require "kubernetes"

module ContainerMom
  struct Source
    include Kubernetes::Serializable

    field type : String
    field url : String
    field credentials : Credentials?
  end

  struct Credentials
    include Kubernetes::Serializable

    field username : String?
    field password : String?
  end

  struct Resources
    include Kubernetes::Serializable

    field cpu : String
    field memory : String
    field storage : String?
  end

  struct Domain
    include Kubernetes::Serializable

    field custom : String?
    field container_mom_subdomain : String?
  end

  struct Billing
    include Kubernetes::Serializable

    field customer_id : String
    field plan : String
  end

  struct ContainerDeploymentSpec
    include Kubernetes::Serializable

    field name : String
    field source : Source
    field resources : Resources
    field regions : Array(String)
    field domain : Domain?
    field billing : Billing
  end

  struct ContainerDeploymentStatus
    include Kubernetes::Serializable

    field phase : String
    field conditions : Array(Condition)
    field endpoints : Array(Endpoint)?
  end

  struct Condition
    include Kubernetes::Serializable

    field type : String
    field status : String
    field last_transition_time : Time
    field reason : String
    field message : String
  end

  struct Endpoint
    include Kubernetes::Serializable

    field url : String
    field type : String
    field region : String
  end
end

module Kubernetes
  # Define our custom resource
  define_resource "containerdeployments",
    group: "app.container.mom",
    type: Resource(ContainerMom::ContainerDeploymentSpec),
    kind: "ContainerDeployment",
    version: "v1alpha1",
    prefix: "apis",
    singular_name: "containerdeployment"
end
