// Copyright 2026 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.agentregistry.v1;

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

option csharp_namespace = "Google.Cloud.AgentRegistry.V1";
option go_package = "cloud.google.com/go/agentregistry/apiv1/agentregistrypb;agentregistrypb";
option java_multiple_files = true;
option java_outer_classname = "BindingProto";
option java_package = "com.google.cloud.agentregistry.v1";
option php_namespace = "Google\\Cloud\\AgentRegistry\\V1";
option ruby_package = "Google::Cloud::AgentRegistry::V1";

// Represents a user-defined Binding.
message Binding {
  option (google.api.resource) = {
    type: "agentregistry.googleapis.com/Binding"
    pattern: "projects/{project}/locations/{location}/bindings/{binding}"
    plural: "bindings"
    singular: "binding"
  };

  // The source of the Binding.
  message Source {
    // The type of the source, currently only supports Agents.
    // Potential future fields include 'tag', etc.
    oneof source_type {
      // The identifier of the source Agent.
      // Format:
      //
      // * `urn:agent:{publisher}:{namespace}:{name}`
      string identifier = 1;
    }
  }

  // The target of the Binding.
  message Target {
    // The type of the target, currently only supports an AgentRegistry
    // Resource.
    // Potential future fields include 'tag', etc.
    oneof target_type {
      // The identifier of the target Agent, MCP Server, or Endpoint.
      // Format:
      //
      // * `urn:agent:{publisher}:{namespace}:{name}`
      // * `urn:mcp:{publisher}:{namespace}:{name}`
      // * `urn:endpoint:{publisher}:{namespace}:{name}`
      string identifier = 1;
    }
  }

  // The AuthProvider of the Binding.
  message AuthProviderBinding {
    // Required. The resource name of the target AuthProvider.
    // Format:
    //
    // * `projects/{project}/locations/{location}/authProviders/{auth_provider}`
    string auth_provider = 1 [(google.api.field_behavior) = REQUIRED];

    // Optional. The list of OAuth2 scopes of the AuthProvider.
    repeated string scopes = 2 [(google.api.field_behavior) = OPTIONAL];

    // Optional. The continue URI of the AuthProvider.
    // The URI is used to reauthenticate the user and finalize the managed OAuth
    // flow.
    string continue_uri = 3 [(google.api.field_behavior) = OPTIONAL];
  }

  // The configuration for the Binding.
  oneof binding {
    // The binding for AuthProvider.
    AuthProviderBinding auth_provider_binding = 6;
  }

  // Required. Identifier. The resource name of the Binding.
  // Format: `projects/{project}/locations/{location}/bindings/{binding}`.
  string name = 1 [
    (google.api.field_behavior) = IDENTIFIER,
    (google.api.field_behavior) = REQUIRED
  ];

  // Optional. User-defined display name for the Binding.
  // Can have a maximum length of `63` characters.
  string display_name = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. User-defined description of a Binding.
  // Can have a maximum length of `2048` characters.
  string description = 3 [(google.api.field_behavior) = OPTIONAL];

  // Required. The target Agent of the Binding.
  Source source = 4 [(google.api.field_behavior) = REQUIRED];

  // Required. The target Agent Registry Resource of the Binding.
  Target target = 5 [(google.api.field_behavior) = REQUIRED];

  // Output only. Timestamp when this binding was created.
  google.protobuf.Timestamp create_time = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Timestamp when this binding was last updated.
  google.protobuf.Timestamp update_time = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];
}
