syntax = "proto3";

option csharp_namespace = "Proto.Billing.Pricing";

package plans;

import "google/protobuf/empty.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/wrappers.proto";

service PasswordManager {
  rpc GetPlanByLookupKey (GetPlanByLookupKeyRequest) returns (PlanResponse);
  rpc ListPlans (google.protobuf.Empty) returns (ListPlansResponse);
}

// Requests
message GetPlanByLookupKeyRequest {
  string lookupKey = 1;
}

// Responses
message PlanResponse {
  string name = 1;
  string lookupKey = 2;
  string tier = 4;
  optional string cadence = 6;
  optional google.protobuf.Int32Value legacyYear = 8;
  bool available = 9;
  repeated FeatureDTO features = 10;
  PurchasableDTO seats = 11;
  optional ScalableDTO managedSeats = 12;
  optional ScalableDTO storage = 13;
  optional SecretsManagerPurchasablesDTO secretsManager = 14;
  optional google.protobuf.Int32Value trialPeriodDays = 15;
  repeated string canUpgradeTo = 16;
  map<string, string> additionalData = 17;
}

message ListPlansResponse {
  repeated PlanResponse plans = 1;
}

// DTOs
message FeatureDTO {
  string name = 1;
  string lookupKey = 2;
}

message FreeDTO {
  int32 quantity = 2;
  string type = 4;
}

message PackagedDTO {
  message AdditionalSeats {
    string stripePriceId = 1;
    string price = 2;
  }

  int32 quantity = 2;
  string stripePriceId = 3;
  string price = 4;
  optional AdditionalSeats additional = 5;
  string type = 6;
}

message ScalableDTO {
  int32 provided = 2;
  string stripePriceId = 6;
  string price = 7;
  string type = 9;
}

message PurchasableDTO {
  oneof kind {
    FreeDTO free = 1;
    PackagedDTO packaged = 2;
    ScalableDTO scalable = 3;
  }
}

message FreeOrScalableDTO {
  oneof kind {
    FreeDTO free = 1;
    ScalableDTO scalable = 2;
  }
}

message SecretsManagerPurchasablesDTO {
  FreeOrScalableDTO seats = 1;
  FreeOrScalableDTO serviceAccounts = 2;
}
