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

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

option csharp_namespace = "Google.Cloud.OracleDatabase.V1";
option go_package = "cloud.google.com/go/oracledatabase/apiv1/oracledatabasepb;oracledatabasepb";
option java_multiple_files = true;
option java_outer_classname = "GoldengateConnectionAssignmentProto";
option java_package = "com.google.cloud.oracledatabase.v1";
option php_namespace = "Google\\Cloud\\OracleDatabase\\V1";
option ruby_package = "Google::Cloud::OracleDatabase::V1";

// Represents the metadata of a Goldengate Connection Assignment.
message GoldengateConnectionAssignment {
  option (google.api.resource) = {
    type: "oracledatabase.googleapis.com/GoldengateConnectionAssignment"
    pattern: "projects/{project}/locations/{location}/goldengateConnectionAssignments/{goldengate_connection_assignment}"
    plural: "goldengateConnectionAssignments"
    singular: "goldengateConnectionAssignment"
  };

  // Identifier. The name of the GoldengateConnectionAssignment resource in the
  // following format:
  // projects/{project}/locations/{region}/goldengateConnectionAssignments/{goldengate_connection_assignment}
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. The properties of the GoldengateConnectionAssignment.
  GoldengateConnectionAssignmentProperties properties = 2
      [(google.api.field_behavior) = REQUIRED];

  // Output only. The time when the connection assignment was created.
  google.protobuf.Timestamp create_time = 3
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The labels or tags associated with the
  // GoldengateConnectionAssignment.
  map<string, string> labels = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The display name for the GoldengateConnectionAssignment.
  string display_name = 5 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The OCID of the entitlement linked to this resource.
  string entitlement_id = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The properties of a GoldengateConnectionAssignment.
message GoldengateConnectionAssignmentProperties {
  // Possible lifecycle states for connection assignments.
  enum State {
    // Lifecycle state is unspecified.
    STATE_UNSPECIFIED = 0;

    // Connection assignment is being created.
    CREATING = 1;

    // Connection assignment is active.
    ACTIVE = 2;

    // Connection assignment failed.
    FAILED = 3;

    // Connection assignment is being updated.
    UPDATING = 4;

    // Connection assignment is being deleted.
    DELETING = 5;
  }

  // Output only. The
  // [OCID](https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm)
  // of the connection assignment being referenced.
  string ocid = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Required. The GoldengateConnection resource to be assigned.
  // Format:
  // projects/{project}/locations/{location}/goldengateConnections/{goldengate_connection}
  string goldengate_connection = 2 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/GoldengateConnection"
    }
  ];

  // Required. The GoldenGateDeployment to assign the connection to.
  // Format:
  // projects/{project}/locations/{location}/goldengateDeployments/{goldengate_deployment}
  string goldengate_deployment = 3 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/GoldengateDeployment"
    }
  ];

  // Output only. Credential store alias.
  string alias = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The lifecycle state of the connection assignment.
  State state = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Request message for listing GoldengateConnectionAssignments.
message ListGoldengateConnectionAssignmentsRequest {
  // Required. The parent value for the GoldengateConnectionAssignments.
  // Format: projects/{project}/locations/{location}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "oracledatabase.googleapis.com/GoldengateConnectionAssignment"
    }
  ];

  // Optional. The maximum number of GoldengateConnectionAssignments to return.
  // The service may return fewer than this value. If unspecified, at most 50
  // GoldengateConnectionAssignments will be returned. The maximum value is
  // 1000; values above 1000 will be coerced to 1000.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A page token, received from a previous
  // `ListGoldengateConnectionAssignments` call. Provide this to retrieve the
  // subsequent page.
  //
  // When paginating, all other parameters provided to
  // `ListGoldengateConnectionAssignments` must match the call that provided
  // the page token.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A filter expression that filters GoldengateConnectionAssignments
  // listed in the response.
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A comma-separated list of fields to order by, sorted in ascending
  // order. Use "DESC" after a field name for descending.
  string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for listing GoldengateConnectionAssignments.
message ListGoldengateConnectionAssignmentsResponse {
  // The list of GoldengateConnectionAssignments.
  repeated GoldengateConnectionAssignment goldengate_connection_assignments = 1;

  // A token, which can be sent as `page_token` to retrieve the next page.
  // If this field is omitted, there are no subsequent pages.
  string next_page_token = 2;

  // Unreachable locations when listing resources across all locations using
  // wildcard location '-'.
  repeated string unreachable = 3;
}

// Request message for getting a GoldengateConnectionAssignment.
message GetGoldengateConnectionAssignmentRequest {
  // Required. The name of the GoldengateConnectionAssignment to retrieve.
  // Format:
  // projects/{project}/locations/{location}/goldengateConnectionAssignments/{goldengate_connection_assignment}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/GoldengateConnectionAssignment"
    }
  ];
}

// Request message for creating a GoldengateConnectionAssignment.
message CreateGoldengateConnectionAssignmentRequest {
  // Required. The parent resource where this GoldengateConnectionAssignment
  // will be created. Format: projects/{project}/locations/{location}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "oracledatabase.googleapis.com/GoldengateConnectionAssignment"
    }
  ];

  // Required. The ID of the GoldengateConnectionAssignment to create.
  string goldengate_connection_assignment_id = 2
      [(google.api.field_behavior) = REQUIRED];

  // Required. The GoldengateConnectionAssignment to create.
  GoldengateConnectionAssignment goldengate_connection_assignment = 3
      [(google.api.field_behavior) = REQUIRED];

  // Optional. An optional request ID to identify requests. Specify a unique
  // request ID so that if you must retry your request, the server will know to
  // ignore the request if it has already been completed. The server will
  // guarantee that for at least 60 minutes since the first request.
  //
  // For example, consider a situation where you make an initial request and the
  // request times out. If you make the request again with the same request
  // ID, the server can check if original operation with the same request ID
  // was received, and if so, will ignore the second request. This prevents
  // clients from accidentally creating duplicate commitments.
  //
  // The request ID must be a valid UUID with the exception that zero UUID is
  // not supported (00000000-0000-0000-0000-000000000000).
  string request_id = 4 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OPTIONAL
  ];
}

// Request message for TestGoldengateConnectionAssignment.
message TestGoldengateConnectionAssignmentRequest {
  // The type of test to perform.
  enum TestType {
    // The default value. This value is unused.
    TEST_TYPE_UNSPECIFIED = 0;

    // The default connection test.
    DEFAULT = 1;
  }

  // Required. Name of the connection assignment for which to test connection.
  // projects/{project}/locations/{region}/goldengateConnectionAssignments/{goldengate_connection_assignment}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/GoldengateConnectionAssignment"
    }
  ];

  // Optional. The type of the test of the assigned connection.
  // The only type actually supported is DEFAULT.
  TestType type = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Error details for TestGoldengateConnectionAssignment.
message TestConnectionAssignmentError {
  // A short error code that defines the error, meant for programmatic parsing.
  string code = 1;

  // A human-readable error message.
  string message = 2;

  // The text describing the action required to fix the issue.
  string action = 3;

  // The text describing the root cause of the reported issue.
  string issue = 4;
}

// The result of the connectivity test performed between the Goldengate
// deployment and the associated database / service.
message TestGoldengateConnectionAssignmentResponse {
  // Type of the result.
  enum ResultType {
    // Result type is unspecified.
    RESULT_TYPE_UNSPECIFIED = 0;

    // Test connection succeeded.
    SUCCEEDED = 1;

    // Test connection failed.
    FAILED = 2;

    // Test connection timed out.
    TIMED_OUT = 3;
  }

  // Type of the result i.e. Success, Failure or Timeout.
  ResultType result_type = 1;

  // Error details if test connection failed.
  TestConnectionAssignmentError error = 2;

  // List of test connection assignment error objects.
  repeated TestConnectionAssignmentError errors = 3;
}

// Request message for deleting a GoldengateConnectionAssignment.
message DeleteGoldengateConnectionAssignmentRequest {
  // Required. The name of the GoldengateConnectionAssignment to delete.
  // Format:
  // projects/{project}/locations/{location}/goldengateConnectionAssignments/{goldengate_connection_assignment}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/GoldengateConnectionAssignment"
    }
  ];

  // Optional. An optional request ID to identify requests. Specify a unique
  // request ID so that if you must retry your request, the server will know to
  // ignore the request if it has already been completed. The server will
  // guarantee that for at least 60 minutes after the first request.
  //
  // For example, consider a situation where you make an initial request and the
  // request times out. If you make the request again with the same request
  // ID, the server can check if original operation with the same request ID
  // was received, and if so, will ignore the second request. This prevents
  // clients from accidentally creating duplicate commitments.
  //
  // The request ID must be a valid UUID with the exception that zero UUID is
  // not supported (00000000-0000-0000-0000-000000000000).
  string request_id = 2 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OPTIONAL
  ];
}
