// 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.apihub.v1;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.ApiHub.V1";
option go_package = "cloud.google.com/go/apihub/apiv1/apihubpb;apihubpb";
option java_multiple_files = true;
option java_outer_classname = "CommonFieldsProto";
option java_package = "com.google.cloud.apihub.v1";
option php_namespace = "Google\\Cloud\\ApiHub\\V1";
option ruby_package = "Google::Cloud::ApiHub::V1";
option (google.api.resource_definition) = {
  type: "aiplatform.googleapis.com/Extension"
  pattern: "projects/{project}/locations/{location}/extensions/{extension}"
};
option (google.api.resource_definition) = {
  type: "iam.googleapis.com/ServiceAccount"
  pattern: "projects/{project}/serviceAccounts/{service_account}"
};

// Lint state represents success or failure for linting.
enum LintState {
  // Lint state unspecified.
  LINT_STATE_UNSPECIFIED = 0;

  // Linting was completed successfully.
  LINT_STATE_SUCCESS = 1;

  // Linting encountered errors.
  LINT_STATE_ERROR = 2;
}

// Enumeration of linter types.
enum Linter {
  // Linter type unspecified.
  LINTER_UNSPECIFIED = 0;

  // Linter type spectral.
  SPECTRAL = 1;

  // Linter type other.
  OTHER = 2;
}

// Severity of the issue.
enum Severity {
  // Severity unspecified.
  SEVERITY_UNSPECIFIED = 0;

  // Severity error.
  SEVERITY_ERROR = 1;

  // Severity warning.
  SEVERITY_WARNING = 2;

  // Severity info.
  SEVERITY_INFO = 3;

  // Severity hint.
  SEVERITY_HINT = 4;
}

// AuthType represents the authentication type.
enum AuthType {
  // Authentication type not specified.
  AUTH_TYPE_UNSPECIFIED = 0;

  // No authentication.
  NO_AUTH = 1;

  // Google service account authentication.
  GOOGLE_SERVICE_ACCOUNT = 2;

  // Username and password authentication.
  USER_PASSWORD = 3;

  // API Key authentication.
  API_KEY = 4;

  // Oauth 2.0 client credentials grant authentication.
  OAUTH2_CLIENT_CREDENTIALS = 5;
}

// Enum for the plugin category.
enum PluginCategory {
  // Default unspecified plugin type.
  PLUGIN_CATEGORY_UNSPECIFIED = 0;

  // API_GATEWAY plugins represent plugins built for API Gateways like Apigee.
  API_GATEWAY = 1;

  // API_PRODUCER plugins represent plugins built for API Producers like
  // Cloud Run, Application Integration etc.
  API_PRODUCER = 2;
}

// An API resource in the API Hub.
message Api {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/Api"
    pattern: "projects/{project}/locations/{location}/apis/{api}"
    plural: "apis"
    singular: "api"
  };

  // Identifier. The name of the API resource in the API Hub.
  //
  // Format:
  // `projects/{project}/locations/{location}/apis/{api}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. The display name of the API resource.
  string display_name = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. The description of the API resource.
  string description = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The documentation for the API resource.
  Documentation documentation = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Owner details for the API resource.
  Owner owner = 5 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The list of versions present in an API resource.
  // Note: An API resource can be associated with more than 1 version.
  // Format is
  // `projects/{project}/locations/{location}/apis/{api}/versions/{version}`
  repeated string versions = 6 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = { type: "apihub.googleapis.com/Version" }
  ];

  // Output only. The time at which the API resource was created.
  google.protobuf.Timestamp create_time = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the API resource was last updated.
  google.protobuf.Timestamp update_time = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The target users for the API.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-target-user`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. All values should be from the list of allowed values defined for the
  // attribute.
  AttributeValues target_user = 9 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The team owning the API.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-team`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. All values should be from the list of allowed values defined for the
  // attribute.
  AttributeValues team = 10 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The business unit owning the API.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-business-unit`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. All values should be from the list of allowed values defined for the
  // attribute.
  AttributeValues business_unit = 11 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The maturity level of the API.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-maturity-level`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. All values should be from the list of allowed values defined for the
  // attribute.
  AttributeValues maturity_level = 12 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The list of user defined attributes associated with the API
  // resource. The key is the attribute name. It will be of the format:
  // `projects/{project}/locations/{location}/attributes/{attribute}`.
  // The value is the attribute values associated with the resource.
  map<string, AttributeValues> attributes = 13
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The style of the API.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-api-style`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. All values should be from the list of allowed values defined for the
  // attribute.
  AttributeValues api_style = 14 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The selected version for an API resource.
  // This can be used when special handling is needed on client side for
  // particular version of the API. Format is
  // `projects/{project}/locations/{location}/apis/{api}/versions/{version}`
  string selected_version = 15 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = { type: "apihub.googleapis.com/Version" }
  ];

  // Optional. The api requirement doc associated with the API resource.
  // Carinality is 1 for this attribute. This maps to the following system
  // defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-api-requirements`
  // attribute. The value of the attribute should be a proper URI, and in case
  // of Cloud Storage URI, it should point to a Cloud Storage object,
  // not a directory.
  AttributeValues api_requirements = 16
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Fingerprint of the API resource.
  string fingerprint = 17 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The list of sources and metadata from the sources of the API
  // resource.
  repeated SourceMetadata source_metadata = 18
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The api functional requirements associated with the API resource.
  // Carinality is 1 for this attribute.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-api-functional-requirements`
  // attribute. The value of the attribute should be a proper URI, and in case
  // of Cloud Storage URI, it should point to a Cloud Storage object,
  // not a directory.
  AttributeValues api_functional_requirements = 19
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The api technical requirements associated with the API resource.
  // Carinality is 1 for this attribute. This maps to the following system
  // defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-api-technical-requirements`
  // attribute. The value of the attribute should be a proper URI, and in case
  // of Cloud Storage URI, it should point to a Cloud Storage object,
  // not a directory.
  AttributeValues api_technical_requirements = 20
      [(google.api.field_behavior) = OPTIONAL];
}

// Represents a version of the API resource in API hub. This is also referred
// to as the API version.
message Version {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/Version"
    pattern: "projects/{project}/locations/{location}/apis/{api}/versions/{version}"
    plural: "versions"
    singular: "version"
  };

  // Identifier. The name of the version.
  //
  // Format:
  // `projects/{project}/locations/{location}/apis/{api}/versions/{version}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. The display name of the version.
  string display_name = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. The description of the version.
  string description = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The documentation of the version.
  Documentation documentation = 4 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The specs associated with this version.
  // Note that an API version can be associated with multiple specs.
  // Format is
  // `projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}`
  repeated string specs = 5 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = { type: "apihub.googleapis.com/Spec" }
  ];

  // Output only. The operations contained in the API version.
  // These operations will be added to the version when a new spec is
  // added or when an existing spec is updated. Format is
  // `projects/{project}/locations/{location}/apis/{api}/versions/{version}/operations/{operation}`
  repeated string api_operations = 6 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "apihub.googleapis.com/ApiOperation"
    }
  ];

  // Output only. The definitions contained in the API version.
  // These definitions will be added to the version when a new spec is
  // added or when an existing spec is updated. Format is
  // `projects/{project}/locations/{location}/apis/{api}/versions/{version}/definitions/{definition}`
  repeated string definitions = 7 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "apihub.googleapis.com/Definition"
    }
  ];

  // Optional. The deployments linked to this API version.
  // Note: A particular API version could be deployed to multiple deployments
  // (for dev deployment, UAT deployment, etc)
  // Format is
  // `projects/{project}/locations/{location}/deployments/{deployment}`
  repeated string deployments = 8 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "apihub.googleapis.com/Deployment"
    }
  ];

  // Output only. The time at which the version was created.
  google.protobuf.Timestamp create_time = 9
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the version was last updated.
  google.protobuf.Timestamp update_time = 10
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The lifecycle of the API version.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-lifecycle`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. All values should be from the list of allowed values defined for the
  // attribute.
  AttributeValues lifecycle = 11 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The compliance associated with the API version.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-compliance`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. All values should be from the list of allowed values defined for the
  // attribute.
  AttributeValues compliance = 12 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The accreditations associated with the API version.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-accreditation`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. All values should be from the list of allowed values defined for the
  // attribute.
  AttributeValues accreditation = 13 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The list of user defined attributes associated with the Version
  // resource. The key is the attribute name. It will be of the format:
  // `projects/{project}/locations/{location}/attributes/{attribute}`.
  // The value is the attribute values associated with the resource.
  map<string, AttributeValues> attributes = 14
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The selected deployment for a Version resource.
  // This can be used when special handling is needed on client side for a
  // particular deployment linked to the version.
  // Format is
  // `projects/{project}/locations/{location}/deployments/{deployment}`
  string selected_deployment = 16 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "apihub.googleapis.com/Deployment"
    }
  ];

  // Output only. The list of sources and metadata from the sources of the
  // version.
  repeated SourceMetadata source_metadata = 17
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Represents a spec associated with an API version in the API
// Hub. Note that specs of various types can be uploaded, however
// parsing of details is supported for OpenAPI spec currently.
message Spec {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/Spec"
    pattern: "projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}"
    plural: "specs"
    singular: "spec"
  };

  // Specifies the parsing mode for API specifications during creation and
  // update.
  // - `RELAXED`: Parsing errors in the specification content do not fail the
  // API call.
  // - `STRICT`: Parsing errors in the specification content result in failure
  // of the API call.
  // If not specified, defaults to `RELAXED`.
  enum ParsingMode {
    // Defaults to `RELAXED`.
    PARSING_MODE_UNSPECIFIED = 0;

    // Parsing of the Spec on create and update is relaxed, meaning that
    // parsing errors the spec contents will not fail the API call.
    RELAXED = 1;

    // Parsing of the Spec on create and update is strict, meaning that
    // parsing errors in the spec contents will fail the API call.
    STRICT = 2;
  }

  // Identifier. The name of the spec.
  //
  // Format:
  // `projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. The display name of the spec.
  // This can contain the file name of the spec.
  string display_name = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The type of spec.
  // The value should be one of the allowed values defined for
  // `projects/{project}/locations/{location}/attributes/system-spec-type`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API.
  //
  // Note, this field is mandatory if content is provided.
  AttributeValues spec_type = 3 [(google.api.field_behavior) = REQUIRED];

  // Optional. Input only. The contents of the uploaded spec.
  SpecContents contents = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = INPUT_ONLY
  ];

  // Output only. Details parsed from the spec.
  SpecDetails details = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The URI of the spec source in case file is uploaded
  // from an external version control system.
  string source_uri = 6 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The time at which the spec was created.
  google.protobuf.Timestamp create_time = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the spec was last updated.
  google.protobuf.Timestamp update_time = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The lint response for the spec.
  LintResponse lint_response = 9 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The list of user defined attributes associated with the spec.
  // The key is the attribute name. It will be of the format:
  // `projects/{project}/locations/{location}/attributes/{attribute}`.
  // The value is the attribute values associated with the resource.
  map<string, AttributeValues> attributes = 10
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The documentation of the spec.
  // For OpenAPI spec, this will be populated from `externalDocs` in OpenAPI
  // spec.
  Documentation documentation = 11 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Input only. Enum specifying the parsing mode for OpenAPI
  // Specification (OAS) parsing.
  ParsingMode parsing_mode = 12 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = INPUT_ONLY
  ];

  // Output only. The list of sources and metadata from the sources of the spec.
  repeated SourceMetadata source_metadata = 13
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Details of the deployment where APIs are hosted.
// A deployment could represent an Apigee proxy, API gateway, other Google Cloud
// services or non-Google Cloud services as well. A deployment entity is a root
// level entity in the API hub and exists independent of any API.
message Deployment {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/Deployment"
    pattern: "projects/{project}/locations/{location}/deployments/{deployment}"
    plural: "deployments"
    singular: "deployment"
  };

  // Identifier. The name of the deployment.
  //
  // Format:
  // `projects/{project}/locations/{location}/deployments/{deployment}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. The display name of the deployment.
  string display_name = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. The description of the deployment.
  string description = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The documentation of the deployment.
  Documentation documentation = 4 [(google.api.field_behavior) = OPTIONAL];

  // Required. The type of deployment.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-deployment-type`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. All values should be from the list of allowed values defined for the
  // attribute.
  AttributeValues deployment_type = 5 [(google.api.field_behavior) = REQUIRED];

  // Required. The resource URI identifies the deployment within its gateway.
  // For Apigee gateways, its recommended to use the format:
  // organizations/{org}/environments/{env}/apis/{api}.
  // For ex: if a proxy with name `orders` is deployed in `staging`
  // environment of `cymbal` organization, the resource URI would be:
  // `organizations/cymbal/environments/staging/apis/orders`.
  string resource_uri = 6 [(google.api.field_behavior) = REQUIRED];

  // Required. The endpoints at which this deployment resource is listening for
  // API requests. This could be a list of complete URIs, hostnames or an IP
  // addresses.
  repeated string endpoints = 7 [(google.api.field_behavior) = REQUIRED];

  // Output only. The API versions linked to this deployment.
  // Note: A particular deployment could be linked to multiple different API
  // versions (of same or different APIs).
  repeated string api_versions = 8 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the deployment was created.
  google.protobuf.Timestamp create_time = 9
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the deployment was last updated.
  google.protobuf.Timestamp update_time = 10
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The SLO for this deployment.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-slo`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. All values should be from the list of allowed values defined for the
  // attribute.
  AttributeValues slo = 11 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The environment mapping to this deployment.
  // This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-environment`
  // attribute.
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. All values should be from the list of allowed values defined for the
  // attribute.
  AttributeValues environment = 12 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The list of user defined attributes associated with the
  // deployment resource. The key is the attribute name. It will be of the
  // format: `projects/{project}/locations/{location}/attributes/{attribute}`.
  // The value is the attribute values associated with the resource.
  map<string, AttributeValues> attributes = 13
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The list of sources and metadata from the sources of the
  // deployment.
  repeated SourceMetadata source_metadata = 14
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The uri where users can navigate to for the management of the
  // deployment. This maps to the following system defined attribute:
  // `projects/{project}/locations/{location}/attributes/system-management-url`
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. The value of the attribute should be a valid URL.
  AttributeValues management_url = 15 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The uri where additional source specific information for this
  // deployment can be found. This maps to the following system defined
  // attribute:
  // `projects/{project}/locations/{location}/attributes/system-source-uri`
  // The number of values for this attribute will be based on the
  // cardinality of the attribute. The same can be retrieved via GetAttribute
  // API. The value of the attribute should be a valid URI, and in case
  // of Cloud Storage URI, it should point to a Cloud Storage object,
  // not a directory.
  AttributeValues source_uri = 16 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The project to which the deployment belongs.
  // For GCP gateways, this will refer to the project identifier.
  // For others like Edge/OPDK, this will refer to the org identifier.
  string source_project = 17 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The environment at source for the deployment.
  // For example: prod, dev, staging, etc.
  string source_environment = 18 [(google.api.field_behavior) = OPTIONAL];
}

// Represents an operation contained in an API version in the API Hub.
// An operation is added/updated/deleted in an API version when a new spec is
// added or an existing spec is updated/deleted in a version.
// Currently, an operation will be created only corresponding to OpenAPI spec as
// parsing is supported for OpenAPI spec.
// Alternatively operations can be managed via create,update and delete APIs,
// creation of apiOperation can be possible only for version with no parsed
// operations and update/delete can be possible only for operations created via
// create API.
message ApiOperation {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/ApiOperation"
    pattern: "projects/{project}/locations/{location}/apis/{api}/versions/{version}/operations/{operation}"
    plural: "apiOperations"
    singular: "apiOperation"
  };

  // Identifier. The name of the operation.
  //
  // Format:
  // `projects/{project}/locations/{location}/apis/{api}/versions/{version}/operations/{operation}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Output only. The name of the spec will be of the format:
  // `projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}`
  // Note:The name of the spec will be empty if the operation is created via
  // [CreateApiOperation][google.cloud.apihub.v1.ApiHub.CreateApiOperation] API.
  string spec = 2 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = { type: "apihub.googleapis.com/Spec" }
  ];

  // Optional. Operation details.
  // Note: Even though this field is optional, it is required for
  // [CreateApiOperation][google.cloud.apihub.v1.ApiHub.CreateApiOperation]
  // API and we will fail the request if not provided.
  OperationDetails details = 3 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The time at which the operation was created.
  google.protobuf.Timestamp create_time = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the operation was last updated.
  google.protobuf.Timestamp update_time = 5
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The list of user defined attributes associated with the API
  // operation resource. The key is the attribute name. It will be of the
  // format: `projects/{project}/locations/{location}/attributes/{attribute}`.
  // The value is the attribute values associated with the resource.
  map<string, AttributeValues> attributes = 6
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The list of sources and metadata from the sources of the API
  // operation.
  repeated SourceMetadata source_metadata = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Represents a definition for example schema, request, response definitions
// contained in an API version.
// A definition is added/updated/deleted in an API version when a new spec is
// added or an existing spec is updated/deleted in a version. Currently,
// definition will be created only corresponding to OpenAPI spec as parsing is
// supported for OpenAPI spec. Also, within OpenAPI spec, only `schema` object
// is supported.
message Definition {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/Definition"
    pattern: "projects/{project}/locations/{location}/apis/{api}/versions/{version}/definitions/{definition}"
    plural: "definitions"
    singular: "definition"
  };

  // Enumeration of definition types.
  enum Type {
    // Definition type unspecified.
    TYPE_UNSPECIFIED = 0;

    // Definition type schema.
    SCHEMA = 1;
  }

  oneof value {
    // Output only. The value of a schema definition.
    Schema schema = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  // Identifier. The name of the definition.
  //
  // Format:
  // `projects/{project}/locations/{location}/apis/{api}/versions/{version}/definitions/{definition}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Output only. The name of the spec from where the definition was parsed.
  // Format is
  // `projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}`
  string spec = 2 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = { type: "apihub.googleapis.com/Spec" }
  ];

  // Output only. The type of the definition.
  Type type = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the definition was created.
  google.protobuf.Timestamp create_time = 5
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the definition was last updated.
  google.protobuf.Timestamp update_time = 6
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The list of user defined attributes associated with the
  // definition resource. The key is the attribute name. It will be of the
  // format: `projects/{project}/locations/{location}/attributes/{attribute}`.
  // The value is the attribute values associated with the resource.
  map<string, AttributeValues> attributes = 7
      [(google.api.field_behavior) = OPTIONAL];
}

// An attribute in the API Hub.
// An attribute is a name value pair which can be attached to different
// resources in the API hub based on the scope of the attribute. Attributes can
// either be pre-defined by the API Hub or created by users.
message Attribute {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/Attribute"
    pattern: "projects/{project}/locations/{location}/attributes/{attribute}"
    plural: "attributes"
    singular: "attribute"
  };

  // The value that can be assigned to the attribute when the data type is
  // enum.
  message AllowedValue {
    // Required. The ID of the allowed value.
    // * If provided, the same will be used. The service will throw an error if
    // the specified id is already used by another allowed value in the same
    // attribute resource.
    // * If not provided, a system generated id derived from the display name
    // will be used. In this case, the service will handle conflict resolution
    // by adding a system generated suffix in case of duplicates.
    //
    // This value should be 4-63 characters, and valid characters
    // are /[a-z][0-9]-/.
    string id = 1 [(google.api.field_behavior) = REQUIRED];

    // Required. The display name of the allowed value.
    string display_name = 2 [(google.api.field_behavior) = REQUIRED];

    // Optional. The detailed description of the allowed value.
    string description = 3 [(google.api.field_behavior) = OPTIONAL];

    // Optional. When set to true, the allowed value cannot be updated or
    // deleted by the user. It can only be true for System defined attributes.
    bool immutable = 4 [(google.api.field_behavior) = OPTIONAL];
  }

  // Enumeration of attribute definition types.
  enum DefinitionType {
    // Attribute definition type unspecified.
    DEFINITION_TYPE_UNSPECIFIED = 0;

    // The attribute is predefined by the API Hub. Note that only the list of
    // allowed values can be updated in this case via UpdateAttribute method.
    SYSTEM_DEFINED = 1;

    // The attribute is defined by the user.
    USER_DEFINED = 2;
  }

  // Enumeration for the scope of the attribute representing the resource in the
  // API Hub to which the attribute can be linked.
  enum Scope {
    // Scope Unspecified.
    SCOPE_UNSPECIFIED = 0;

    // Attribute can be linked to an API.
    API = 1;

    // Attribute can be linked to an API version.
    VERSION = 2;

    // Attribute can be linked to a Spec.
    SPEC = 3;

    // Attribute can be linked to an API Operation.
    API_OPERATION = 4;

    // Attribute can be linked to a Deployment.
    DEPLOYMENT = 5;

    // Attribute can be linked to a Dependency.
    DEPENDENCY = 6;

    // Attribute can be linked to a definition.
    DEFINITION = 7;

    // Attribute can be linked to a ExternalAPI.
    EXTERNAL_API = 8;

    // Attribute can be linked to a Plugin.
    PLUGIN = 9;
  }

  // Enumeration of attribute's data type.
  enum DataType {
    // Attribute data type unspecified.
    DATA_TYPE_UNSPECIFIED = 0;

    // Attribute's value is of type enum.
    ENUM = 1;

    // Attribute's value is of type json.
    JSON = 2;

    // Attribute's value is of type string.
    STRING = 3;

    // Attribute's value is of type uri.
    URI = 4;
  }

  // Identifier. The name of the attribute in the API Hub.
  //
  // Format:
  // `projects/{project}/locations/{location}/attributes/{attribute}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. The display name of the attribute.
  string display_name = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. The description of the attribute.
  string description = 3 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The definition type of the attribute.
  DefinitionType definition_type = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Required. The scope of the attribute. It represents the resource in the API
  // Hub to which the attribute can be linked.
  Scope scope = 5 [(google.api.field_behavior) = REQUIRED];

  // Required. The type of the data of the attribute.
  DataType data_type = 6 [(google.api.field_behavior) = REQUIRED];

  // Optional. The list of allowed values when the attribute value is of type
  // enum. This is required when the data_type of the attribute is ENUM. The
  // maximum number of allowed values of an attribute will be 1000.
  repeated AllowedValue allowed_values = 7
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The maximum number of values that the attribute can have when
  // associated with an API Hub resource. Cardinality 1 would represent a
  // single-valued attribute. It must not be less than 1 or greater than 20. If
  // not specified, the cardinality would be set to 1 by default and represent a
  // single-valued attribute.
  int32 cardinality = 8 [(google.api.field_behavior) = OPTIONAL];

  // Output only. When mandatory is true, the attribute is mandatory for the
  // resource specified in the scope. Only System defined attributes can be
  // mandatory.
  bool mandatory = 9 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the attribute was created.
  google.protobuf.Timestamp create_time = 10
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the attribute was last updated.
  google.protobuf.Timestamp update_time = 11
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The spec contents.
message SpecContents {
  // Required. The contents of the spec.
  bytes contents = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. The mime type of the content for example application/json,
  // application/yaml, application/wsdl etc.
  string mime_type = 2 [(google.api.field_behavior) = REQUIRED];
}

// SpecDetails contains the details parsed from supported
// spec types.
message SpecDetails {
  oneof details {
    // Output only. Additional details apart from `OperationDetails` parsed from
    // an OpenAPI spec. The OperationDetails parsed from the spec can be
    // obtained by using
    // [ListAPIOperations][google.cloud.apihub.v1.ApiHub.ListApiOperations]
    // method.
    OpenApiSpecDetails open_api_spec_details = 2
        [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  // Output only. The description of the spec.
  string description = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// OpenApiSpecDetails contains the details parsed from an OpenAPI spec in
// addition to the fields mentioned in
// [SpecDetails][google.cloud.apihub.v1.SpecDetails].
message OpenApiSpecDetails {
  // Enumeration of spec formats.
  enum Format {
    // SpecFile type unspecified.
    FORMAT_UNSPECIFIED = 0;

    // OpenAPI Spec v2.0.
    OPEN_API_SPEC_2_0 = 1;

    // OpenAPI Spec v3.0.
    OPEN_API_SPEC_3_0 = 2;

    // OpenAPI Spec v3.1.
    OPEN_API_SPEC_3_1 = 3;
  }

  // Output only. The format of the spec.
  Format format = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The version in the spec.
  // This maps to `info.version` in OpenAPI spec.
  string version = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Owner details for the spec.
  // This maps to `info.contact` in OpenAPI spec.
  Owner owner = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The operation details parsed from the spec.
message OperationDetails {
  oneof operation {
    // The HTTP Operation.
    HttpOperation http_operation = 4;
  }

  // Optional. Description of the operation behavior.
  // For OpenAPI spec, this will map to `operation.description` in the
  // spec, in case description is empty, `operation.summary` will be used.
  string description = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Additional external documentation for this operation.
  // For OpenAPI spec, this will map to `operation.documentation` in the spec.
  Documentation documentation = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. For OpenAPI spec, this will be set if `operation.deprecated`is
  // marked as `true` in the spec.
  bool deprecated = 3 [(google.api.field_behavior) = OPTIONAL];
}

// The HTTP Operation.
message HttpOperation {
  // Enumeration of Method types.
  enum Method {
    // Method unspecified.
    METHOD_UNSPECIFIED = 0;

    // Get Operation type.
    GET = 1;

    // Put Operation type.
    PUT = 2;

    // Post Operation type.
    POST = 3;

    // Delete Operation type.
    DELETE = 4;

    // Options Operation type.
    OPTIONS = 5;

    // Head Operation type.
    HEAD = 6;

    // Patch Operation type.
    PATCH = 7;

    // Trace Operation type.
    TRACE = 8;
  }

  // Optional. The path details for the Operation.
  // Note: Even though this field is optional, it is required for
  // [CreateApiOperation][google.cloud.apihub.v1.ApiHub.CreateApiOperation]
  // API and we will fail the request if not provided.
  Path path = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Operation method
  // Note: Even though this field is optional, it is required for
  // [CreateApiOperation][google.cloud.apihub.v1.ApiHub.CreateApiOperation]
  // API and we will fail the request if not provided.
  Method method = 2 [(google.api.field_behavior) = OPTIONAL];
}

// The path details derived from the spec.
message Path {
  // Optional. Complete path relative to server endpoint.
  // Note: Even though this field is optional, it is required for
  // [CreateApiOperation][google.cloud.apihub.v1.ApiHub.CreateApiOperation]
  // API and we will fail the request if not provided.
  string path = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A short description for the path applicable to all operations.
  string description = 2 [(google.api.field_behavior) = OPTIONAL];
}

// The schema details derived from the spec. Currently, this entity is supported
// for OpenAPI spec only.
// For OpenAPI spec, this maps to the schema defined in
// the  `definitions` section for OpenAPI 2.0 version and in
// `components.schemas` section for OpenAPI 3.0 and 3.1 version.
message Schema {
  // Output only. The display name of the schema.
  // This will map to the name of the schema in the spec.
  string display_name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The raw value of the schema definition corresponding to the
  // schema name in the spec.
  bytes raw_value = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Owner details.
message Owner {
  // Optional. The name of the owner.
  string display_name = 1 [(google.api.field_behavior) = OPTIONAL];

  // Required. The email of the owner.
  string email = 2 [(google.api.field_behavior) = REQUIRED];
}

// Documentation details.
message Documentation {
  // Optional. The uri of the externally hosted documentation.
  string external_uri = 1 [(google.api.field_behavior) = OPTIONAL];
}

// The attribute values associated with resource.
message AttributeValues {
  // The attribute values of data type enum.
  message EnumAttributeValues {
    // Required. The attribute values in case attribute data type is enum.
    repeated Attribute.AllowedValue values = 1
        [(google.api.field_behavior) = REQUIRED];
  }

  // The attribute values of data type string or JSON.
  message StringAttributeValues {
    // Required. The attribute values in case attribute data type is string or
    // JSON.
    repeated string values = 1 [(google.api.field_behavior) = REQUIRED];
  }

  // The attribute values associated with the resource.
  oneof Value {
    // The attribute values associated with a resource in case attribute data
    // type is enum.
    EnumAttributeValues enum_values = 2;

    // The attribute values associated with a resource in case attribute data
    // type is string.
    StringAttributeValues string_values = 3;

    // The attribute values associated with a resource in case attribute data
    // type is JSON.
    StringAttributeValues json_values = 4;

    // The attribute values associated with a resource in case attribute data
    // type is URL, URI or IP, like gs://bucket-name/object-name.
    StringAttributeValues uri_values = 5;
  }

  // Output only. The name of the attribute.
  // Format: projects/{project}/locations/{location}/attributes/{attribute}
  string attribute = 1 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "apihub.googleapis.com/Attribute"
    }
  ];
}

// A dependency resource defined in the API hub describes a dependency directed
// from a consumer to a supplier entity. A dependency can be defined between two
// [Operations][google.cloud.apihub.v1.ApiOperation] or between
// an [Operation][google.cloud.apihub.v1.ApiOperation] and [External
// API][google.cloud.apihub.v1.ExternalApi].
message Dependency {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/Dependency"
    pattern: "projects/{project}/locations/{location}/dependencies/{dependency}"
    plural: "dependencies"
    singular: "dependency"
  };

  // Possible states for a dependency.
  enum State {
    // Default value. This value is unused.
    STATE_UNSPECIFIED = 0;

    // Dependency will be in a proposed state when it is newly identified by the
    // API hub on its own.
    PROPOSED = 1;

    // Dependency will be in a validated state when it is validated by the
    // admin or manually created in the API hub.
    VALIDATED = 2;
  }

  // Possible modes of discovering the dependency.
  enum DiscoveryMode {
    // Default value. This value is unused.
    DISCOVERY_MODE_UNSPECIFIED = 0;

    // Manual mode of discovery when the dependency is defined by the user.
    MANUAL = 1;
  }

  // Identifier. The name of the dependency in the API Hub.
  //
  // Format: `projects/{project}/locations/{location}/dependencies/{dependency}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. Immutable. The entity acting as the consumer in the dependency.
  DependencyEntityReference consumer = 2 [
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.field_behavior) = REQUIRED
  ];

  // Required. Immutable. The entity acting as the supplier in the dependency.
  DependencyEntityReference supplier = 3 [
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.field_behavior) = REQUIRED
  ];

  // Output only. State of the dependency.
  State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Human readable description corresponding of the dependency.
  string description = 5 [(google.api.field_behavior) = OPTIONAL];

  // Output only. Discovery mode of the dependency.
  DiscoveryMode discovery_mode = 6 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Error details of a dependency if the system has detected it
  // internally.
  DependencyErrorDetail error_detail = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the dependency was created.
  google.protobuf.Timestamp create_time = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the dependency was last updated.
  google.protobuf.Timestamp update_time = 9
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The list of user defined attributes associated with the
  // dependency resource. The key is the attribute name. It will be of the
  // format: `projects/{project}/locations/{location}/attributes/{attribute}`.
  // The value is the attribute values associated with the resource.
  map<string, AttributeValues> attributes = 10
      [(google.api.field_behavior) = OPTIONAL];
}

// Reference to an entity participating in a dependency.
message DependencyEntityReference {
  // Required. Unique identifier for the participating entity.
  oneof identifier {
    // The resource name of an operation in the API Hub.
    //
    // Format:
    // `projects/{project}/locations/{location}/apis/{api}/versions/{version}/operations/{operation}`
    string operation_resource_name = 2;

    // The resource name of an external API in the API Hub.
    //
    // Format:
    // `projects/{project}/locations/{location}/externalApis/{external_api}`
    string external_api_resource_name = 3;
  }

  // Output only. Display name of the entity.
  string display_name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Details describing error condition of a dependency.
message DependencyErrorDetail {
  // Possible values representing an error in the dependency.
  enum Error {
    // Default value used for no error in the dependency.
    ERROR_UNSPECIFIED = 0;

    // Supplier entity has been deleted.
    SUPPLIER_NOT_FOUND = 1;

    // Supplier entity has been recreated.
    SUPPLIER_RECREATED = 2;
  }

  // Optional. Error in the dependency.
  Error error = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Timestamp at which the error was found.
  google.protobuf.Timestamp error_time = 2
      [(google.api.field_behavior) = OPTIONAL];
}

// LintResponse contains the response from the linter.
message LintResponse {
  // Count of issues with a given severity.
  message SummaryEntry {
    // Required. Severity of the issue.
    Severity severity = 1 [(google.api.field_behavior) = REQUIRED];

    // Required. Count of issues with the given severity.
    int32 count = 2 [(google.api.field_behavior) = REQUIRED];
  }

  // Optional. Array of issues found in the analyzed document.
  repeated Issue issues = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Summary of all issue types and counts for each severity level.
  repeated SummaryEntry summary = 2 [(google.api.field_behavior) = OPTIONAL];

  // Required. Lint state represents success or failure for linting.
  LintState state = 3 [(google.api.field_behavior) = REQUIRED];

  // Required. Name of the linting application.
  string source = 4 [(google.api.field_behavior) = REQUIRED];

  // Required. Name of the linter used.
  Linter linter = 5 [(google.api.field_behavior) = REQUIRED];

  // Required. Timestamp when the linting response was generated.
  google.protobuf.Timestamp create_time = 6
      [(google.api.field_behavior) = REQUIRED];
}

// Issue contains the details of a single issue found by the linter.
message Issue {
  // Required. Rule code unique to each rule defined in linter.
  string code = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. An array of strings indicating the location in the analyzed
  // document where the rule was triggered.
  repeated string path = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. Human-readable message describing the issue found by the linter.
  string message = 3 [(google.api.field_behavior) = REQUIRED];

  // Required. Severity level of the rule violation.
  Severity severity = 4 [(google.api.field_behavior) = REQUIRED];

  // Required. Object describing where in the file the issue was found.
  Range range = 5 [(google.api.field_behavior) = REQUIRED];
}

// Object describing where in the file the issue was found.
message Range {
  // Required. Start of the issue.
  Point start = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. End of the issue.
  Point end = 2 [(google.api.field_behavior) = REQUIRED];
}

// Point within the file (line and character).
message Point {
  // Required. Line number (zero-indexed).
  int32 line = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. Character position within the line (zero-indexed).
  int32 character = 2 [(google.api.field_behavior) = REQUIRED];
}

// Represents the metadata of the long-running operation.
message OperationMetadata {
  // Output only. The time the operation was created.
  google.protobuf.Timestamp create_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time the operation finished running.
  google.protobuf.Timestamp end_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Server-defined resource path for the target of the operation.
  string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Name of the verb executed by the operation.
  string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Human-readable status of the operation, if any.
  string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Identifies whether the user has requested cancellation
  // of the operation. Operations that have been cancelled successfully
  // have [Operation.error][google.longrunning.Operation.error] value with a
  // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to
  // `Code.CANCELLED`.
  bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. API version used to start the operation.
  string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// An ApiHubInstance represents the instance resources of the API Hub.
// Currently, only one ApiHub instance is allowed for each project.
message ApiHubInstance {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/ApiHubInstance"
    pattern: "projects/{project}/locations/{location}/apiHubInstances/{api_hub_instance}"
    plural: "apiHubInstances"
    singular: "apiHubInstance"
  };

  // Available configurations to provision an ApiHub Instance.
  message Config {
    // Types of data encryption.
    enum EncryptionType {
      // Encryption type unspecified.
      ENCRYPTION_TYPE_UNSPECIFIED = 0;

      // Default encryption using Google managed encryption key.
      GMEK = 1;

      // Encryption using customer managed encryption key.
      CMEK = 2;
    }

    // Optional. The Customer Managed Encryption Key (CMEK) used for data
    // encryption. The CMEK name should follow the format of
    // `projects/([^/]+)/locations/([^/]+)/keyRings/([^/]+)/cryptoKeys/([^/]+)`,
    // where the location must match the instance location.
    // If the CMEK is not provided, a GMEK will be created for the instance.
    string cmek_key_name = 1 [(google.api.field_behavior) = OPTIONAL];

    // Optional. If true, the search will be disabled for the instance. The
    // default value is false.
    bool disable_search = 2 [(google.api.field_behavior) = OPTIONAL];

    // Optional. The name of the Vertex AI location where the data store is
    // stored.
    string vertex_location = 3 [(google.api.field_behavior) = OPTIONAL];

    // Optional. Encryption type for the region. If the encryption type is CMEK,
    // the cmek_key_name must be provided. If no encryption type is provided,
    // GMEK will be used.
    EncryptionType encryption_type = 4 [(google.api.field_behavior) = OPTIONAL];
  }

  // State of the ApiHub Instance.
  enum State {
    // The default value. This value is used if the state is omitted.
    STATE_UNSPECIFIED = 0;

    // The ApiHub instance has not been initialized or has been deleted.
    INACTIVE = 1;

    // The ApiHub instance is being created.
    CREATING = 2;

    // The ApiHub instance has been created and is ready for use.
    ACTIVE = 3;

    // The ApiHub instance is being updated.
    UPDATING = 4;

    // The ApiHub instance is being deleted.
    DELETING = 5;

    // The ApiHub instance encountered an error during a state change.
    FAILED = 6;
  }

  // Identifier. Format:
  // `projects/{project}/locations/{location}/apiHubInstances/{apiHubInstance}`.
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Output only. Creation timestamp.
  google.protobuf.Timestamp create_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Last update timestamp.
  google.protobuf.Timestamp update_time = 3
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The current state of the ApiHub instance.
  State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Extra information about ApiHub instance state. Currently the
  // message would be populated when state is `FAILED`.
  string state_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Required. Config of the ApiHub instance.
  Config config = 6 [(google.api.field_behavior) = REQUIRED];

  // Optional. Instance labels to represent user-provided metadata.
  // Refer to cloud documentation on labels for more details.
  // https://cloud.google.com/compute/docs/labeling-resources
  map<string, string> labels = 7 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Description of the ApiHub instance.
  string description = 8 [(google.api.field_behavior) = OPTIONAL];
}

// An external API represents an API being provided by external sources. This
// can be used to model third-party APIs and can be used to define dependencies.
message ExternalApi {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/ExternalApi"
    pattern: "projects/{project}/locations/{location}/externalApis/{external_api}"
    plural: "externalApis"
    singular: "externalApi"
  };

  // Identifier. Format:
  // `projects/{project}/locations/{location}/externalApi/{externalApi}`.
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. Display name of the external API. Max length is 63 characters
  // (Unicode Code Points).
  string display_name = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. Description of the external API. Max length is 2000 characters
  // (Unicode Code Points).
  string description = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. List of endpoints on which this API is accessible.
  repeated string endpoints = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. List of paths served by this API.
  repeated string paths = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Documentation of the external API.
  Documentation documentation = 6 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The list of user defined attributes associated with the Version
  // resource. The key is the attribute name. It will be of the format:
  // `projects/{project}/locations/{location}/attributes/{attribute}`.
  // The value is the attribute values associated with the resource.
  map<string, AttributeValues> attributes = 7
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. Creation timestamp.
  google.protobuf.Timestamp create_time = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Last update timestamp.
  google.protobuf.Timestamp update_time = 9
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// ConfigValueOption represents an option for a config variable of type enum or
// multi select.
message ConfigValueOption {
  // Required. Id of the option.
  string id = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. Display name of the option.
  string display_name = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. Description of the option.
  string description = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Secret provides a reference to entries in Secret Manager.
message Secret {
  // Required. The resource name of the secret version in the format,
  // format as: `projects/*/secrets/*/versions/*`.
  string secret_version = 1 [(google.api.field_behavior) = REQUIRED];
}

// ConfigVariableTemplate represents a configuration variable template present
// in a Plugin Config.
message ConfigVariableTemplate {
  // ValueType indicates the data type of the value.
  enum ValueType {
    // Value type is not specified.
    VALUE_TYPE_UNSPECIFIED = 0;

    // Value type is string.
    STRING = 1;

    // Value type is integer.
    INT = 2;

    // Value type is boolean.
    BOOL = 3;

    // Value type is secret.
    SECRET = 4;

    // Value type is enum.
    ENUM = 5;

    // Value type is multi select.
    MULTI_SELECT = 6;

    // Value type is multi string.
    MULTI_STRING = 7;

    // Value type is multi int.
    MULTI_INT = 8;
  }

  // Required. ID of the config variable. Must be unique within the
  // configuration.
  string id = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. Type of the parameter: string, int, bool etc.
  ValueType value_type = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. Description.
  string description = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Regular expression in RE2 syntax used for validating the `value`
  // of a `ConfigVariable`.
  string validation_regex = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Flag represents that this `ConfigVariable` must be provided for a
  // PluginInstance.
  bool required = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Enum options. To be populated if `ValueType` is `ENUM`.
  repeated ConfigValueOption enum_options = 6
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Multi select options. To be populated if `ValueType` is
  // `MULTI_SELECT`.
  repeated ConfigValueOption multi_select_options = 7
      [(google.api.field_behavior) = OPTIONAL];
}

// ConfigVariable represents a additional configuration variable present in a
// PluginInstance Config or AuthConfig, based on a ConfigVariableTemplate.
message ConfigVariable {
  // The config variable value of data type multi select.
  message MultiSelectValues {
    // Optional. The config variable value of data type multi select.
    repeated ConfigValueOption values = 1
        [(google.api.field_behavior) = OPTIONAL];
  }

  // The config variable value of data type multi string.
  message MultiStringValues {
    // Optional. The config variable value of data type multi string.
    repeated string values = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // The config variable value of data type multi int.
  message MultiIntValues {
    // Optional. The config variable value of data type multi int.
    repeated int32 values = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // The values associated with the config variable.
  oneof value {
    // Optional. The config variable value in case of config variable of type
    // string.
    string string_value = 2 [(google.api.field_behavior) = OPTIONAL];

    // Optional. The config variable value in case of config variable of type
    // integer.
    int64 int_value = 3 [(google.api.field_behavior) = OPTIONAL];

    // Optional. The config variable value in case of config variable of type
    // boolean.
    bool bool_value = 4 [(google.api.field_behavior) = OPTIONAL];

    // Optional. The config variable value in case of config variable of type
    // secret.
    Secret secret_value = 5 [(google.api.field_behavior) = OPTIONAL];

    // Optional. The config variable value in case of config variable of type
    // enum.
    ConfigValueOption enum_value = 6 [(google.api.field_behavior) = OPTIONAL];

    // Optional. The config variable value in case of config variable of type
    // multi select.
    MultiSelectValues multi_select_values = 7
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. The config variable value in case of config variable of type
    // multi string.
    MultiStringValues multi_string_values = 8
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. The config variable value in case of config variable of type
    // multi integer.
    MultiIntValues multi_int_values = 9
        [(google.api.field_behavior) = OPTIONAL];
  }

  // Output only. Key will be the
  // [id][google.cloud.apihub.v1.ConfigVariableTemplate.id] to uniquely identify
  // the config variable.
  string key = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Config for Google service account authentication.
message GoogleServiceAccountConfig {
  // Required. The service account to be used for authenticating request.
  //
  // The `iam.serviceAccounts.getAccessToken` permission should be granted on
  // this service account to the impersonator service account.
  string service_account = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "iam.googleapis.com/ServiceAccount"
    }
  ];
}

// AuthConfig represents the authentication information.
message AuthConfig {
  // Parameters to support Username and Password Authentication.
  message UserPasswordConfig {
    // Required. Username.
    string username = 1 [(google.api.field_behavior) = REQUIRED];

    // Required. Secret version reference containing the password.
    // The `secretmanager.versions.access` permission should be
    // granted to the service account accessing the secret.
    Secret password = 2 [(google.api.field_behavior) = REQUIRED];
  }

  // Parameters to support Oauth 2.0 client credentials grant authentication.
  // See https://tools.ietf.org/html/rfc6749#section-1.3.4 for more details.
  message Oauth2ClientCredentialsConfig {
    // Required. The client identifier.
    string client_id = 1 [(google.api.field_behavior) = REQUIRED];

    // Required. Secret version reference containing the client secret.
    // The `secretmanager.versions.access` permission should be
    // granted to the service account accessing the secret.
    Secret client_secret = 2 [(google.api.field_behavior) = REQUIRED];
  }

  // Config for authentication with API key.
  message ApiKeyConfig {
    // Enum of location an HTTP element can be.
    enum HttpElementLocation {
      // HTTP element location not specified.
      HTTP_ELEMENT_LOCATION_UNSPECIFIED = 0;

      // Element is in the HTTP request query.
      QUERY = 1;

      // Element is in the HTTP request header.
      HEADER = 2;

      // Element is in the HTTP request path.
      PATH = 3;

      // Element is in the HTTP request body.
      BODY = 4;

      // Element is in the HTTP request cookie.
      COOKIE = 5;
    }

    // Required. The parameter name of the API key.
    // E.g. If the API request is "https://example.com/act?api_key=<API KEY>",
    // "api_key" would be the parameter name.
    string name = 1 [(google.api.field_behavior) = REQUIRED];

    // Required. The name of the SecretManager secret version resource storing
    // the API key. Format:
    // `projects/{project}/secrets/{secrete}/versions/{version}`. The
    // `secretmanager.versions.access` permission should be granted to the
    // service account accessing the secret.
    Secret api_key = 2 [(google.api.field_behavior) = REQUIRED];

    // Required. The location of the API key.
    // The default value is QUERY.
    HttpElementLocation http_element_location = 3
        [(google.api.field_behavior) = REQUIRED];
  }

  // Supported auth types.
  oneof config {
    // Google Service Account.
    GoogleServiceAccountConfig google_service_account_config = 2;

    // User Password.
    UserPasswordConfig user_password_config = 3;

    // Api Key Config.
    ApiKeyConfig api_key_config = 4;

    // Oauth2.0 Client Credentials.
    Oauth2ClientCredentialsConfig oauth2_client_credentials_config = 5;
  }

  // Required. The authentication type.
  AuthType auth_type = 1 [(google.api.field_behavior) = REQUIRED];
}

// SourceMetadata represents the metadata for a resource at the source.
message SourceMetadata {
  // PluginInstanceActionSource represents the plugin instance action source.
  message PluginInstanceActionSource {
    // Output only. The resource name of the source plugin instance.
    // Format is
    // `projects/{project}/locations/{location}/plugins/{plugin}/instances/{instance}`
    string plugin_instance = 1 [
      (google.api.field_behavior) = OUTPUT_ONLY,
      (google.api.resource_reference) = {
        type: "apihub.googleapis.com/PluginInstance"
      }
    ];

    // Output only. The id of the plugin instance action.
    string action_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  // The possible types of the source.
  enum SourceType {
    // Source type not specified.
    SOURCE_TYPE_UNSPECIFIED = 0;

    // Source type plugin.
    PLUGIN = 1;
  }

  // The source of the resource.
  oneof source {
    // Output only. The source of the resource is a plugin instance action.
    PluginInstanceActionSource plugin_instance_action_source = 1
        [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  // Output only. The type of the source.
  SourceType source_type = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The unique identifier of the resource at the source.
  string original_resource_id = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the resource was created at the source.
  google.protobuf.Timestamp original_resource_create_time = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the resource was last updated at the source.
  google.protobuf.Timestamp original_resource_update_time = 5
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Respresents an API Observation observed in one of the sources.
message DiscoveredApiObservation {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/DiscoveredApiObservation"
    pattern: "projects/{project}/locations/{location}/discoveredApiObservations/{discovered_api_observation}"
    plural: "discoveredApiObservations"
    singular: "discoveredApiObservation"
  };

  // DiscoveredApiObservation protocol style
  enum Style {
    // Unknown style
    STYLE_UNSPECIFIED = 0;

    // Style is Rest API
    REST = 1;

    // Style is Grpc API
    GRPC = 2;

    // Style is GraphQL API
    GRAPHQL = 3;
  }

  // The possible types of the source from which the observation was collected.
  enum SourceType {
    // Source type not specified.
    SOURCE_TYPE_UNSPECIFIED = 0;

    // GCP external load balancer.
    GCP_XLB = 1;

    // GCP internal load balancer.
    GCP_ILB = 2;
  }

  // Identifier. The name of the discovered API Observation.
  //
  // Format:
  // `projects/{project}/locations/{location}/discoveredApiObservations/{discovered_api_observation}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Optional. Style of ApiObservation
  Style style = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The IP address (IPv4 or IPv6) of the origin server that the
  // request was sent to. This field can include port information. Examples:
  // `"192.168.1.1"`, `"10.0.0.1:80"`, `"FE80::0202:B3FF:FE1E:8329"`.
  repeated string server_ips = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The hostname of requests processed for this Observation.
  string hostname = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Last event detected time stamp
  google.protobuf.Timestamp last_event_detected_time = 5
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The location of the observation source.
  repeated string source_locations = 6 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // Optional. The number of observed API Operations.
  int64 api_operation_count = 7 [(google.api.field_behavior) = OPTIONAL];

  // Optional. For an observation pushed from a gcp resource, this would be the
  // gcp project id.
  string origin = 8 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The type of the source from which the observation was collected.
  repeated SourceType source_types = 9 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The number of known API Operations.
  int64 known_operations_count = 10 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The number of unknown API Operations.
  int64 unknown_operations_count = 11
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Create time stamp of the observation in API Hub.
  google.protobuf.Timestamp create_time = 12
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Update time stamp of the observation in API Hub.
  google.protobuf.Timestamp update_time = 13
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The metadata of the source from which the observation was
  // collected.
  SourceMetadata source_metadata = 14
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// DiscoveredApiOperation represents an API Operation observed in one of the
// sources.
message DiscoveredApiOperation {
  option (google.api.resource) = {
    type: "apihub.googleapis.com/DiscoveredApiOperation"
    pattern: "projects/{project}/locations/{location}/discoveredApiObservations/{discovered_api_observation}/discoveredApiOperations/{discovered_api_operation}"
    plural: "discoveredApiOperations"
    singular: "discoveredApiOperation"
  };

  // MatchResult represents the result of matching a discovered API operation
  // with a catalog API operation.
  message MatchResult {
    // Output only. The name of the matched API Operation.
    //
    // Format:
    // `projects/{project}/locations/{location}/apis/{api}/versions/{version}/operations/{operation}`
    string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  // The classification of the discovered API operation.
  enum Classification {
    // Operation is not classified as known or unknown.
    CLASSIFICATION_UNSPECIFIED = 0;

    // Operation has a matched catalog operation.
    KNOWN = 1;

    // Operation does not have a matched catalog operation.
    UNKNOWN = 2;
  }

  // ApiOperation protocol style
  oneof operation {
    // Optional. An HTTP Operation.
    HttpOperationDetails http_operation = 2
        [(google.api.field_behavior) = OPTIONAL];
  }

  // Identifier. The name of the discovered API Operation.
  //
  // Format:
  // `projects/{project}/locations/{location}/discoveredApiObservations/{discovered_api_observation}/discoveredApiOperations/{discovered_api_operation}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Optional. First seen time stamp
  google.protobuf.Timestamp first_seen_time = 3
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Last seen time stamp
  google.protobuf.Timestamp last_seen_time = 4
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The number of occurrences of this API Operation.
  int64 count = 5 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The classification of the discovered API operation.
  Classification classification = 6 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The list of matched results for the discovered API operation.
  // This will be populated only if the classification is known. The current
  // usecase is for a single match. Keeping it repeated to support multiple
  // matches in future.
  repeated MatchResult match_results = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The metadata of the source from which the api operation was
  // collected.
  SourceMetadata source_metadata = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Create time stamp of the discovered API operation in API Hub.
  google.protobuf.Timestamp create_time = 9
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Update time stamp of the discovered API operation in API Hub.
  google.protobuf.Timestamp update_time = 10
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// An HTTP-based API Operation, sometimes called a "REST" Operation.
message HttpOperationDetails {
  // HTTP Path parameter.
  message PathParam {
    // Optional. Segment location in the path, 1-indexed
    int32 position = 1 [(google.api.field_behavior) = OPTIONAL];

    // Optional. Data type of path param
    DataType data_type = 2 [(google.api.field_behavior) = OPTIONAL];
  }

  // An aggregation of HTTP query parameter occurrences.
  message QueryParam {
    // Required. Name of query param
    string name = 1 [(google.api.field_behavior) = REQUIRED];

    // Optional. The number of occurrences of this query parameter across
    // transactions.
    int64 count = 2 [(google.api.field_behavior) = OPTIONAL];

    // Optional. Data type of path param
    DataType data_type = 3 [(google.api.field_behavior) = OPTIONAL];
  }

  // An aggregation of HTTP header occurrences.
  message Header {
    // Header name.
    string name = 1;

    // The number of occurrences of this Header across transactions.
    int64 count = 2;

    // Data type of header
    DataType data_type = 3;
  }

  // An aggregation of HTTP requests.
  message HttpRequest {
    // Optional. Unordered map from header name to header metadata
    map<string, Header> headers = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // An aggregation of HTTP responses.
  message HttpResponse {
    // Optional. Unordered map from header name to header metadata
    map<string, Header> headers = 1 [(google.api.field_behavior) = OPTIONAL];

    // Optional. Map of status code to observed count
    map<int32, int64> response_codes = 2
        [(google.api.field_behavior) = OPTIONAL];
  }

  // Type of data
  enum DataType {
    // Unspecified data type
    DATA_TYPE_UNSPECIFIED = 0;

    // Boolean data type
    BOOL = 1;

    // Integer data type
    INTEGER = 2;

    // Float data type
    FLOAT = 3;

    // String data type
    STRING = 4;

    // UUID data type
    UUID = 5;
  }

  // Required. An HTTP Operation.
  HttpOperation http_operation = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. Path params of HttpOperation
  repeated PathParam path_params = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Query params of HttpOperation
  map<string, QueryParam> query_params = 3
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Request metadata.
  HttpRequest request = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Response metadata.
  HttpResponse response = 5 [(google.api.field_behavior) = OPTIONAL];
}
