// 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.support.v2beta;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/support/v2beta/support_event_subscription.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";

option csharp_namespace = "Google.Cloud.Support.V2Beta";
option go_package = "cloud.google.com/go/support/apiv2beta/supportpb;supportpb";
option java_multiple_files = true;
option java_outer_classname = "SupportEventSubscriptionServiceProto";
option java_package = "com.google.cloud.support.v2beta";
option php_namespace = "Google\\Cloud\\Support\\V2beta";
option ruby_package = "Google::Cloud::Support::V2beta";

// Service for managing customer support event subscriptions.
service SupportEventSubscriptionService {
  option (google.api.default_host) = "cloudsupport.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Creates a support event subscription for an organization.
  rpc CreateSupportEventSubscription(CreateSupportEventSubscriptionRequest)
      returns (SupportEventSubscription) {
    option (google.api.http) = {
      post: "/v2beta/{parent=organizations/*}/supportEventSubscriptions"
      body: "support_event_subscription"
    };
    option (google.api.method_signature) = "parent,support_event_subscription";
  }

  // Gets a support event subscription.
  rpc GetSupportEventSubscription(GetSupportEventSubscriptionRequest)
      returns (SupportEventSubscription) {
    option (google.api.http) = {
      get: "/v2beta/{name=organizations/*/supportEventSubscriptions/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists support event subscriptions for an organization.
  rpc ListSupportEventSubscriptions(ListSupportEventSubscriptionsRequest)
      returns (ListSupportEventSubscriptionsResponse) {
    option (google.api.http) = {
      get: "/v2beta/{parent=organizations/*}/supportEventSubscriptions"
    };
    option (google.api.method_signature) = "parent";
  }

  // Updates a support event subscription.
  rpc UpdateSupportEventSubscription(UpdateSupportEventSubscriptionRequest)
      returns (SupportEventSubscription) {
    option (google.api.http) = {
      patch: "/v2beta/{support_event_subscription.name=organizations/*/supportEventSubscriptions/*}"
      body: "support_event_subscription"
    };
    option (google.api.method_signature) =
        "support_event_subscription,update_mask";
  }

  // Soft deletes a support event subscription.
  rpc DeleteSupportEventSubscription(DeleteSupportEventSubscriptionRequest)
      returns (SupportEventSubscription) {
    option (google.api.http) = {
      delete: "/v2beta/{name=organizations/*/supportEventSubscriptions/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Undeletes a support event subscription.
  rpc UndeleteSupportEventSubscription(UndeleteSupportEventSubscriptionRequest)
      returns (SupportEventSubscription) {
    option (google.api.http) = {
      post: "/v2beta/{name=organizations/*/supportEventSubscriptions/*}:undelete"
      body: "*"
    };
  }

  // Expunges a support event subscription.
  //
  // EXAMPLES:
  //
  // cURL:
  //
  // ```shell
  // support_event_subscription="organizations/123456789/supportEventSubscriptions/abcdef123456"
  // curl \
  //   --request POST \
  //   --header "Authorization: Bearer $(gcloud auth print-access-token)" \
  //   "https://cloudsupport.googleapis.com/v2beta/$support_event_subscription:expunge"
  // ```
  //
  // Python:
  //
  // ```python
  // import googleapiclient.discovery
  //
  // api_version = "v2beta"
  // supportApiService = googleapiclient.discovery.build(
  //     serviceName="cloudsupport",
  //     version=api_version,
  //     discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}",
  // )
  //
  // request = supportApiService.supportEventSubscriptions().expunge(
  //     name="organizations/123456789/supportEventSubscriptions/abcdef123456"
  // )
  // print(request.execute())
  // ```
  rpc ExpungeSupportEventSubscription(ExpungeSupportEventSubscriptionRequest)
      returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2beta/{name=organizations/*/supportEventSubscriptions/*}:expunge"
      body: "*"
    };
    option (google.api.method_signature) = "name";
  }
}

// Request message for CreateSupportEventSubscription.
message CreateSupportEventSubscriptionRequest {
  // Required. The parent resource name where the support event subscription
  // will be created. Format: organizations/{organization_id}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "cloudsupport.googleapis.com/SupportEventSubscription"
    }
  ];

  // Required. The Pub/Sub configuration to create.
  SupportEventSubscription support_event_subscription = 2
      [(google.api.field_behavior) = REQUIRED];
}

// Request message for GetSupportEventSubscription.
message GetSupportEventSubscriptionRequest {
  // Required. The name of the support event subscription to retrieve.
  // Format:
  // organizations/{organization_id}/supportEventSubscriptions/{subscription_id}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "cloudsupport.googleapis.com/SupportEventSubscription"
    }
  ];
}

// Request message for ListSupportEventSubscriptions.
message ListSupportEventSubscriptionsRequest {
  // Required. The fully qualified name of the Cloud resource to list support
  // event subscriptions under. Format: organizations/{organization_id}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "cloudsupport.googleapis.com/SupportEventSubscription"
    }
  ];

  // Optional. Filter expression based on AIP-160.
  // Supported fields:
  // - pub_sub_topic
  // - state
  //
  // Examples:
  // - `pub_sub_topic="projects/example-project/topics/example-topic"`
  // - `state=WORKING`
  // - `pub_sub_topic="projects/example-project/topics/example-topic" AND
  // state=WORKING`
  string filter = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Whether to show deleted subscriptions. By default, deleted
  // subscriptions are not returned.
  bool show_deleted = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The maximum number of support event subscriptions to return.
  int32 page_size = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A token identifying the page of results to return. If
  // unspecified, the first page is retrieved.
  //
  // When paginating, all other parameters provided to
  // `ListSupportEventSubscriptions` must match the call that provided the page
  // token.
  string page_token = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for ListSupportEventSubscriptions.
message ListSupportEventSubscriptionsResponse {
  // The support event subscriptions.
  repeated SupportEventSubscription support_event_subscriptions = 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;
}

// Request message for UpdateSupportEventSubscription.
message UpdateSupportEventSubscriptionRequest {
  // Required. The support event subscription to update.
  // The `name` field is used to identify the configuration to update.
  SupportEventSubscription support_event_subscription = 1
      [(google.api.field_behavior) = REQUIRED];

  // Optional. The list of fields to update. The only supported value is
  // pub_sub_topic.
  google.protobuf.FieldMask update_mask = 2
      [(google.api.field_behavior) = OPTIONAL];
}

// Request message for DeleteSupportEventSubscription.
message DeleteSupportEventSubscriptionRequest {
  // Required. The name of the support event subscription to delete.
  // Format:
  // organizations/{organization_id}/supportEventSubscriptions/{subscription_id}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "cloudsupport.googleapis.com/SupportEventSubscription"
    }
  ];
}

// Request message for UndeleteSupportEventSubscription.
message UndeleteSupportEventSubscriptionRequest {
  // Required. The name of the support event subscription to undelete.
  // Format:
  // organizations/{organization_id}/supportEventSubscriptions/{subscription_id}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "cloudsupport.googleapis.com/SupportEventSubscription"
    }
  ];
}

// Request message for ExpungeSupportEventSubscription.
message ExpungeSupportEventSubscriptionRequest {
  // Required. The name of the support event subscription to expunge.
  // Format:
  // organizations/{organization_id}/supportEventSubscriptions/{subscription_id}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "cloudsupport.googleapis.com/SupportEventSubscription"
    }
  ];
}
