syntax = "proto3";

package controller.api.services.v1;

option go_package = "github.com/hashicorp/boundary/internal/gen/controller/api/services;services";

import "protoc-gen-openapiv2/options/annotations.proto";
import "google/api/annotations.proto";
import "google/protobuf/field_mask.proto";
import "controller/api/resources/authmethods/v1/auth_method.proto";

service AuthMethodService {
  // GetAuthMethod returns a stored Auth Method if present.  The provided request
  // must include the Auth Method id. If missing, malformed or referencing a
   // non existing resource an error is returned.
  rpc GetAuthMethod(GetAuthMethodRequest) returns (GetAuthMethodResponse) {
    option (google.api.http) = {
      get: "/v1/auth-methods/{id}"
      response_body: "item"
    };
    option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
      summary: "Gets a single Auth Method."
    };
  }

  // ListAuthMethods returns a list of stored Auth Methods which are in the
  // provided scope. The request must include the scope id and if missing,
  // malformed, or referencing a non existing scope, an error is returned.
  rpc ListAuthMethods(ListAuthMethodsRequest) returns (ListAuthMethodsResponse) {
    option (google.api.http) = {
      get: "/v1/auth-methods"
    };
    option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
      summary: "Lists all Auth Methods."
    };
  }

  // CreateAuthMethod creates and stores an Auth Method in boundary.  The
  // provided request must include the scope in which the Auth Method will be
  // created. If the scope id is missing, malformed or referencing a
  // non existing resource an error is returned.  If a name is provided that is
  // in use in another Auth Method in the same scope, an error is returned.
  rpc CreateAuthMethod(CreateAuthMethodRequest) returns (CreateAuthMethodResponse) {
    option (google.api.http) = {
      post: "/v1/auth-methods"
      body: "item"
      response_body: "item"
    };
    option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
      summary: "Creates a single Auth Method."
    };
  }

  // UpdateAuthMethod updates an existing Auth Method in boundary.  The provided
  // Auth Method must not have any read only fields set.  The update mask must be
  // included in the request and contain at least 1 mutable field.  To unset
  // a field's value, include the field in the update mask and don't set it
  // in the provided user. An error is returned if the Auth Method id is missing
  // or reference a non existing resource.  An error is also returned if the
  // request attempts to update the name to one that is already in use by
  // another Auth Method in the parent scope.
  rpc UpdateAuthMethod(UpdateAuthMethodRequest) returns (UpdateAuthMethodResponse) {
    option (google.api.http) = {
      patch: "/v1/auth-methods/{id}"
      body: "item"
      response_body: "item"
    };
    option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
      summary: "Updates an Auth Method."
    };
  }

  // DeleteAuthMethod removes an Auth Method from Boundary. If the Auth Method id
  // is malformed or not provided an error is returned.
  rpc DeleteAuthMethod(DeleteAuthMethodRequest) returns (DeleteAuthMethodResponse) {
    option (google.api.http) = {
      delete: "/v1/auth-methods/{id}"
    };
    option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
      summary: "Deletes an AuthMethod"
    };
  }
}

message GetAuthMethodRequest {
  string id = 1;
}

message GetAuthMethodResponse {
  resources.authmethods.v1.AuthMethod item = 1;
}

message ListAuthMethodsRequest {
  string scope_id = 1 [json_name="scope_id"];
}

message ListAuthMethodsResponse {
  repeated resources.authmethods.v1.AuthMethod items = 1;
}

message CreateAuthMethodRequest {
  resources.authmethods.v1.AuthMethod item = 1;
}

message CreateAuthMethodResponse {
  string uri = 1;
  resources.authmethods.v1.AuthMethod item = 2;
}

message UpdateAuthMethodRequest {
  string id = 1;
  resources.authmethods.v1.AuthMethod item = 2;
  google.protobuf.FieldMask update_mask = 3 [json_name="update_mask"];
}

message UpdateAuthMethodResponse {
  resources.authmethods.v1.AuthMethod item = 1;
}

message DeleteAuthMethodRequest {
  string id = 1;
}

message DeleteAuthMethodResponse {}
