/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.polaris.service.types;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import org.apache.iceberg.catalog.Namespace;
import org.immutables.value.Value;

/**
 * Represents a modified version of the PolicyIdentifier that is different from the one generated by
 * the OpenAPI generator
 *
 * <p>the open api generation inlines the namespace definition, generates a {@code List<String>}
 * directly, instead of generating a Namespace class. This version uses {@link Namespace} for
 * namespace field.
 *
 * <p>TODO: make code generation use {@link Namespace} directly
 */
@Value.Builder
public record PolicyIdentifier(
    @ApiModelProperty(
            example = "[\"accounting\",\"tax\"]",
            required = true,
            value = "Reference to one or more levels of a namespace")
        @JsonProperty(value = "namespace", required = true)
        Namespace namespace,
    @ApiModelProperty(required = true) @JsonProperty(value = "name", required = true) String name) {

  public static PolicyIdentifierBuilder builder() {
    return new PolicyIdentifierBuilder();
  }
}
