syntax = "proto3";
package cosmos.circuit.v1;

option go_package = "cosmossdk.io/x/circuit/types";

import "cosmos/msg/v1/msg.proto";
import "cosmos/circuit/v1/types.proto";

// Msg defines the circuit Msg service.
service Msg {
  option (cosmos.msg.v1.service) = true;

  // AuthorizeCircuitBreaker allows a super-admin to grant (or revoke) another
  // account's circuit breaker permissions.
  rpc AuthorizeCircuitBreaker(MsgAuthorizeCircuitBreaker) returns (MsgAuthorizeCircuitBreakerResponse);

  // TripCircuitBreaker pauses processing of Msg's in the state machine.
  rpc TripCircuitBreaker(MsgTripCircuitBreaker) returns (MsgTripCircuitBreakerResponse);

  // ResetCircuitBreaker resumes processing of Msg's in the state machine that
  // have been been paused using TripCircuitBreaker.
  rpc ResetCircuitBreaker(MsgResetCircuitBreaker) returns (MsgResetCircuitBreakerResponse);
}

// MsgAuthorizeCircuitBreaker defines the Msg/AuthorizeCircuitBreaker request type.
message MsgAuthorizeCircuitBreaker {
  option (cosmos.msg.v1.signer) = "granter";

  // granter is the granter of the circuit breaker permissions and must have
  // LEVEL_SUPER_ADMIN.
  string granter = 1;

  // grantee is the account authorized with the provided permissions.
  string grantee = 2;

  // permissions are the circuit breaker permissions that the grantee receives.
  // These will overwrite any existing permissions. LEVEL_NONE_UNSPECIFIED can
  // be specified to revoke all permissions.
  Permissions permissions = 3;
}

// MsgAuthorizeCircuitBreakerResponse defines the Msg/AuthorizeCircuitBreaker response type.
message MsgAuthorizeCircuitBreakerResponse {
  bool success = 1;
}

// MsgTripCircuitBreaker defines the Msg/TripCircuitBreaker request type.
message MsgTripCircuitBreaker {
  option (cosmos.msg.v1.signer) = "authority";

  // authority is the account authorized to trip the circuit breaker.
  string authority = 1;

  // msg_type_urls specifies a list of type URLs to immediately stop processing.
  // IF IT IS LEFT EMPTY, ALL MSG PROCESSING WILL STOP IMMEDIATELY.
  // This value is validated against the authority's permissions and if the
  // authority does not have permissions to trip the specified msg type URLs
  // (or all URLs), the operation will fail.
  repeated string msg_type_urls = 2;
}

// MsgTripCircuitBreakerResponse defines the Msg/TripCircuitBreaker response type.
message MsgTripCircuitBreakerResponse {
  bool success = 1;
}

// MsgResetCircuitBreaker defines the Msg/ResetCircuitBreaker request type.
message MsgResetCircuitBreaker {
  option (cosmos.msg.v1.signer) = "authority";

  // authority is the account authorized to trip or reset the circuit breaker.
  string authority = 1;

  // msg_type_urls specifies a list of Msg type URLs to resume processing. If
  // it is left empty all Msg processing for type URLs that the account is
  // authorized to trip will resume.
  repeated string msg_type_urls = 3;
}

// MsgResetCircuitBreakerResponse defines the Msg/ResetCircuitBreaker response type.
message MsgResetCircuitBreakerResponse {
  bool success = 1;
}
