syntax = "proto3";
package akash.deployment.v1beta1;

import "gogoproto/gogo.proto";
import "akash/deployment/v1beta1/group.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/akash-network/akash-api/go/node/deployment/v1beta1";

// Msg defines the deployment Msg service.
service Msg {
  // CreateDeployment defines a method to create new deployment given proper inputs.
  rpc CreateDeployment(MsgCreateDeployment) returns (MsgCreateDeploymentResponse);

  // DepositDeployment deposits more funds into the deployment account
  rpc DepositDeployment(MsgDepositDeployment) returns (MsgDepositDeploymentResponse);

  // UpdateDeployment defines a method to update a deployment given proper inputs.
  rpc UpdateDeployment(MsgUpdateDeployment) returns (MsgUpdateDeploymentResponse);

  // CloseDeployment defines a method to close a deployment given proper inputs.
  rpc CloseDeployment(MsgCloseDeployment) returns (MsgCloseDeploymentResponse);

  // CloseGroup defines a method to close a group of a deployment given proper inputs.
  rpc CloseGroup(MsgCloseGroup) returns (MsgCloseGroupResponse);

  // PauseGroup defines a method to close a group of a deployment given proper inputs.
  rpc PauseGroup(MsgPauseGroup) returns (MsgPauseGroupResponse);

  // StartGroup defines a method to close a group of a deployment given proper inputs.
  rpc StartGroup(MsgStartGroup) returns (MsgStartGroupResponse);
}

// MsgCreateDeployment defines an SDK message for creating deployment
message MsgCreateDeployment {
  option (gogoproto.equal) = false;

  DeploymentID id = 1 [
    (gogoproto.nullable)   = false,
    (gogoproto.customname) = "ID",
    (gogoproto.jsontag)    = "id",
    (gogoproto.moretags)   = "yaml:\"id\""
  ];
  repeated GroupSpec groups = 2
      [(gogoproto.nullable) = false, (gogoproto.jsontag) = "groups", (gogoproto.moretags) = "yaml:\"groups\""];
  bytes version = 3 [(gogoproto.jsontag) = "version", (gogoproto.moretags) = "yaml:\"version\""];

  cosmos.base.v1beta1.Coin deposit = 4
      [(gogoproto.nullable) = false, (gogoproto.jsontag) = "deposit", (gogoproto.moretags) = "yaml:\"deposit\""];
}

// MsgCreateDeploymentResponse defines the Msg/CreateDeployment response type.
message MsgCreateDeploymentResponse {}

// MsgDepositDeployment deposits more funds into the deposit account
message MsgDepositDeployment {
  option (gogoproto.equal) = false;

  DeploymentID id = 1 [
    (gogoproto.nullable)   = false,
    (gogoproto.customname) = "ID",
    (gogoproto.jsontag)    = "id",
    (gogoproto.moretags)   = "yaml:\"id\""
  ];

  cosmos.base.v1beta1.Coin amount = 2
      [(gogoproto.nullable) = false, (gogoproto.jsontag) = "amount", (gogoproto.moretags) = "yaml:\"amount\""];
}

// MsgCreateDeploymentResponse defines the Msg/CreateDeployment response type.
message MsgDepositDeploymentResponse {}

// MsgUpdateDeployment defines an SDK message for updating deployment
message MsgUpdateDeployment {
  option (gogoproto.equal) = false;

  DeploymentID id = 1 [
    (gogoproto.nullable)   = false,
    (gogoproto.customname) = "ID",
    (gogoproto.jsontag)    = "id",
    (gogoproto.moretags)   = "yaml:\"id\""
  ];
  repeated GroupSpec groups = 2
      [(gogoproto.nullable) = false, (gogoproto.jsontag) = "groups", (gogoproto.moretags) = "yaml:\"groups\""];
  bytes version = 3 [(gogoproto.jsontag) = "version", (gogoproto.moretags) = "yaml:\"version\""];
}

// MsgUpdateDeploymentResponse defines the Msg/UpdateDeployment response type.
message MsgUpdateDeploymentResponse {}

// MsgCloseDeployment defines an SDK message for closing deployment
message MsgCloseDeployment {
  option (gogoproto.equal) = false;

  DeploymentID id = 1 [
    (gogoproto.nullable)   = false,
    (gogoproto.customname) = "ID",
    (gogoproto.jsontag)    = "id",
    (gogoproto.moretags)   = "yaml:\"id\""
  ];
}

// MsgCloseDeploymentResponse defines the Msg/CloseDeployment response type.
message MsgCloseDeploymentResponse {}

// DeploymentID stores owner and sequence number
message DeploymentID {
  option (gogoproto.equal)            = false;
  option (gogoproto.goproto_stringer) = false;

  string owner = 1 [(gogoproto.jsontag) = "owner", (gogoproto.moretags) = "yaml:\"owner\""];
  uint64 dseq  = 2
      [(gogoproto.customname) = "DSeq", (gogoproto.jsontag) = "dseq", (gogoproto.moretags) = "yaml:\"dseq\""];
}

// Deployment stores deploymentID, state and version details
message Deployment {
  option (gogoproto.equal) = false;

  DeploymentID deployment_id = 1 [
    (gogoproto.nullable)   = false,
    (gogoproto.customname) = "DeploymentID",
    (gogoproto.jsontag)    = "id",
    (gogoproto.moretags)   = "yaml:\"id\""
  ];

  // State is an enum which refers to state of deployment
  enum State {
    option (gogoproto.goproto_enum_prefix) = false;

    // Prefix should start with 0 in enum. So declaring dummy state
    invalid = 0 [(gogoproto.enumvalue_customname) = "DeploymentStateInvalid"];
    // DeploymentActive denotes state for deployment active
    active = 1 [(gogoproto.enumvalue_customname) = "DeploymentActive"];
    // DeploymentClosed denotes state for deployment closed
    closed = 2 [(gogoproto.enumvalue_customname) = "DeploymentClosed"];
  }

  State state   = 2 [(gogoproto.jsontag) = "state", (gogoproto.moretags) = "yaml:\"state\""];
  bytes version = 3 [(gogoproto.jsontag) = "version", (gogoproto.moretags) = "yaml:\"version\""];
  int64 created_at = 4;
}

// DeploymentFilters defines filters used to filter deployments
message DeploymentFilters {
  option (gogoproto.equal) = false;

  string owner = 1 [(gogoproto.jsontag) = "owner", (gogoproto.moretags) = "yaml:\"owner\""];
  uint64 dseq  = 2
      [(gogoproto.customname) = "DSeq", (gogoproto.jsontag) = "dseq", (gogoproto.moretags) = "yaml:\"dseq\""];
  string state = 3 [(gogoproto.jsontag) = "state", (gogoproto.moretags) = "yaml:\"state\""];
}
