// Copyright 2025 Google LLC
//
// Licensed 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.

syntax = "proto3";

package google.cloud.managedkafka.schemaregistry.v1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/httpbody.proto";
import "google/api/resource.proto";
import "google/cloud/managedkafka/schemaregistry/v1/schema_registry_resources.proto";
import "google/protobuf/empty.proto";

option csharp_namespace = "Google.Cloud.ManagedKafka.SchemaRegistry.V1";
option go_package = "cloud.google.com/go/managedkafka/schemaregistry/apiv1/schemaregistrypb;schemaregistrypb";
option java_multiple_files = true;
option java_outer_classname = "SchemaRegistryProto";
option java_package = "com.google.cloud.managedkafka.schemaregistry.v1";
option php_namespace = "Google\\Cloud\\ManagedKafka\\SchemaRegistry\\V1";
option ruby_package = "Google::Cloud::ManagedKafka::SchemaRegistry::V1";

// SchemaRegistry is a service that allows users to manage schemas for their
// Kafka clusters. It provides APIs to register, list, and delete schemas, as
// well as to get the schema for a given schema id or a given version id under a
// subject, to update the global or subject-specific compatibility mode, and to
// check the compatibility of a schema against a subject or a version. The main
// resource hierarchy is as follows:
//
// * SchemaRegistry
// * SchemaRegistry/Context
// * SchemaRegistry/Context/Schema
// * SchemaRegistry/Context/Subject
// * SchemaRegistry/Context/Subject/Version
// * SchemaRegistry/Config
// * SchemaRegistry/Mode
//
// **SchemaRegistry** is the root resource to represent a schema registry
// instance. A customer can have multiple schema registry instances in a
// project.
//
// **Context** is a context resource that represents a group of
// schemas, subjects and versions. A schema registry instance can have multiple
// contexts and always has a 'default' context. Contexts are independent of each
// other. Context is optional and if not specified, it falls back to the
// 'default' context.
//
// **Schema** is a schema resource that represents a unique schema in a context
// of a schema registry instance. Each schema has a unique schema id, and can be
// referenced by a version of a subject.
//
// **Subject** refers to the name under which the schema is registered. A
// typical subject is the Kafka topic name. A schema registry instance can have
// multiple subjects.
//
// **Version** represents a version of a subject. A subject can have multiple
// versions. Creation of new version of a subject is guarded by the
// compatibility mode configured globally or for the subject specifically.
//
// **Config** represents a config at global level cross all registry
// instances or at subject level. Currently, only compatibility is supported in
// config.
//
// **Mode** represents the mode of a schema registry or a specific subject.
// Three modes are supported:
// * READONLY: The schema registry is in read-only mode, no write operations
// allowed..
// * READWRITE: The schema registry is in read-write mode, which allows limited
// write operations on the schema.
// * IMPORT: The schema registry is in import mode, which allows more editing
// operations on the schema for data importing purposes.
service ManagedSchemaRegistry {
  option (google.api.default_host) = "managedkafka.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Get the schema registry instance.
  rpc GetSchemaRegistry(GetSchemaRegistryRequest) returns (SchemaRegistry) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/schemaRegistries/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // List schema registries.
  rpc ListSchemaRegistries(ListSchemaRegistriesRequest)
      returns (ListSchemaRegistriesResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*}/schemaRegistries"
    };
    option (google.api.method_signature) = "parent";
  }

  // Create a schema registry instance.
  rpc CreateSchemaRegistry(CreateSchemaRegistryRequest)
      returns (SchemaRegistry) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/schemaRegistries"
      body: "*"
    };
    option (google.api.method_signature) = "parent,schema_registry";
  }

  // Delete a schema registry instance.
  rpc DeleteSchemaRegistry(DeleteSchemaRegistryRequest)
      returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/schemaRegistries/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Get the context.
  rpc GetContext(GetContextRequest) returns (Context) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // List contexts for a schema registry.
  rpc ListContexts(ListContextsRequest) returns (google.api.HttpBody) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*}/contexts"
    };
    option (google.api.method_signature) = "parent";
  }

  // Get the schema for the given schema id.
  rpc GetSchema(GetSchemaRequest) returns (Schema) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/schemas/**}"
      additional_bindings {
        get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/schemas/**}"
      }
    };
    option (google.api.method_signature) = "name";
  }

  // Get the schema string for the given schema id.
  // The response will be the schema string.
  rpc GetRawSchema(GetSchemaRequest) returns (google.api.HttpBody) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/schemas/**}/schema"
      additional_bindings {
        get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/schemas/**}/schema"
      }
    };
    option (google.api.method_signature) = "name";
  }

  // List the schema versions for the given schema id.
  // The response will be an array of subject-version pairs as:
  // [{"subject":"subject1", "version":1}, {"subject":"subject2", "version":2}].
  rpc ListSchemaVersions(ListSchemaVersionsRequest)
      returns (google.api.HttpBody) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/schemas/**}/versions"
      additional_bindings {
        get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/contexts/*/schemas/**}/versions"
      }
    };
    option (google.api.method_signature) = "parent";
  }

  // List the supported schema types.
  // The response will be an array of schema types.
  rpc ListSchemaTypes(ListSchemaTypesRequest) returns (google.api.HttpBody) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*}/schemas/types"
      additional_bindings {
        get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/contexts/*}/schemas/types"
      }
    };
    option (google.api.method_signature) = "parent";
  }

  // List subjects in the schema registry.
  // The response will be an array of subject names.
  rpc ListSubjects(ListSubjectsRequest) returns (google.api.HttpBody) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*}/subjects"
      additional_bindings {
        get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/contexts/*}/subjects"
      }
    };
    option (google.api.method_signature) = "parent,subject_prefix,deleted";
  }

  // List subjects which reference a particular schema id.
  // The response will be an array of subject names.
  rpc ListSubjectsBySchemaId(ListSubjectsBySchemaIdRequest)
      returns (google.api.HttpBody) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/schemas/**}/subjects"
      additional_bindings {
        get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/contexts/*/schemas/**}/subjects"
      }
    };
    option (google.api.method_signature) = "parent,subject,deleted";
  }

  // Delete a subject.
  // The response will be an array of versions of the deleted subject.
  rpc DeleteSubject(DeleteSubjectRequest) returns (google.api.HttpBody) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/schemaRegistries/*/subjects/*}"
      additional_bindings {
        delete: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/subjects/*}"
      }
    };
    option (google.api.method_signature) = "name";
  }

  // Lookup a schema under the specified subject.
  rpc LookupVersion(LookupVersionRequest) returns (SchemaVersion) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/subjects/*}"
      body: "*"
      additional_bindings {
        post: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/contexts/*/subjects/*}"
        body: "*"
      }
    };
    option (google.api.method_signature) = "parent,schema";
  }

  // Get a versioned schema (schema with subject/version) of a subject.
  rpc GetVersion(GetVersionRequest) returns (SchemaVersion) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/subjects/*/versions/*}"
      additional_bindings {
        get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/subjects/*/versions/*}"
      }
    };
    option (google.api.method_signature) = "name";
  }

  // Get the schema string only for a version of a subject.
  // The response will be the schema string.
  rpc GetRawSchemaVersion(GetVersionRequest) returns (google.api.HttpBody) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/subjects/*/versions/*}/schema"
      additional_bindings {
        get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/subjects/*/versions/*}/schema"
      }
    };
    option (google.api.method_signature) = "name";
  }

  // Get all versions of a subject.
  // The response will be an array of versions of the subject.
  rpc ListVersions(ListVersionsRequest) returns (google.api.HttpBody) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/subjects/*}/versions"
      additional_bindings {
        get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/contexts/*/subjects/*}/versions"
      }
    };
    option (google.api.method_signature) = "parent";
  }

  // Register a new version under a given subject with the given schema.
  rpc CreateVersion(CreateVersionRequest) returns (CreateVersionResponse) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/subjects/*}/versions"
      body: "*"
      additional_bindings {
        post: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/contexts/*/subjects/*}/versions"
        body: "*"
      }
    };
    option (google.api.method_signature) =
        "parent,version,id,schema_type,schema,references,normalize";
  }

  // Delete a version of a subject.
  // The response will be the deleted version id.
  rpc DeleteVersion(DeleteVersionRequest) returns (google.api.HttpBody) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/schemaRegistries/*/subjects/*/versions/*}"
      additional_bindings {
        delete: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/subjects/*/versions/*}"
      }
    };
    option (google.api.method_signature) = "name";
  }

  // Get a list of IDs of schemas that reference the schema with the given
  // subject and version.
  rpc ListReferencedSchemas(ListReferencedSchemasRequest)
      returns (google.api.HttpBody) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/subjects/*/versions/*}/referencedby"
      additional_bindings {
        get: "/v1/{parent=projects/*/locations/*/schemaRegistries/*/contexts/*/subjects/*/versions/*}/referencedby"
      }
    };
    option (google.api.method_signature) = "parent";
  }

  // Check compatibility of a schema with all versions or a specific version of
  // a subject.
  rpc CheckCompatibility(CheckCompatibilityRequest)
      returns (CheckCompatibilityResponse) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/schemaRegistries/*/compatibility/**}"
      body: "*"
      additional_bindings {
        post: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/compatibility/**}"
        body: "*"
      }
    };
    option (google.api.method_signature) = "name,schema";
  }

  // Get schema config at global level or for a subject.
  rpc GetSchemaConfig(GetSchemaConfigRequest) returns (SchemaConfig) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/config/**}"
      additional_bindings {
        get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/config/**}"
      }
    };
    option (google.api.method_signature) = "name";
  }

  // Update config at global level or for a subject.
  // Creates a SchemaSubject-level SchemaConfig if it does not exist.
  rpc UpdateSchemaConfig(UpdateSchemaConfigRequest) returns (SchemaConfig) {
    option (google.api.http) = {
      put: "/v1/{name=projects/*/locations/*/schemaRegistries/*/config/**}"
      body: "*"
      additional_bindings {
        put: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/config/**}"
        body: "*"
      }
    };
    option (google.api.method_signature) = "name,compatibility";
  }

  // Delete schema config for a subject.
  rpc DeleteSchemaConfig(DeleteSchemaConfigRequest) returns (SchemaConfig) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/schemaRegistries/*/config/**}"
      additional_bindings {
        delete: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/config/**}"
      }
    };
    option (google.api.method_signature) = "name";
  }

  // Get mode at global level or for a subject.
  rpc GetSchemaMode(GetSchemaModeRequest) returns (SchemaMode) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/mode/**}"
      additional_bindings {
        get: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/mode/**}"
      }
    };
    option (google.api.method_signature) = "name";
  }

  // Update mode at global level or for a subject.
  rpc UpdateSchemaMode(UpdateSchemaModeRequest) returns (SchemaMode) {
    option (google.api.http) = {
      put: "/v1/{name=projects/*/locations/*/schemaRegistries/*/mode/**}"
      body: "*"
      additional_bindings {
        put: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/mode/**}"
        body: "*"
      }
    };
    option (google.api.method_signature) = "name,mode";
  }

  // Delete schema mode for a subject.
  rpc DeleteSchemaMode(DeleteSchemaModeRequest) returns (SchemaMode) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/schemaRegistries/*/mode/**}"
      additional_bindings {
        delete: "/v1/{name=projects/*/locations/*/schemaRegistries/*/contexts/*/mode/**}"
      }
    };
    option (google.api.method_signature) = "name";
  }
}

// Request for GetSchemaRegistry.
message GetSchemaRegistryRequest {
  // Required. The name of the schema registry instance to return. Structured
  // like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaRegistry"
    }
  ];
}

// Request for ListSchemaRegistries.
message ListSchemaRegistriesRequest {
  // Required. The parent whose schema registry instances are to be listed.
  // Structured like: `projects/{project}/locations/{location}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "*" }
  ];
}

// Request for ListSchemaRegistries.
message ListSchemaRegistriesResponse {
  // The schema registry instances.
  repeated SchemaRegistry schema_registries = 1;
}

// Request to create a schema registry instance.
message CreateSchemaRegistryRequest {
  // Required. The parent whose schema registry instance is to be created.
  // Structured like: `projects/{project}/locations/{location}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "*" }
  ];

  // Required. The schema registry instance ID to use for this schema registry.
  // The ID must contain only letters (a-z, A-Z), numbers (0-9), and underscores
  // (-). The maximum length is 63 characters.
  // The ID must not start with a number.
  string schema_registry_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The schema registry instance to create.
  // The name field is ignored.
  SchemaRegistry schema_registry = 3 [(google.api.field_behavior) = REQUIRED];
}

// Request for DeleteSchemaRegistry.
message DeleteSchemaRegistryRequest {
  // Required. The name of the schema registry instance to delete. Structured
  // like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaRegistry"
    }
  ];
}

// Request for GetContext
message GetContextRequest {
  // Required. The name of the context to return. Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaContext"
    }
  ];
}

// Request for ListContexts.
message ListContextsRequest {
  // Required. The parent of the contexts. Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaRegistry"
    }
  ];
}

// Request for GetSchema.
message GetSchemaRequest {
  // Required. The name of the schema to return. Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/schemas/ids/{schema}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/Schema"
    }
  ];

  // Optional. Used to limit the search for the schema ID to a specific subject,
  // otherwise the schema ID will be searched for in all subjects in the given
  // specified context.
  optional string subject = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Request for ListSchemaTypes.
message ListSchemaTypesRequest {
  // Required. The parent schema registry whose schema types are to be listed.
  // Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "*" }
  ];
}

// Request for ListSchemaVersions.
message ListSchemaVersionsRequest {
  // Required. The schema whose schema versions are to be listed. Structured
  // like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/schemas/ids/{schema}`
  // or
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/schemas/ids/{schema}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/Schema"
    }
  ];

  // Optional. The subject to filter the subjects by.
  optional string subject = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. If true, the response will include soft-deleted versions of the
  // schema, even if the subject is soft-deleted. The default is false.
  optional bool deleted = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Request for listing subjects.
message ListSubjectsRequest {
  // Required. The parent schema registry/context whose subjects are to be
  // listed. Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}`
  // or
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "*" }
  ];

  // Optional. The context to filter the subjects by, in the format of
  // `:.{context}:`. If unset, all subjects in the registry are returned. Set to
  // empty string or add as
  // '?subjectPrefix=' at the end of this request to list subjects in the
  // default context.
  optional string subject_prefix = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. If true, the response will include soft-deleted subjects. The
  // default is false.
  optional bool deleted = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Request for listing subjects.
message ListSubjectsBySchemaIdRequest {
  // Required. The schema resource whose associated subjects are to be listed.
  // Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/schemas/ids/{schema}`
  // or
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/schemas/ids/{schema}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "*" }
  ];

  // Optional. The subject to filter the subjects by.
  optional string subject = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. If true, the response will include soft-deleted subjects. The
  // default is false.
  optional bool deleted = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Request for GetVersions.
message ListVersionsRequest {
  // Required. The subject whose versions are to be listed. Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/subjects/{subject}`
  // or
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaSubject"
    }
  ];

  // Optional. If true, the response will include soft-deleted versions of an
  // active or soft-deleted subject. The default is false.
  optional bool deleted = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Request for DeleteSubject.
message DeleteSubjectRequest {
  // Required. The name of the subject to delete. Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/subjects/{subject}`
  // or
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaSubject"
    }
  ];

  // Optional. If true, the subject and all associated metadata including the
  // schema ID will be deleted permanently. Otherwise, only the subject is
  // soft-deleted. The default is false. Soft-deleted subjects can still be
  // searched in ListSubjects API call with deleted=true query parameter. A
  // soft-delete of a subject must be performed before a hard-delete.
  optional bool permanent = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Request for GetVersion.
message GetVersionRequest {
  // Required. The name of the subject to return versions. Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/subjects/{subject}/versions/{version}`
  // or
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}/versions/{version}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaVersion"
    }
  ];

  // Optional. If true, no matter if the subject/version is soft-deleted or not,
  // it returns the version details. If false, it returns NOT_FOUND error if the
  // subject/version is soft-deleted. The default is false.
  optional bool deleted = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Request for CreateVersion.
message CreateVersionRequest {
  // Required. The subject to create the version for. Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/subjects/{subject}`
  // or
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaSubject"
    }
  ];

  // Optional. The version to create. It is optional. If not specified, the
  // version will be created with the max version ID of the subject increased
  // by 1. If the version ID is specified, it will be used as the new version ID
  // and must not be used by an existing version of the subject.
  optional int32 version = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The schema ID of the schema. If not specified, the schema ID will
  // be generated by the server. If the schema ID is specified, it must not be
  // used by an existing schema that is different from the schema to be created.
  optional int32 id = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The type of the schema. It is optional. If not specified, the
  // schema type will be AVRO.
  optional Schema.SchemaType schema_type = 4
      [(google.api.field_behavior) = OPTIONAL];

  // Required. The schema payload
  string schema = 5 [(google.api.field_behavior) = REQUIRED];

  // Optional. The schema references used by the schema.
  repeated Schema.SchemaReference references = 6
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. If true, the schema will be normalized before being stored. The
  // default is false.
  optional bool normalize = 7 [(google.api.field_behavior) = OPTIONAL];
}

// Response for CreateVersion.
message CreateVersionResponse {
  // The unique identifier of the schema created.
  int32 id = 1;
}

// Request for LookupVersion.
message LookupVersionRequest {
  // Required. The subject to lookup the schema in. Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/subjects/{subject}`
  // or
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaSubject"
    }
  ];

  // Optional. The schema type of the schema.
  optional Schema.SchemaType schema_type = 2
      [(google.api.field_behavior) = OPTIONAL];

  // Required. The schema payload
  string schema = 3 [(google.api.field_behavior) = REQUIRED];

  // Optional. The schema references used by the schema.
  repeated Schema.SchemaReference references = 4
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. If true, the schema will be normalized before being looked up.
  // The default is false.
  optional bool normalize = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. If true, soft-deleted versions will be included in lookup, no
  // matter if the subject is active or soft-deleted. If false, soft-deleted
  // versions will be excluded. The default is false.
  optional bool deleted = 6 [(google.api.field_behavior) = OPTIONAL];
}

// Request for DeleteVersion.
message DeleteVersionRequest {
  // Required. The name of the subject version to delete. Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/subjects/{subject}/versions/{version}`
  // or
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}/versions/{version}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaVersion"
    }
  ];

  // Optional. If true, both the version and the referenced schema ID will be
  // permanently deleted. The default is false. If false, the version will be
  // deleted but the schema ID will be retained. Soft-deleted versions can still
  // be searched in ListVersions API call with deleted=true query parameter. A
  // soft-delete of a version must be performed before a hard-delete.
  optional bool permanent = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Request for ListReferencedSchemas.
message ListReferencedSchemasRequest {
  // Required. The version to list referenced by. Structured like:
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/subjects/{subject}/versions/{version}`
  // or
  // `projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}/versions/{version}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaVersion"
    }
  ];
}

// Request for CheckCompatibility.
message CheckCompatibilityRequest {
  // Required. The name of the resource to check compatibility for. The format
  // is either of following:
  // * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/compatibility/subjects/*/versions: Check compatibility with one or
  //   more versions of the specified subject.
  // * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/compatibility/subjects/{subject}/versions/{version}: Check
  //   compatibility with a specific version of the subject.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "*" }
  ];

  // Optional. The schema type of the schema.
  optional Schema.SchemaType schema_type = 2
      [(google.api.field_behavior) = OPTIONAL];

  // Required. The schema payload
  string schema = 3 [(google.api.field_behavior) = REQUIRED];

  // Optional. The schema references used by the schema.
  repeated Schema.SchemaReference references = 4
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. If true, the response will contain the compatibility check result
  // with reasons for failed checks. The default is false.
  optional bool verbose = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Response for CheckCompatibility.
message CheckCompatibilityResponse {
  // The compatibility check result. If true, the schema is compatible with the
  // resource.
  bool is_compatible = 1 [json_name = "is_compatible"];

  // Failure reasons if verbose = true.
  repeated string messages = 2;
}

// Request for getting config.
message GetSchemaConfigRequest {
  // Required. The resource name to get the config for. It can be either of
  // following:
  //   * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/config: Get config at global level.
  //   * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/config/{subject}: Get config for a specific subject.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaConfig"
    }
  ];

  // Optional. If true, the config will fall back to the config at the global
  // level if no subject level config is found.
  optional bool default_to_global = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Request for updating schema config.
// On a SchemaSubject-level SchemaConfig, an unset field will be removed from
// the SchemaConfig.
message UpdateSchemaConfigRequest {
  // Required. The resource name to update the config for. It can be either of
  // following:
  //   * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/config: Update config at global level.
  //   * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/config/{subject}: Update config for a specific subject.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaConfig"
    }
  ];

  // Required. The compatibility type of the schemas.
  // Cannot be unset for a SchemaRegistry-level SchemaConfig.
  // If unset on a SchemaSubject-level SchemaConfig, removes the compatibility
  // field for the SchemaConfig.
  optional SchemaConfig.CompatibilityType compatibility = 2
      [(google.api.field_behavior) = REQUIRED];

  // Optional. If true, the schema will be normalized before being stored or
  // looked up. The default is false. Cannot be unset for a SchemaRegistry-level
  // SchemaConfig. If unset on a SchemaSubject-level SchemaConfig, removes the
  // normalize field for the SchemaConfig.
  optional bool normalize = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Request for deleting schema config.
message DeleteSchemaConfigRequest {
  // Required. The resource name of subject to delete the config for. The format
  // is
  //   * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/config/{subject}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaConfig"
    }
  ];
}

// Request for getting schema registry or subject mode.
message GetSchemaModeRequest {
  // Required. The resource name of the mode. The format is
  //   * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/mode/{subject}: mode for a schema registry, or
  //   * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/mode/{subject}: mode for a specific subject in a specific context
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaMode"
    }
  ];
}

// Request for updating schema registry or subject mode.
message UpdateSchemaModeRequest {
  // Required. The resource name of the mode. The format is
  //   * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/mode/{subject}: mode for a schema registry, or
  //   * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/mode/{subject}: mode for a specific subject in a specific context
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaMode"
    }
  ];

  // Required. The mode type.
  SchemaMode.ModeType mode = 2 [(google.api.field_behavior) = REQUIRED];
}

// Request for deleting schema mode.
message DeleteSchemaModeRequest {
  // Required. The resource name of subject to delete the mode for. The format
  // is
  //   * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/mode/{subject}
  //   * projects/{project}/locations/{location}/schemaRegistries/{schema_registry}/contexts/{context}/mode/{subject}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/SchemaMode"
    }
  ];
}
