syntax = "proto3";

package yandex.cloud.iam.v1.awscompatibility;

import "google/api/annotations.proto";
import "google/protobuf/field_mask.proto";
import "yandex/cloud/api/operation.proto";
import "yandex/cloud/iam/v1/awscompatibility/access_key.proto";
import "yandex/cloud/operation/operation.proto";
import "yandex/cloud/validation.proto";

option go_package = "github.com/yandex-cloud/go-genproto/yandex/cloud/iam/v1/awscompatibility;awscompatibility";
option java_package = "yandex.cloud.api.iam.v1.awscompatibility";

// A set of methods for managing access keys.
service AccessKeyService {
  // Retrieves the list of access keys for the specified service account.
  rpc List (ListAccessKeysRequest) returns (ListAccessKeysResponse) {
    option (google.api.http) = { get: "/iam/aws-compatibility/v1/accessKeys" };
  }

  // Returns the specified access key.
  //
  // To get the list of available access keys, make a [List] request.
  rpc Get (GetAccessKeyRequest) returns (AccessKey) {
    option (google.api.http) = { get: "/iam/aws-compatibility/v1/accessKeys/{access_key_id}" };
  }

  // Creates an access key for the specified service account.
  rpc Create (CreateAccessKeyRequest) returns (CreateAccessKeyResponse) {
    option (google.api.http) = { post: "/iam/aws-compatibility/v1/accessKeys" body: "*" };
  }

  // Updates the specified access key.
  rpc Update (UpdateAccessKeyRequest) returns (operation.Operation) {
    option (google.api.http) = { patch: "/iam/aws-compatibility/v1/accessKeys/{access_key_id}" body: "*" };
    option (yandex.cloud.api.operation) = {
      metadata: "UpdateAccessKeyMetadata"
      response: "AccessKey"
    };
  }

  // Deletes the specified access key.
  rpc Delete (DeleteAccessKeyRequest) returns (operation.Operation) {
    option (google.api.http) = { delete: "/iam/aws-compatibility/v1/accessKeys/{access_key_id}" };
    option (yandex.cloud.api.operation) = {
      metadata: "DeleteAccessKeyMetadata"
      response: "google.protobuf.Empty"
    };
  }

  // Retrieves the list of operations for the specified access key.
  rpc ListOperations (ListAccessKeyOperationsRequest) returns (ListAccessKeyOperationsResponse) {
    option (google.api.http) = { get: "/iam/aws-compatibility/v1/accessKeys/{access_key_id}/operations" };
  }
}

message GetAccessKeyRequest {
  // ID of the AccessKey resource to return.
  // To get the access key ID, use a [AccessKeyService.List] request.
  string access_key_id = 1 [(required) = true, (length) = "<=50"];
}

message ListAccessKeysRequest {
  // ID of the service account to list access keys for.
  // To get the service account ID, use a [yandex.cloud.iam.v1.ServiceAccountService.List] request.
  // If not specified, it defaults to the subject that made the request.
  string service_account_id = 1 [(length) = "<=50"]; // use current subject identity if this not set

  // The maximum number of results per page to return. If the number of available
  // results is larger than [page_size],
  // the service returns a [ListAccessKeysResponse.next_page_token]
  // that can be used to get the next page of results in subsequent list requests.
  // Default value: 100.
  int64 page_size = 2 [(value) = "<=1000"];

  // Page token. To get the next page of results, set [page_token]
  // to the [ListAccessKeysResponse.next_page_token]
  // returned by a previous list request.
  string page_token = 3 [(length) = "<=100"];
}

message ListAccessKeysResponse {
  // List of access keys.
  repeated AccessKey access_keys = 1;

  // This token allows you to get the next page of results for list requests. If the number of results
  // is larger than [ListAccessKeysRequest.page_size], use
  // the [next_page_token] as the value
  // for the [ListAccessKeysRequest.page_token] query parameter
  // in the next list request. Each subsequent list request will have its own
  // [next_page_token] to continue paging through the results.
  string next_page_token = 2;
}

message CreateAccessKeyRequest {
  // ID of the service account to create an access key for.
  // To get the service account ID, use a [yandex.cloud.iam.v1.ServiceAccountService.List] request.
  // If not specified, it defaults to the subject that made the request.
  string service_account_id = 1 [(length) = "<=50"]; // use current subject identity if this not set

  // Description of the access key.
  string description = 2 [(length) = "<=256"];
}

message CreateAccessKeyResponse {
  // AccessKey resource.
  AccessKey access_key = 1;

  // Secret access key.
  // The key is AWS compatible.
  string secret = 2;
}

message UpdateAccessKeyRequest {
  // ID of the AccessKey resource to update.
  // To get the access key ID, use a [AccessKeyService.List] request.
  string access_key_id = 1 [(required) = true, (length) = "<=50"];

  // Field mask that specifies which fields of the Accesskey resource are going to be updated.
  google.protobuf.FieldMask update_mask = 2;

  // Description of the access key.
  string description = 3 [(length) = "<=256"];
}

message UpdateAccessKeyMetadata {
  // ID of the AccessKey resource that is being updated.
  string access_key_id = 1;
}

message DeleteAccessKeyRequest {
  // ID of the access key to delete.
  // To get the access key ID, use a [AccessKeyService.List] request.
  string access_key_id = 1 [(required) = true, (length) = "<=50"];
}

message DeleteAccessKeyMetadata {
  // ID of the access key that is being deleted.
  string access_key_id = 1;
}

message ListAccessKeyOperationsRequest {
  // ID of the key to list operations for.
  string access_key_id = 1 [(required) = true, (length) = "<=50"];

  // The maximum number of results per page to return. If the number of available
  // results is larger than [page_size],
  // the service returns a [ListAccessKeyOperationsResponse.next_page_token]
  // that can be used to get the next page of results in subsequent list requests.
  // Default value: 100.
  int64 page_size = 2 [(value) = "0-1000"];

  // Page token. To get the next page of results, set [page_token] to the
  // [ListAccessKeyOperationsResponse.next_page_token] returned by a previous list request.
  string page_token = 3 [(length) = "<=100"];
}

message ListAccessKeyOperationsResponse {
  // List of operations for the specified access key.
  repeated operation.Operation operations = 1;

  // This token allows you to get the next page of results for list requests. If the number of results
  // is larger than [ListAccessKeyOperationsRequest.page_size], use the [next_page_token] as the value
  // for the [ListAccessKeyOperationsRequest.page_token] query parameter in the next list request.
  // Each subsequent list request will have its own [next_page_token] to continue paging through the results.
  string next_page_token = 2;
}
