From fafe6557e884fca4f3b6556ec959b5e71956b6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Kutryj?= Date: Tue, 18 Nov 2025 13:48:38 +0100 Subject: [PATCH] feat(plumber): retention policy worker --- plumber/AGENTS.md | 20 + plumber/block/AGENTS.md | 19 + plumber/ppl/AGENTS.md | 22 + plumber/ppl/config/config.exs | 5 + plumber/ppl/config/test.exs | 4 + plumber/ppl/lib/ppl/application.ex | 1 + .../ppl/ppl_requests/model/ppl_requests.ex | 1 + .../ppl/lib/ppl/retention/policy_applier.ex | 29 ++ .../ppl/lib/ppl/retention/policy_consumer.ex | 55 ++ ...00_add_expires_at_to_pipeline_requests.exs | 11 + plumber/proto/Makefile | 1 + .../proto/lib/internal_api/artifacthub.pb.ex | 16 +- plumber/proto/lib/internal_api/build.pb.ex | 481 ------------------ plumber/proto/lib/internal_api/gofer.dt.pb.ex | 15 +- .../proto/lib/internal_api/organization.pb.ex | 12 +- .../internal_api/plumber_w_f.workflow.pb.ex | 467 ++++++++--------- .../proto/lib/internal_api/projecthub.pb.ex | 24 +- .../proto/lib/internal_api/repository.pb.ex | 4 +- .../internal_api/repository_integrator.pb.ex | 7 +- plumber/proto/lib/internal_api/task.pb.ex | 11 +- plumber/proto/lib/internal_api/usage.pb.ex | 358 +++++++++++++ 21 files changed, 833 insertions(+), 730 deletions(-) create mode 100644 plumber/AGENTS.md create mode 100644 plumber/block/AGENTS.md create mode 100644 plumber/ppl/AGENTS.md create mode 100644 plumber/ppl/lib/ppl/retention/policy_applier.ex create mode 100644 plumber/ppl/lib/ppl/retention/policy_consumer.ex create mode 100644 plumber/ppl/priv/ecto_repo/migrations/20250224121500_add_expires_at_to_pipeline_requests.exs delete mode 100644 plumber/proto/lib/internal_api/build.pb.ex create mode 100644 plumber/proto/lib/internal_api/usage.pb.ex diff --git a/plumber/AGENTS.md b/plumber/AGENTS.md new file mode 100644 index 000000000..e64993804 --- /dev/null +++ b/plumber/AGENTS.md @@ -0,0 +1,20 @@ +# Plumber Repository Guidelines + +## Layout +- `ppl/` hosts the pipeline orchestrator (Elixir/OTP application) together with its GRPC endpoints and database migrations. +- `block/` implements block/task execution logic and is started as a sibling OTP app inside the same release. +- `proto/`, `spec/`, and other top-level folders expose shared protobuf contracts, YAML schemas, and helper libraries. + +## Build & Test +- Run `mix deps.get` inside both `ppl/` and `block/` after cloning; each app keeps its own `mix.lock`. +- Use the provided `Makefile` targets (e.g., `make unit-test`) to spin up Postgres/RabbitMQ containers and execute the umbrella test suites. +- Database migrations live under `ppl/priv/ecto_repo/migrations` and `block/priv/ecto_repo/migrations`; run them with `mix ecto.migrate -r `. +- All new code must pass `mix credo --strict`, `mix format`, and the relevant `mix test` suites before submitting. + +## Development Notes +- Services rely on RabbitMQ (`RABBITMQ_URL`) for event streams; keep it running locally when exercising background workers (e.g., the retention policy consumer). +- Watchman (StatsD) is the default metrics sink; configure `METRICS_HOST`/`METRICS_PORT` for local debugging if needed. + +## Documentation +- Service-specific guidance lives under `ppl/AGENTS.md` and `block/AGENTS.md`. +- Architectural notes, including retention policies, are documented in `docs/` (see `docs/pipeline_retention.md` for the event-driven marking flow). diff --git a/plumber/block/AGENTS.md b/plumber/block/AGENTS.md new file mode 100644 index 000000000..d33bfc2ba --- /dev/null +++ b/plumber/block/AGENTS.md @@ -0,0 +1,19 @@ +# Block Service Guidelines + +## Project Layout +- `lib/block/` contains block request processing, task orchestration, and API clients. +- `priv/ecto_repo/migrations/` stores migrations for `Block.EctoRepo`. +- `config/` defines repo settings, looper timings, and runtime overrides. +- Tests live under `test/`; shared helpers reside in `test/support`. + +## Setup & Commands +- Install deps: `mix deps.get`. +- Migrate DB: `mix ecto.migrate -r Block.EctoRepo`. +- Run unit tests: `mix test` (requires Postgres running; use the root Makefile to spin up containers). +- Format/lint: `mix format`, `mix credo --strict`. + +## Integration Notes +- Block is started as part of the Plumber release; ensure both repos (`Ppl.EctoRepo` and `Block.EctoRepo`) are migrated. +- RabbitMQ (`RABBITMQ_URL`) is required for task lifecycle events; keep it reachable during development. +- When pipelines are deleted (e.g., via the retention worker) `Block.delete_blocks_from_ppl/1` is invoked to purge block-state tables—be mindful of this coupling when making schema changes. + diff --git a/plumber/ppl/AGENTS.md b/plumber/ppl/AGENTS.md new file mode 100644 index 000000000..5a377e7bf --- /dev/null +++ b/plumber/ppl/AGENTS.md @@ -0,0 +1,22 @@ +# Ppl Service Guidelines + +## Project Layout +- `lib/ppl/` contains the OTP application code (workers, GRPC servers, caches, etc.). +- `priv/ecto_repo/migrations/` holds database migrations for `Ppl.EctoRepo`. +- `config/` hosts the environment-specific config (runtime DB credentials, Watchman, RabbitMQ consumers). +- `test/` mirrors `lib/` with ExUnit suites; helpers live in `test/support`. + +## Common Tasks +- Install deps: `mix deps.get`. +- Run migrations: `mix ecto.migrate -r Ppl.EctoRepo`. +- Launch tests: `mix test` (set `MIX_ENV=test`, and start Postgres/RabbitMQ via the repo `Makefile` if not already running). +- Format & lint: `mix format`, `mix credo --strict`. + +## Background Workers +- Looper STMs and Beholders are supervised via `Ppl.Application`. +- `Ppl.Retention.PolicyConsumer` (Tackle) listens for `usage.OrganizationPolicyApply` events and marks pipelines by setting `expires_at`. + +## Configuration Tips +- StatsD via Watchman: set `METRICS_HOST`, `METRICS_PORT`, `METRICS_NAMESPACE`. +- DB settings: `POSTGRES_DB_*` env vars control `Ppl.EctoRepo`; separate vars govern the `block` repo. +- Retention consumer: `USAGE_POLICY_EXCHANGE` / `USAGE_POLICY_ROUTING_KEY` configure which RabbitMQ route the policy consumer listens to. diff --git a/plumber/ppl/config/config.exs b/plumber/ppl/config/config.exs index 8987a3a22..e839f6ec6 100644 --- a/plumber/ppl/config/config.exs +++ b/plumber/ppl/config/config.exs @@ -43,6 +43,11 @@ config :gofer_client, gofer_grpc_timeout: 4_567 # Time in hours before delete requests are processed config :ppl, deletion_offset_h: 24 +# Retention policy event consumer +config :ppl, Ppl.Retention.PolicyConsumer, + exchange: System.get_env("USAGE_POLICY_EXCHANGE"), + routing_key: System.get_env("USAGE_POLICY_ROUTING_KEY") + # How many times should wormhole retry to publish pipeline events to RabbitMQ config :ppl, publish_retry_count: 3 # Timeout for publishing pipeline events to RabbitMQ diff --git a/plumber/ppl/config/test.exs b/plumber/ppl/config/test.exs index 9914319b7..618f2403a 100644 --- a/plumber/ppl/config/test.exs +++ b/plumber/ppl/config/test.exs @@ -47,6 +47,10 @@ config :ppl, dr_pending_sp: 100 config :ppl, dr_deleting_sp: 100 config :ppl, dr_queue_deleting_sp: 100 +config :ppl, Ppl.Retention.PolicyConsumer, + exchange: "usage_internal_api_test", + routing_key: "usage.apply_organization_policy.test" + config :watchman, host: "localhost", port: 8125, diff --git a/plumber/ppl/lib/ppl/application.ex b/plumber/ppl/lib/ppl/application.ex index 670cbcde1..3a25883fe 100644 --- a/plumber/ppl/lib/ppl/application.ex +++ b/plumber/ppl/lib/ppl/application.ex @@ -52,6 +52,7 @@ defmodule Ppl.Application do [ Ppl.Sup.STM, worker(Ppl.OrgEventsConsumer, []), + worker(Ppl.Retention.PolicyConsumer, []) ] end diff --git a/plumber/ppl/lib/ppl/ppl_requests/model/ppl_requests.ex b/plumber/ppl/lib/ppl/ppl_requests/model/ppl_requests.ex index 406f4a06c..6c9964463 100644 --- a/plumber/ppl/lib/ppl/ppl_requests/model/ppl_requests.ex +++ b/plumber/ppl/lib/ppl/ppl_requests/model/ppl_requests.ex @@ -23,6 +23,7 @@ defmodule Ppl.PplRequests.Model.PplRequests do field :wf_id, :string field :source_args, :map field :pre_flight_checks, :map + field :expires_at, :naive_datetime_usec timestamps(type: :naive_datetime_usec) end diff --git a/plumber/ppl/lib/ppl/retention/policy_applier.ex b/plumber/ppl/lib/ppl/retention/policy_applier.ex new file mode 100644 index 000000000..2032585d3 --- /dev/null +++ b/plumber/ppl/lib/ppl/retention/policy_applier.ex @@ -0,0 +1,29 @@ +defmodule Ppl.Retention.PolicyApplier do + @moduledoc """ + Marks pipelines for expiration when an organization policy is applied. + """ + + import Ecto.Query + + alias Ppl.EctoRepo + alias Ppl.PplRequests.Model.PplRequests + + @doc """ + Sets `expires_at` on all pipelines for `org_id` inserted before `cutoff`. + Pipelines already marked with an earlier or equal expiration are left untouched. + Returns the number of rows affected. + """ + @spec mark_expiring(String.t(), NaiveDateTime.t()) :: non_neg_integer() + def mark_expiring(org_id, cutoff) do + query = + from(pr in PplRequests, + where: fragment("?->>?", pr.request_args, "organization_id") == ^org_id, + where: pr.inserted_at < ^cutoff, + where: is_nil(pr.expires_at) or pr.expires_at > ^cutoff + ) + + {count, _} = EctoRepo.update_all(query, set: [expires_at: ^cutoff]) + count + end +end + diff --git a/plumber/ppl/lib/ppl/retention/policy_consumer.ex b/plumber/ppl/lib/ppl/retention/policy_consumer.ex new file mode 100644 index 000000000..f70ef39b7 --- /dev/null +++ b/plumber/ppl/lib/ppl/retention/policy_consumer.ex @@ -0,0 +1,55 @@ +defmodule Ppl.Retention.PolicyConsumer do + @moduledoc """ + Subscribes to usage.ApplyOrganizationPolicyEvent and marks pipelines for expiration. + """ + + @consumer_opts Application.compile_env(:ppl, __MODULE__, []) + + use Tackle.Consumer, + url: System.get_env("RABBITMQ_URL"), + exchange: Keyword.get(@consumer_opts, :exchange, "usage_internal_api"), + routing_key: Keyword.get(@consumer_opts, :routing_key, "usage.apply_organization_policy"), + service: "plumber-retention" + + require Logger + + alias Google.Protobuf.Timestamp + alias InternalApi.Usage.OrganizationPolicyApply + alias Ppl.Retention.PolicyApplier + + def handle_message(message) do + with {:ok, event} <- decode(message), + {:ok, cutoff} <- cutoff_to_naive(event.cutoff_date), + {:ok, org_id} <- non_empty(event.org_id) do + count = PolicyApplier.mark_expiring(org_id, cutoff) + Watchman.increment({"retention.marked", [org_id]}) + Logger.info("[Retention] Marked #{count} pipelines for org #{org_id} until #{cutoff}") + else + {:error, reason} -> + Logger.error("[Retention] Failed to apply policy event: #{inspect(reason)}") + end + end + + defp decode(message) do + OrganizationPolicyApply.decode(message) + |> case do + %OrganizationPolicyApply{} = event -> {:ok, event} + other -> {:error, {:unexpected_payload, other}} + end + rescue + e -> {:error, e} + end + + defp cutoff_to_naive(%Timestamp{seconds: 0, nanos: 0}), do: {:error, :missing_cutoff} + + defp cutoff_to_naive(%Timestamp{seconds: seconds, nanos: nanos}) do + {:ok, datetime} = DateTime.from_unix(seconds, :second) + micros = div(nanos, 1_000) + {:ok, datetime |> DateTime.add(micros, :microsecond) |> DateTime.to_naive()} + end + + defp cutoff_to_naive(nil), do: {:error, :missing_cutoff} + + defp non_empty(value) when value in [nil, ""], do: {:error, :missing_org_id} + defp non_empty(value), do: {:ok, value} +end diff --git a/plumber/ppl/priv/ecto_repo/migrations/20250224121500_add_expires_at_to_pipeline_requests.exs b/plumber/ppl/priv/ecto_repo/migrations/20250224121500_add_expires_at_to_pipeline_requests.exs new file mode 100644 index 000000000..35f7a4245 --- /dev/null +++ b/plumber/ppl/priv/ecto_repo/migrations/20250224121500_add_expires_at_to_pipeline_requests.exs @@ -0,0 +1,11 @@ +defmodule Ppl.EctoRepo.Migrations.AddExpiresAtToPipelineRequests do + use Ecto.Migration + + def change do + alter table(:pipeline_requests) do + add :expires_at, :naive_datetime_usec + end + + create index(:pipeline_requests, [:created_at, :expires_at], name: :idx_pipeline_requests_created_at_expires_at_not_null, concurrently: true, where: "expires_at IS NOT NULL") + end +end diff --git a/plumber/proto/Makefile b/plumber/proto/Makefile index c0495c8a7..73aa95a49 100644 --- a/plumber/proto/Makefile +++ b/plumber/proto/Makefile @@ -48,6 +48,7 @@ endif docker run --rm -v $(PWD):/home/protoc/code -v $(TMP_INTERNAL_REPO_DIR):/home/protoc/source renderedtext/protoc:$(RT_PROTOC_IMG_VSN) protoc -I /home/protoc/source -I /home/protoc/source/include --elixir_out=plugins=grpc:$(RELATIVE_INTERNAL_PB_OUTPUT_DIR) --plugin=/root/.mix/escripts/protoc-gen-elixir /home/protoc/source/artifacthub.proto docker run --rm -v $(PWD):/home/protoc/code -v $(TMP_INTERNAL_REPO_DIR):/home/protoc/source renderedtext/protoc:$(RT_PROTOC_IMG_VSN) protoc -I /home/protoc/source -I /home/protoc/source/include --elixir_out=plugins=grpc:$(RELATIVE_INTERNAL_PB_OUTPUT_DIR) --plugin=/root/.mix/escripts/protoc-gen-elixir /home/protoc/source/health.proto docker run --rm -v $(PWD):/home/protoc/code -v $(TMP_INTERNAL_REPO_DIR):/home/protoc/source renderedtext/protoc:$(RT_PROTOC_IMG_VSN) protoc -I /home/protoc/source -I /home/protoc/source/include --elixir_out=plugins=grpc:$(RELATIVE_INTERNAL_PB_OUTPUT_DIR) --plugin=/root/.mix/escripts/protoc-gen-elixir /home/protoc/source/pre_flight_checks_hub.proto + docker run --rm -v $(PWD):/home/protoc/code -v $(TMP_INTERNAL_REPO_DIR):/home/protoc/source renderedtext/protoc:$(RT_PROTOC_IMG_VSN) protoc -I /home/protoc/source -I /home/protoc/source/include --elixir_out=plugins=grpc:$(RELATIVE_INTERNAL_PB_OUTPUT_DIR) --plugin=/root/.mix/escripts/protoc-gen-elixir /home/protoc/source/usage.proto rm -rf $(TMP_INTERNAL_REPO_DIR) console: diff --git a/plumber/proto/lib/internal_api/artifacthub.pb.ex b/plumber/proto/lib/internal_api/artifacthub.pb.ex index 46c16957b..d70f907cc 100644 --- a/plumber/proto/lib/internal_api/artifacthub.pb.ex +++ b/plumber/proto/lib/internal_api/artifacthub.pb.ex @@ -37,17 +37,23 @@ defmodule InternalApi.Artifacthub.RetentionPolicy do :last_cleaned_at ] - field(:project_level_retention_policies, 1, + field( + :project_level_retention_policies, + 1, repeated: true, type: InternalApi.Artifacthub.RetentionPolicy.RetentionPolicyRule ) - field(:workflow_level_retention_policies, 2, + field( + :workflow_level_retention_policies, + 2, repeated: true, type: InternalApi.Artifacthub.RetentionPolicy.RetentionPolicyRule ) - field(:job_level_retention_policies, 3, + field( + :job_level_retention_policies, + 3, repeated: true, type: InternalApi.Artifacthub.RetentionPolicy.RetentionPolicyRule ) @@ -281,7 +287,9 @@ defmodule InternalApi.Artifacthub.ListBucketsResponse do } defstruct [:bucket_names_for_ids] - field(:bucket_names_for_ids, 1, + field( + :bucket_names_for_ids, + 1, repeated: true, type: InternalApi.Artifacthub.ListBucketsResponse.BucketNamesForIdsEntry, map: true diff --git a/plumber/proto/lib/internal_api/build.pb.ex b/plumber/proto/lib/internal_api/build.pb.ex deleted file mode 100644 index 928b6e6f0..000000000 --- a/plumber/proto/lib/internal_api/build.pb.ex +++ /dev/null @@ -1,481 +0,0 @@ -defmodule InternalApi.Build.ScheduleRequest do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - build: InternalApi.Build.Build.t(), - build_request_id: String.t(), - ppl_id: String.t(), - hook_id: String.t(), - wf_id: String.t() - } - defstruct [:build, :build_request_id, :ppl_id, :hook_id, :wf_id] - - field(:build, 1, type: InternalApi.Build.Build) - field(:build_request_id, 5, type: :string) - field(:ppl_id, 6, type: :string) - field(:hook_id, 7, type: :string) - field(:wf_id, 8, type: :string) -end - -defmodule InternalApi.Build.Build do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - jobs: [InternalApi.Build.Job.t()], - boosters: [InternalApi.Build.Booster.t()] - } - defstruct [:jobs, :boosters] - - field(:jobs, 1, repeated: true, type: InternalApi.Build.Job) - field(:boosters, 2, repeated: true, type: InternalApi.Build.Booster) -end - -defmodule InternalApi.Build.Job do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - name: String.t(), - semaphore_image: String.t(), - agent: InternalApi.Build.Agent.t(), - ppl_env_variables: [InternalApi.Build.EnvVariable.t()], - env_variables: [InternalApi.Build.EnvVariable.t()], - secrets: [InternalApi.Build.Secret.t()], - ppl_commands: [String.t()], - prologue_commands: [String.t()], - commands: [String.t()], - epilogue_commands: [String.t()] - } - defstruct [ - :name, - :semaphore_image, - :agent, - :ppl_env_variables, - :env_variables, - :secrets, - :ppl_commands, - :prologue_commands, - :commands, - :epilogue_commands - ] - - field(:name, 2, type: :string) - field(:semaphore_image, 8, type: :string) - field(:agent, 12, type: InternalApi.Build.Agent) - field(:ppl_env_variables, 10, repeated: true, type: InternalApi.Build.EnvVariable) - field(:env_variables, 3, repeated: true, type: InternalApi.Build.EnvVariable) - field(:secrets, 11, repeated: true, type: InternalApi.Build.Secret) - field(:ppl_commands, 9, repeated: true, type: :string) - field(:prologue_commands, 5, repeated: true, type: :string) - field(:commands, 1, repeated: true, type: :string) - field(:epilogue_commands, 6, repeated: true, type: :string) -end - -defmodule InternalApi.Build.Agent do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - machine: InternalApi.Build.Agent.Machine.t() - } - defstruct [:machine] - - field(:machine, 1, type: InternalApi.Build.Agent.Machine) -end - -defmodule InternalApi.Build.Agent.Machine do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - type: String.t(), - os_image: String.t() - } - defstruct [:type, :os_image] - - field(:type, 1, type: :string) - field(:os_image, 2, type: :string) -end - -defmodule InternalApi.Build.EnvVariable do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - key: String.t(), - value: String.t() - } - defstruct [:key, :value] - - field(:key, 1, type: :string) - field(:value, 2, type: :string) -end - -defmodule InternalApi.Build.Booster do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - name: String.t(), - job_count: integer, - type: integer, - env_variables: [InternalApi.Build.EnvVariable.t()], - prologue_commands: [String.t()], - epilogue_commands: [String.t()], - secrets: [InternalApi.Build.Secret.t()], - semaphore_image: String.t(), - ppl_commands: [String.t()], - ppl_env_variables: [InternalApi.Build.EnvVariable.t()] - } - defstruct [ - :name, - :job_count, - :type, - :env_variables, - :prologue_commands, - :epilogue_commands, - :secrets, - :semaphore_image, - :ppl_commands, - :ppl_env_variables - ] - - field(:name, 1, type: :string) - field(:job_count, 2, type: :int32) - field(:type, 3, type: InternalApi.Build.Booster.Type, enum: true) - field(:env_variables, 4, repeated: true, type: InternalApi.Build.EnvVariable) - field(:prologue_commands, 6, repeated: true, type: :string) - field(:epilogue_commands, 7, repeated: true, type: :string) - field(:secrets, 12, repeated: true, type: InternalApi.Build.Secret) - field(:semaphore_image, 9, type: :string) - field(:ppl_commands, 10, repeated: true, type: :string) - field(:ppl_env_variables, 11, repeated: true, type: InternalApi.Build.EnvVariable) -end - -defmodule InternalApi.Build.Booster.Type do - @moduledoc false - use Protobuf, enum: true, syntax: :proto3 - - field(:RSPEC, 0) - field(:CUCUMBER, 1) -end - -defmodule InternalApi.Build.Secret do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - name: String.t(), - env_var_names: [String.t()], - config_file_paths: [String.t()] - } - defstruct [:name, :env_var_names, :config_file_paths] - - field(:name, 1, type: :string) - field(:env_var_names, 2, repeated: true, type: :string) - field(:config_file_paths, 3, repeated: true, type: :string) -end - -defmodule InternalApi.Build.ScheduleResponse do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - response_status: InternalApi.Build.ResponseStatus.t(), - status: InternalApi.ResponseStatus.t() - } - defstruct [:response_status, :status] - - field(:response_status, 2, type: InternalApi.Build.ResponseStatus) - field(:status, 3, type: InternalApi.ResponseStatus) -end - -defmodule InternalApi.Build.ResponseStatus do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - code: integer, - message: String.t() - } - defstruct [:code, :message] - - field(:code, 1, type: InternalApi.Build.ResponseStatus.ResponseCode, enum: true) - field(:message, 2, type: :string) -end - -defmodule InternalApi.Build.ResponseStatus.ResponseCode do - @moduledoc false - use Protobuf, enum: true, syntax: :proto3 - - field(:OK, 0) - field(:BAD_PARAM, 2) -end - -defmodule InternalApi.Build.DescribeRequest do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - build_request_id: String.t() - } - defstruct [:build_request_id] - - field(:build_request_id, 2, type: :string) -end - -defmodule InternalApi.Build.DescribeManyRequest do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - build_request_ids: [String.t()] - } - defstruct [:build_request_ids] - - field(:build_request_ids, 1, repeated: true, type: :string) -end - -defmodule InternalApi.Build.DescribeResponse do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - build_status: InternalApi.Build.ExecutionStatus.t(), - response_status: InternalApi.Build.ResponseStatus.t(), - build: InternalApi.Build.BuildDescription.t(), - status: InternalApi.ResponseStatus.t() - } - defstruct [:build_status, :response_status, :build, :status] - - field(:build_status, 1, type: InternalApi.Build.ExecutionStatus) - field(:response_status, 3, type: InternalApi.Build.ResponseStatus) - field(:build, 4, type: InternalApi.Build.BuildDescription) - field(:status, 5, type: InternalApi.ResponseStatus) -end - -defmodule InternalApi.Build.DescribeManyResponse do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - response_status: InternalApi.Build.ResponseStatus.t(), - builds: [InternalApi.Build.BuildDescription.t()], - status: InternalApi.ResponseStatus.t() - } - defstruct [:response_status, :builds, :status] - - field(:response_status, 1, type: InternalApi.Build.ResponseStatus) - field(:builds, 2, repeated: true, type: InternalApi.Build.BuildDescription) - field(:status, 3, type: InternalApi.ResponseStatus) -end - -defmodule InternalApi.Build.BuildDescription do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - build_request_id: String.t(), - status: integer, - result: integer, - jobs: [InternalApi.Build.BuildDescription.Job.t()] - } - defstruct [:build_request_id, :status, :result, :jobs] - - field(:build_request_id, 1, type: :string) - field(:status, 2, type: InternalApi.Build.BuildDescription.Status, enum: true) - field(:result, 3, type: InternalApi.Build.BuildDescription.Result, enum: true) - field(:jobs, 4, repeated: true, type: InternalApi.Build.BuildDescription.Job) -end - -defmodule InternalApi.Build.BuildDescription.Job do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - job_id: String.t(), - status: integer, - result: integer, - name: String.t(), - index: integer - } - defstruct [:job_id, :status, :result, :name, :index] - - field(:job_id, 1, type: :string) - field(:status, 2, type: InternalApi.Build.BuildDescription.Job.Status, enum: true) - field(:result, 3, type: InternalApi.Build.BuildDescription.Job.Result, enum: true) - field(:name, 4, type: :string) - field(:index, 5, type: :int32) -end - -defmodule InternalApi.Build.BuildDescription.Job.Status do - @moduledoc false - use Protobuf, enum: true, syntax: :proto3 - - field(:ENQUEUED, 0) - field(:RUNNING, 1) - field(:STOPPING, 2) - field(:FINISHED, 3) -end - -defmodule InternalApi.Build.BuildDescription.Job.Result do - @moduledoc false - use Protobuf, enum: true, syntax: :proto3 - - field(:PASSED, 0) - field(:FAILED, 1) - field(:STOPPED, 2) -end - -defmodule InternalApi.Build.BuildDescription.Status do - @moduledoc false - use Protobuf, enum: true, syntax: :proto3 - - field(:ENQUEUED, 0) - field(:RUNNING, 1) - field(:STOPPING, 2) - field(:FINISHED, 3) - field(:DELETED, 4) -end - -defmodule InternalApi.Build.BuildDescription.Result do - @moduledoc false - use Protobuf, enum: true, syntax: :proto3 - - field(:PASSED, 0) - field(:FAILED, 1) - field(:STOPPED, 2) -end - -defmodule InternalApi.Build.ExecutionStatus do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - status: integer, - result: integer, - name: String.t() - } - defstruct [:status, :result, :name] - - field(:status, 1, type: InternalApi.Build.ExecutionStatus.Status, enum: true) - field(:result, 2, type: InternalApi.Build.ExecutionStatus.Result, enum: true) - field(:name, 3, type: :string) -end - -defmodule InternalApi.Build.ExecutionStatus.Status do - @moduledoc false - use Protobuf, enum: true, syntax: :proto3 - - field(:ENQUEUED, 0) - field(:RUNNING, 1) - field(:STOPPING, 2) - field(:FINISHED, 3) - field(:DELETED, 4) -end - -defmodule InternalApi.Build.ExecutionStatus.Result do - @moduledoc false - use Protobuf, enum: true, syntax: :proto3 - - field(:PASSED, 0) - field(:FAILED, 1) - field(:STOPPED, 2) -end - -defmodule InternalApi.Build.VersionRequest do - @moduledoc false - use Protobuf, syntax: :proto3 - - defstruct [] -end - -defmodule InternalApi.Build.VersionResponse do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - version: String.t() - } - defstruct [:version] - - field(:version, 1, type: :string) -end - -defmodule InternalApi.Build.TerminateRequest do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - build_request_id: String.t() - } - defstruct [:build_request_id] - - field(:build_request_id, 1, type: :string) -end - -defmodule InternalApi.Build.TerminateResponse do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - response_status: InternalApi.Build.ResponseStatus.t(), - status: InternalApi.ResponseStatus.t() - } - defstruct [:response_status, :status] - - field(:response_status, 1, type: InternalApi.Build.ResponseStatus) - field(:status, 2, type: InternalApi.ResponseStatus) -end - -defmodule InternalApi.Build.BuildStarted do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - build_request_id: String.t(), - timestamp: Google.Protobuf.Timestamp.t() - } - defstruct [:build_request_id, :timestamp] - - field(:build_request_id, 1, type: :string) - field(:timestamp, 2, type: Google.Protobuf.Timestamp) -end - -defmodule InternalApi.Build.BuildFinished do - @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - build_request_id: String.t(), - timestamp: Google.Protobuf.Timestamp.t() - } - defstruct [:build_request_id, :timestamp] - - field(:build_request_id, 1, type: :string) - field(:timestamp, 2, type: Google.Protobuf.Timestamp) -end - -defmodule InternalApi.Build.BuildService.Service do - @moduledoc false - use GRPC.Service, name: "InternalApi.Build.BuildService" - - rpc(:Schedule, InternalApi.Build.ScheduleRequest, InternalApi.Build.ScheduleResponse) - rpc(:Describe, InternalApi.Build.DescribeRequest, InternalApi.Build.DescribeResponse) - - rpc( - :DescribeMany, - InternalApi.Build.DescribeManyRequest, - InternalApi.Build.DescribeManyResponse - ) - - rpc(:Version, InternalApi.Build.VersionRequest, InternalApi.Build.VersionResponse) - rpc(:Terminate, InternalApi.Build.TerminateRequest, InternalApi.Build.TerminateResponse) -end - -defmodule InternalApi.Build.BuildService.Stub do - @moduledoc false - use GRPC.Stub, service: InternalApi.Build.BuildService.Service -end diff --git a/plumber/proto/lib/internal_api/gofer.dt.pb.ex b/plumber/proto/lib/internal_api/gofer.dt.pb.ex index c56c33c79..8ff376358 100644 --- a/plumber/proto/lib/internal_api/gofer.dt.pb.ex +++ b/plumber/proto/lib/internal_api/gofer.dt.pb.ex @@ -67,7 +67,9 @@ defmodule InternalApi.Gofer.DeploymentTargets.VerifyRequest do field(:target_id, 1, type: :string) field(:triggerer, 2, type: :string) - field(:git_ref_type, 3, + field( + :git_ref_type, + 3, type: InternalApi.Gofer.DeploymentTargets.VerifyRequest.GitRefType, enum: true ) @@ -123,7 +125,9 @@ defmodule InternalApi.Gofer.DeploymentTargets.HistoryRequest do field(:target_id, 1, type: :string) - field(:cursor_type, 2, + field( + :cursor_type, + 2, type: InternalApi.Gofer.DeploymentTargets.HistoryRequest.CursorType, enum: true ) @@ -421,7 +425,12 @@ defmodule InternalApi.Gofer.DeploymentTargets.Deployment do field(:switch_id, 9, type: :string) field(:target_name, 10, type: :string) - field(:env_vars, 11, repeated: true, type: InternalApi.Gofer.DeploymentTargets.Deployment.EnvVar) + field( + :env_vars, + 11, + repeated: true, + type: InternalApi.Gofer.DeploymentTargets.Deployment.EnvVar + ) field(:can_requester_rerun, 12, type: :bool) end diff --git a/plumber/proto/lib/internal_api/organization.pb.ex b/plumber/proto/lib/internal_api/organization.pb.ex index 741f05b53..825679122 100644 --- a/plumber/proto/lib/internal_api/organization.pb.ex +++ b/plumber/proto/lib/internal_api/organization.pb.ex @@ -322,7 +322,9 @@ defmodule InternalApi.Organization.AddMembersRequest do field(:org_id, 1, type: :string) field(:creator_id, 2, type: :string) - field(:members_data, 3, + field( + :members_data, + 3, repeated: true, type: InternalApi.Organization.AddMembersRequest.MemberData ) @@ -696,13 +698,17 @@ defmodule InternalApi.Organization.RepositoryIntegratorsResponse do field(:primary, 1, type: InternalApi.RepositoryIntegrator.IntegrationType, enum: true) - field(:enabled, 2, + field( + :enabled, + 2, repeated: true, type: InternalApi.RepositoryIntegrator.IntegrationType, enum: true ) - field(:available, 3, + field( + :available, + 3, repeated: true, type: InternalApi.RepositoryIntegrator.IntegrationType, enum: true diff --git a/plumber/proto/lib/internal_api/plumber_w_f.workflow.pb.ex b/plumber/proto/lib/internal_api/plumber_w_f.workflow.pb.ex index 86a7d4dd5..dde00f3ab 100644 --- a/plumber/proto/lib/internal_api/plumber_w_f.workflow.pb.ex +++ b/plumber/proto/lib/internal_api/plumber_w_f.workflow.pb.ex @@ -39,22 +39,22 @@ defmodule InternalApi.PlumberWF.ScheduleRequest do :git_reference ] - field :service, 2, type: InternalApi.PlumberWF.ScheduleRequest.ServiceType, enum: true - field :repo, 3, type: InternalApi.PlumberWF.ScheduleRequest.Repo - field :project_id, 6, type: :string - field :branch_id, 7, type: :string - field :hook_id, 8, type: :string - field :request_token, 9, type: :string - field :snapshot_id, 10, type: :string - field :definition_file, 11, type: :string - field :requester_id, 12, type: :string - field :organization_id, 13, type: :string - field :label, 14, type: :string - field :triggered_by, 15, type: InternalApi.PlumberWF.TriggeredBy, enum: true - field :scheduler_task_id, 16, type: :string - field :env_vars, 17, repeated: true, type: InternalApi.PlumberWF.ScheduleRequest.EnvVar - field :start_in_conceived_state, 18, type: :bool - field :git_reference, 19, type: :string + field(:service, 2, type: InternalApi.PlumberWF.ScheduleRequest.ServiceType, enum: true) + field(:repo, 3, type: InternalApi.PlumberWF.ScheduleRequest.Repo) + field(:project_id, 6, type: :string) + field(:branch_id, 7, type: :string) + field(:hook_id, 8, type: :string) + field(:request_token, 9, type: :string) + field(:snapshot_id, 10, type: :string) + field(:definition_file, 11, type: :string) + field(:requester_id, 12, type: :string) + field(:organization_id, 13, type: :string) + field(:label, 14, type: :string) + field(:triggered_by, 15, type: InternalApi.PlumberWF.TriggeredBy, enum: true) + field(:scheduler_task_id, 16, type: :string) + field(:env_vars, 17, repeated: true, type: InternalApi.PlumberWF.ScheduleRequest.EnvVar) + field(:start_in_conceived_state, 18, type: :bool) + field(:git_reference, 19, type: :string) end defmodule InternalApi.PlumberWF.ScheduleRequest.Repo do @@ -70,11 +70,11 @@ defmodule InternalApi.PlumberWF.ScheduleRequest.Repo do } defstruct [:owner, :repo_name, :branch_name, :commit_sha, :repository_id] - field :owner, 1, type: :string - field :repo_name, 2, type: :string - field :branch_name, 4, type: :string - field :commit_sha, 5, type: :string - field :repository_id, 6, type: :string + field(:owner, 1, type: :string) + field(:repo_name, 2, type: :string) + field(:branch_name, 4, type: :string) + field(:commit_sha, 5, type: :string) + field(:repository_id, 6, type: :string) end defmodule InternalApi.PlumberWF.ScheduleRequest.EnvVar do @@ -87,20 +87,20 @@ defmodule InternalApi.PlumberWF.ScheduleRequest.EnvVar do } defstruct [:name, :value] - field :name, 1, type: :string - field :value, 2, type: :string + field(:name, 1, type: :string) + field(:value, 2, type: :string) end defmodule InternalApi.PlumberWF.ScheduleRequest.ServiceType do @moduledoc false use Protobuf, enum: true, syntax: :proto3 - field :GIT_HUB, 0 - field :LOCAL, 1 - field :SNAPSHOT, 2 - field :BITBUCKET, 3 - field :GITLAB, 4 - field :GIT, 5 + field(:GIT_HUB, 0) + field(:LOCAL, 1) + field(:SNAPSHOT, 2) + field(:BITBUCKET, 3) + field(:GITLAB, 4) + field(:GIT, 5) end defmodule InternalApi.PlumberWF.ScheduleResponse do @@ -114,9 +114,9 @@ defmodule InternalApi.PlumberWF.ScheduleResponse do } defstruct [:wf_id, :status, :ppl_id] - field :wf_id, 2, type: :string - field :status, 3, type: InternalApi.Status - field :ppl_id, 4, type: :string + field(:wf_id, 2, type: :string) + field(:status, 3, type: InternalApi.Status) + field(:ppl_id, 4, type: :string) end defmodule InternalApi.PlumberWF.GetPathRequest do @@ -130,9 +130,9 @@ defmodule InternalApi.PlumberWF.GetPathRequest do } defstruct [:wf_id, :first_ppl_id, :last_ppl_id] - field :wf_id, 1, type: :string - field :first_ppl_id, 2, type: :string - field :last_ppl_id, 3, type: :string + field(:wf_id, 1, type: :string) + field(:first_ppl_id, 2, type: :string) + field(:last_ppl_id, 3, type: :string) end defmodule InternalApi.PlumberWF.GetPathResponse do @@ -147,10 +147,10 @@ defmodule InternalApi.PlumberWF.GetPathResponse do } defstruct [:wf_id, :wf_created_at, :path, :status] - field :wf_id, 2, type: :string - field :wf_created_at, 3, type: Google.Protobuf.Timestamp - field :path, 4, repeated: true, type: InternalApi.PlumberWF.GetPathResponse.PathElement - field :status, 5, type: InternalApi.Status + field(:wf_id, 2, type: :string) + field(:wf_created_at, 3, type: Google.Protobuf.Timestamp) + field(:path, 4, repeated: true, type: InternalApi.PlumberWF.GetPathResponse.PathElement) + field(:status, 5, type: InternalApi.Status) end defmodule InternalApi.PlumberWF.GetPathResponse.PathElement do @@ -164,9 +164,9 @@ defmodule InternalApi.PlumberWF.GetPathResponse.PathElement do } defstruct [:ppl_id, :switch_id, :rebuild_partition] - field :ppl_id, 1, type: :string - field :switch_id, 2, type: :string - field :rebuild_partition, 3, repeated: true, type: :string + field(:ppl_id, 1, type: :string) + field(:switch_id, 2, type: :string) + field(:rebuild_partition, 3, repeated: true, type: :string) end defmodule InternalApi.PlumberWF.ListLatestWorkflowsRequest do @@ -192,32 +192,35 @@ defmodule InternalApi.PlumberWF.ListLatestWorkflowsRequest do :git_ref_types ] - field :order, 1, type: InternalApi.PlumberWF.ListLatestWorkflowsRequest.Order, enum: true - field :page_size, 2, type: :int32 - field :page_token, 3, type: :string + field(:order, 1, type: InternalApi.PlumberWF.ListLatestWorkflowsRequest.Order, enum: true) + field(:page_size, 2, type: :int32) + field(:page_token, 3, type: :string) - field :direction, 4, + field( + :direction, + 4, type: InternalApi.PlumberWF.ListLatestWorkflowsRequest.Direction, enum: true + ) - field :project_id, 5, type: :string - field :requester_id, 6, type: :string - field :git_ref_types, 7, repeated: true, type: InternalApi.PlumberWF.GitRefType, enum: true + field(:project_id, 5, type: :string) + field(:requester_id, 6, type: :string) + field(:git_ref_types, 7, repeated: true, type: InternalApi.PlumberWF.GitRefType, enum: true) end defmodule InternalApi.PlumberWF.ListLatestWorkflowsRequest.Order do @moduledoc false use Protobuf, enum: true, syntax: :proto3 - field :BY_CREATION_TIME_DESC, 0 + field(:BY_CREATION_TIME_DESC, 0) end defmodule InternalApi.PlumberWF.ListLatestWorkflowsRequest.Direction do @moduledoc false use Protobuf, enum: true, syntax: :proto3 - field :NEXT, 0 - field :PREVIOUS, 1 + field(:NEXT, 0) + field(:PREVIOUS, 1) end defmodule InternalApi.PlumberWF.ListLatestWorkflowsResponse do @@ -231,9 +234,9 @@ defmodule InternalApi.PlumberWF.ListLatestWorkflowsResponse do } defstruct [:workflows, :next_page_token, :previous_page_token] - field :workflows, 1, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails - field :next_page_token, 2, type: :string - field :previous_page_token, 3, type: :string + field(:workflows, 1, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails) + field(:next_page_token, 2, type: :string) + field(:previous_page_token, 3, type: :string) end defmodule InternalApi.PlumberWF.ListGroupedKSRequest do @@ -259,28 +262,28 @@ defmodule InternalApi.PlumberWF.ListGroupedKSRequest do :git_ref_types ] - field :order, 1, type: InternalApi.PlumberWF.ListGroupedKSRequest.Order, enum: true - field :page_size, 2, type: :int32 - field :page_token, 3, type: :string - field :direction, 4, type: InternalApi.PlumberWF.ListGroupedKSRequest.Direction, enum: true - field :project_id, 5, type: :string - field :requester_id, 6, type: :string - field :git_ref_types, 7, repeated: true, type: InternalApi.PlumberWF.GitRefType, enum: true + field(:order, 1, type: InternalApi.PlumberWF.ListGroupedKSRequest.Order, enum: true) + field(:page_size, 2, type: :int32) + field(:page_token, 3, type: :string) + field(:direction, 4, type: InternalApi.PlumberWF.ListGroupedKSRequest.Direction, enum: true) + field(:project_id, 5, type: :string) + field(:requester_id, 6, type: :string) + field(:git_ref_types, 7, repeated: true, type: InternalApi.PlumberWF.GitRefType, enum: true) end defmodule InternalApi.PlumberWF.ListGroupedKSRequest.Order do @moduledoc false use Protobuf, enum: true, syntax: :proto3 - field :BY_CREATION_TIME_DESC, 0 + field(:BY_CREATION_TIME_DESC, 0) end defmodule InternalApi.PlumberWF.ListGroupedKSRequest.Direction do @moduledoc false use Protobuf, enum: true, syntax: :proto3 - field :NEXT, 0 - field :PREVIOUS, 1 + field(:NEXT, 0) + field(:PREVIOUS, 1) end defmodule InternalApi.PlumberWF.ListGroupedKSResponse do @@ -294,9 +297,9 @@ defmodule InternalApi.PlumberWF.ListGroupedKSResponse do } defstruct [:workflows, :next_page_token, :previous_page_token] - field :workflows, 1, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails - field :next_page_token, 2, type: :string - field :previous_page_token, 3, type: :string + field(:workflows, 1, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails) + field(:next_page_token, 2, type: :string) + field(:previous_page_token, 3, type: :string) end defmodule InternalApi.PlumberWF.ListGroupedRequest do @@ -312,20 +315,20 @@ defmodule InternalApi.PlumberWF.ListGroupedRequest do } defstruct [:page, :page_size, :project_id, :grouped_by, :git_ref_types] - field :page, 1, type: :int32 - field :page_size, 2, type: :int32 - field :project_id, 3, type: :string - field :grouped_by, 4, type: InternalApi.PlumberWF.ListGroupedRequest.SourceType, enum: true - field :git_ref_types, 5, repeated: true, type: InternalApi.PlumberWF.GitRefType, enum: true + field(:page, 1, type: :int32) + field(:page_size, 2, type: :int32) + field(:project_id, 3, type: :string) + field(:grouped_by, 4, type: InternalApi.PlumberWF.ListGroupedRequest.SourceType, enum: true) + field(:git_ref_types, 5, repeated: true, type: InternalApi.PlumberWF.GitRefType, enum: true) end defmodule InternalApi.PlumberWF.ListGroupedRequest.SourceType do @moduledoc false use Protobuf, enum: true, syntax: :proto3 - field :BRANCH, 0 - field :TAG, 1 - field :PULL_REQUEST, 2 + field(:BRANCH, 0) + field(:TAG, 1) + field(:PULL_REQUEST, 2) end defmodule InternalApi.PlumberWF.ListGroupedResponse do @@ -342,12 +345,12 @@ defmodule InternalApi.PlumberWF.ListGroupedResponse do } defstruct [:status, :workflows, :page_number, :page_size, :total_entries, :total_pages] - field :status, 1, type: InternalApi.Status - field :workflows, 2, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails - field :page_number, 3, type: :int32 - field :page_size, 4, type: :int32 - field :total_entries, 5, type: :int32 - field :total_pages, 6, type: :int32 + field(:status, 1, type: InternalApi.Status) + field(:workflows, 2, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails) + field(:page_number, 3, type: :int32) + field(:page_size, 4, type: :int32) + field(:total_entries, 5, type: :int32) + field(:total_pages, 6, type: :int32) end defmodule InternalApi.PlumberWF.ListRequest do @@ -381,17 +384,17 @@ defmodule InternalApi.PlumberWF.ListRequest do :git_ref_types ] - field :page, 1, type: :int32 - field :page_size, 2, type: :int32 - field :project_id, 3, type: :string - field :branch_name, 4, type: :string - field :requester_id, 5, type: :string - field :organization_id, 6, type: :string - field :project_ids, 7, repeated: true, type: :string - field :created_before, 8, type: Google.Protobuf.Timestamp - field :created_after, 9, type: Google.Protobuf.Timestamp - field :label, 10, type: :string - field :git_ref_types, 11, repeated: true, type: InternalApi.PlumberWF.GitRefType, enum: true + field(:page, 1, type: :int32) + field(:page_size, 2, type: :int32) + field(:project_id, 3, type: :string) + field(:branch_name, 4, type: :string) + field(:requester_id, 5, type: :string) + field(:organization_id, 6, type: :string) + field(:project_ids, 7, repeated: true, type: :string) + field(:created_before, 8, type: Google.Protobuf.Timestamp) + field(:created_after, 9, type: Google.Protobuf.Timestamp) + field(:label, 10, type: :string) + field(:git_ref_types, 11, repeated: true, type: InternalApi.PlumberWF.GitRefType, enum: true) end defmodule InternalApi.PlumberWF.ListResponse do @@ -408,12 +411,12 @@ defmodule InternalApi.PlumberWF.ListResponse do } defstruct [:status, :workflows, :page_number, :page_size, :total_entries, :total_pages] - field :status, 1, type: InternalApi.Status - field :workflows, 2, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails - field :page_number, 3, type: :int32 - field :page_size, 4, type: :int32 - field :total_entries, 5, type: :int32 - field :total_pages, 6, type: :int32 + field(:status, 1, type: InternalApi.Status) + field(:workflows, 2, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails) + field(:page_number, 3, type: :int32) + field(:page_size, 4, type: :int32) + field(:total_entries, 5, type: :int32) + field(:total_pages, 6, type: :int32) end defmodule InternalApi.PlumberWF.ListKeysetRequest do @@ -455,36 +458,36 @@ defmodule InternalApi.PlumberWF.ListKeysetRequest do :requester_ids ] - field :page_size, 1, type: :int32 - field :page_token, 2, type: :string - field :order, 3, type: InternalApi.PlumberWF.ListKeysetRequest.Order, enum: true - field :organization_id, 4, type: :string - field :project_id, 5, type: :string - field :requester_id, 6, type: :string - field :project_ids, 7, repeated: true, type: :string - field :created_before, 8, type: Google.Protobuf.Timestamp - field :created_after, 9, type: Google.Protobuf.Timestamp - field :label, 10, type: :string - field :git_ref_types, 11, repeated: true, type: InternalApi.PlumberWF.GitRefType, enum: true - field :direction, 12, type: InternalApi.PlumberWF.ListKeysetRequest.Direction, enum: true - field :triggerers, 13, repeated: true, type: InternalApi.PlumberWF.TriggeredBy, enum: true - field :branch_name, 14, type: :string - field :requester_ids, 15, repeated: true, type: :string + field(:page_size, 1, type: :int32) + field(:page_token, 2, type: :string) + field(:order, 3, type: InternalApi.PlumberWF.ListKeysetRequest.Order, enum: true) + field(:organization_id, 4, type: :string) + field(:project_id, 5, type: :string) + field(:requester_id, 6, type: :string) + field(:project_ids, 7, repeated: true, type: :string) + field(:created_before, 8, type: Google.Protobuf.Timestamp) + field(:created_after, 9, type: Google.Protobuf.Timestamp) + field(:label, 10, type: :string) + field(:git_ref_types, 11, repeated: true, type: InternalApi.PlumberWF.GitRefType, enum: true) + field(:direction, 12, type: InternalApi.PlumberWF.ListKeysetRequest.Direction, enum: true) + field(:triggerers, 13, repeated: true, type: InternalApi.PlumberWF.TriggeredBy, enum: true) + field(:branch_name, 14, type: :string) + field(:requester_ids, 15, repeated: true, type: :string) end defmodule InternalApi.PlumberWF.ListKeysetRequest.Order do @moduledoc false use Protobuf, enum: true, syntax: :proto3 - field :BY_CREATION_TIME_DESC, 0 + field(:BY_CREATION_TIME_DESC, 0) end defmodule InternalApi.PlumberWF.ListKeysetRequest.Direction do @moduledoc false use Protobuf, enum: true, syntax: :proto3 - field :NEXT, 0 - field :PREVIOUS, 1 + field(:NEXT, 0) + field(:PREVIOUS, 1) end defmodule InternalApi.PlumberWF.ListKeysetResponse do @@ -499,10 +502,10 @@ defmodule InternalApi.PlumberWF.ListKeysetResponse do } defstruct [:status, :workflows, :next_page_token, :previous_page_token] - field :status, 1, type: InternalApi.Status - field :workflows, 2, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails - field :next_page_token, 3, type: :string - field :previous_page_token, 4, type: :string + field(:status, 1, type: InternalApi.Status) + field(:workflows, 2, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails) + field(:next_page_token, 3, type: :string) + field(:previous_page_token, 4, type: :string) end defmodule InternalApi.PlumberWF.WorkflowDetails do @@ -540,19 +543,19 @@ defmodule InternalApi.PlumberWF.WorkflowDetails do :organization_id ] - field :wf_id, 1, type: :string - field :initial_ppl_id, 2, type: :string - field :project_id, 3, type: :string - field :hook_id, 4, type: :string - field :requester_id, 5, type: :string - field :branch_id, 6, type: :string - field :branch_name, 7, type: :string - field :commit_sha, 8, type: :string - field :created_at, 9, type: Google.Protobuf.Timestamp - field :triggered_by, 10, type: InternalApi.PlumberWF.TriggeredBy, enum: true - field :rerun_of, 11, type: :string - field :repository_id, 12, type: :string - field :organization_id, 13, type: :string + field(:wf_id, 1, type: :string) + field(:initial_ppl_id, 2, type: :string) + field(:project_id, 3, type: :string) + field(:hook_id, 4, type: :string) + field(:requester_id, 5, type: :string) + field(:branch_id, 6, type: :string) + field(:branch_name, 7, type: :string) + field(:commit_sha, 8, type: :string) + field(:created_at, 9, type: Google.Protobuf.Timestamp) + field(:triggered_by, 10, type: InternalApi.PlumberWF.TriggeredBy, enum: true) + field(:rerun_of, 11, type: :string) + field(:repository_id, 12, type: :string) + field(:organization_id, 13, type: :string) end defmodule InternalApi.PlumberWF.DescribeRequest do @@ -564,7 +567,7 @@ defmodule InternalApi.PlumberWF.DescribeRequest do } defstruct [:wf_id] - field :wf_id, 1, type: :string + field(:wf_id, 1, type: :string) end defmodule InternalApi.PlumberWF.DescribeResponse do @@ -577,8 +580,8 @@ defmodule InternalApi.PlumberWF.DescribeResponse do } defstruct [:status, :workflow] - field :status, 1, type: InternalApi.Status - field :workflow, 2, type: InternalApi.PlumberWF.WorkflowDetails + field(:status, 1, type: InternalApi.Status) + field(:workflow, 2, type: InternalApi.PlumberWF.WorkflowDetails) end defmodule InternalApi.PlumberWF.DescribeManyRequest do @@ -590,7 +593,7 @@ defmodule InternalApi.PlumberWF.DescribeManyRequest do } defstruct [:wf_ids] - field :wf_ids, 1, repeated: true, type: :string + field(:wf_ids, 1, repeated: true, type: :string) end defmodule InternalApi.PlumberWF.DescribeManyResponse do @@ -603,8 +606,8 @@ defmodule InternalApi.PlumberWF.DescribeManyResponse do } defstruct [:status, :workflows] - field :status, 1, type: InternalApi.Status - field :workflows, 2, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails + field(:status, 1, type: InternalApi.Status) + field(:workflows, 2, repeated: true, type: InternalApi.PlumberWF.WorkflowDetails) end defmodule InternalApi.PlumberWF.TerminateRequest do @@ -617,8 +620,8 @@ defmodule InternalApi.PlumberWF.TerminateRequest do } defstruct [:requester_id, :wf_id] - field :requester_id, 2, type: :string - field :wf_id, 3, type: :string + field(:requester_id, 2, type: :string) + field(:wf_id, 3, type: :string) end defmodule InternalApi.PlumberWF.TerminateResponse do @@ -630,7 +633,7 @@ defmodule InternalApi.PlumberWF.TerminateResponse do } defstruct [:status] - field :status, 2, type: InternalApi.Status + field(:status, 2, type: InternalApi.Status) end defmodule InternalApi.PlumberWF.ListLabelsRequest do @@ -644,9 +647,9 @@ defmodule InternalApi.PlumberWF.ListLabelsRequest do } defstruct [:page, :page_size, :project_id] - field :page, 1, type: :int32 - field :page_size, 2, type: :int32 - field :project_id, 3, type: :string + field(:page, 1, type: :int32) + field(:page_size, 2, type: :int32) + field(:project_id, 3, type: :string) end defmodule InternalApi.PlumberWF.ListLabelsResponse do @@ -663,12 +666,12 @@ defmodule InternalApi.PlumberWF.ListLabelsResponse do } defstruct [:status, :labels, :page_number, :page_size, :total_entries, :total_pages] - field :status, 1, type: InternalApi.Status - field :labels, 2, repeated: true, type: :string - field :page_number, 3, type: :int32 - field :page_size, 4, type: :int32 - field :total_entries, 5, type: :int32 - field :total_pages, 6, type: :int32 + field(:status, 1, type: InternalApi.Status) + field(:labels, 2, repeated: true, type: :string) + field(:page_number, 3, type: :int32) + field(:page_size, 4, type: :int32) + field(:total_entries, 5, type: :int32) + field(:total_pages, 6, type: :int32) end defmodule InternalApi.PlumberWF.RescheduleRequest do @@ -682,9 +685,9 @@ defmodule InternalApi.PlumberWF.RescheduleRequest do } defstruct [:wf_id, :requester_id, :request_token] - field :wf_id, 1, type: :string - field :requester_id, 2, type: :string - field :request_token, 3, type: :string + field(:wf_id, 1, type: :string) + field(:requester_id, 2, type: :string) + field(:request_token, 3, type: :string) end defmodule InternalApi.PlumberWF.GetProjectIdRequest do @@ -696,7 +699,7 @@ defmodule InternalApi.PlumberWF.GetProjectIdRequest do } defstruct [:wf_id] - field :wf_id, 1, type: :string + field(:wf_id, 1, type: :string) end defmodule InternalApi.PlumberWF.GetProjectIdResponse do @@ -709,8 +712,8 @@ defmodule InternalApi.PlumberWF.GetProjectIdResponse do } defstruct [:status, :project_id] - field :status, 1, type: InternalApi.Status - field :project_id, 2, type: :string + field(:status, 1, type: InternalApi.Status) + field(:project_id, 2, type: :string) end defmodule InternalApi.PlumberWF.CreateRequest do @@ -718,33 +721,21 @@ defmodule InternalApi.PlumberWF.CreateRequest do use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ - service: integer, project_id: String.t(), label: String.t(), + hook_id: String.t(), request_token: String.t(), - definition_key: String.t(), - requester_id: String.t(), - organization_id: String.t() + definition_file: String.t(), + requester_id: String.t() } - defstruct [:service, :project_id, :label, :request_token, :definition_key, :requester_id, :organization_id] - - field :service, 1, type: InternalApi.PlumberWF.CreateRequest.ServiceType, enum: true - field :project_id, 2, type: :string - field :label, 3, type: :string - field :request_token, 4, type: :string - field :definition_key, 5, type: :string - field :requester_id, 6, type: :string - field :organization_id, 7, type: :string -end - -defmodule InternalApi.PlumberWF.CreateRequest.ServiceType do - @moduledoc false - use Protobuf, enum: true, syntax: :proto3 + defstruct [:project_id, :label, :hook_id, :request_token, :definition_file, :requester_id] - field :GIT_HUB_DEPRECATED, 0 - field :LOCAL, 1 - field :SNAPSHOT_DEPRECATED, 2 - field :LISTENER_PROXY, 3 + field(:project_id, 1, type: :string) + field(:label, 2, type: :string) + field(:hook_id, 3, type: :string) + field(:request_token, 4, type: :string) + field(:definition_file, 5, type: :string) + field(:requester_id, 6, type: :string) end defmodule InternalApi.PlumberWF.CreateResponse do @@ -758,73 +749,91 @@ defmodule InternalApi.PlumberWF.CreateResponse do } defstruct [:wf_id, :status, :ppl_id] - field :wf_id, 1, type: :string - field :status, 2, type: InternalApi.Status - field :ppl_id, 3, type: :string + field(:wf_id, 1, type: :string) + field(:status, 2, type: InternalApi.Status) + field(:ppl_id, 3, type: :string) end defmodule InternalApi.PlumberWF.TriggeredBy do @moduledoc false use Protobuf, enum: true, syntax: :proto3 - field :HOOK, 0 - field :SCHEDULE, 1 - field :API, 2 - field :MANUAL_RUN, 3 + field(:HOOK, 0) + field(:SCHEDULE, 1) + field(:API, 2) + field(:MANUAL_RUN, 3) end defmodule InternalApi.PlumberWF.GitRefType do @moduledoc false use Protobuf, enum: true, syntax: :proto3 - field :BRANCH, 0 - field :TAG, 1 - field :PR, 2 + field(:BRANCH, 0) + field(:TAG, 1) + field(:PR, 2) end defmodule InternalApi.PlumberWF.WorkflowService.Service do @moduledoc false use GRPC.Service, name: "InternalApi.PlumberWF.WorkflowService" - rpc :Schedule, InternalApi.PlumberWF.ScheduleRequest, InternalApi.PlumberWF.ScheduleResponse - rpc :GetPath, InternalApi.PlumberWF.GetPathRequest, InternalApi.PlumberWF.GetPathResponse - rpc :List, InternalApi.PlumberWF.ListRequest, InternalApi.PlumberWF.ListResponse - - rpc :ListKeyset, - InternalApi.PlumberWF.ListKeysetRequest, - InternalApi.PlumberWF.ListKeysetResponse - - rpc :ListGrouped, - InternalApi.PlumberWF.ListGroupedRequest, - InternalApi.PlumberWF.ListGroupedResponse - - rpc :ListGroupedKS, - InternalApi.PlumberWF.ListGroupedKSRequest, - InternalApi.PlumberWF.ListGroupedKSResponse - - rpc :ListLatestWorkflows, - InternalApi.PlumberWF.ListLatestWorkflowsRequest, - InternalApi.PlumberWF.ListLatestWorkflowsResponse - - rpc :Describe, InternalApi.PlumberWF.DescribeRequest, InternalApi.PlumberWF.DescribeResponse - - rpc :DescribeMany, - InternalApi.PlumberWF.DescribeManyRequest, - InternalApi.PlumberWF.DescribeManyResponse - - rpc :Terminate, InternalApi.PlumberWF.TerminateRequest, InternalApi.PlumberWF.TerminateResponse - - rpc :ListLabels, - InternalApi.PlumberWF.ListLabelsRequest, - InternalApi.PlumberWF.ListLabelsResponse - - rpc :Reschedule, InternalApi.PlumberWF.RescheduleRequest, InternalApi.PlumberWF.ScheduleResponse - - rpc :GetProjectId, - InternalApi.PlumberWF.GetProjectIdRequest, - InternalApi.PlumberWF.GetProjectIdResponse - - rpc :Create, InternalApi.PlumberWF.CreateRequest, InternalApi.PlumberWF.CreateResponse + rpc(:Schedule, InternalApi.PlumberWF.ScheduleRequest, InternalApi.PlumberWF.ScheduleResponse) + rpc(:GetPath, InternalApi.PlumberWF.GetPathRequest, InternalApi.PlumberWF.GetPathResponse) + rpc(:List, InternalApi.PlumberWF.ListRequest, InternalApi.PlumberWF.ListResponse) + + rpc( + :ListKeyset, + InternalApi.PlumberWF.ListKeysetRequest, + InternalApi.PlumberWF.ListKeysetResponse + ) + + rpc( + :ListGrouped, + InternalApi.PlumberWF.ListGroupedRequest, + InternalApi.PlumberWF.ListGroupedResponse + ) + + rpc( + :ListGroupedKS, + InternalApi.PlumberWF.ListGroupedKSRequest, + InternalApi.PlumberWF.ListGroupedKSResponse + ) + + rpc( + :ListLatestWorkflows, + InternalApi.PlumberWF.ListLatestWorkflowsRequest, + InternalApi.PlumberWF.ListLatestWorkflowsResponse + ) + + rpc(:Describe, InternalApi.PlumberWF.DescribeRequest, InternalApi.PlumberWF.DescribeResponse) + + rpc( + :DescribeMany, + InternalApi.PlumberWF.DescribeManyRequest, + InternalApi.PlumberWF.DescribeManyResponse + ) + + rpc(:Terminate, InternalApi.PlumberWF.TerminateRequest, InternalApi.PlumberWF.TerminateResponse) + + rpc( + :ListLabels, + InternalApi.PlumberWF.ListLabelsRequest, + InternalApi.PlumberWF.ListLabelsResponse + ) + + rpc( + :Reschedule, + InternalApi.PlumberWF.RescheduleRequest, + InternalApi.PlumberWF.ScheduleResponse + ) + + rpc( + :GetProjectId, + InternalApi.PlumberWF.GetProjectIdRequest, + InternalApi.PlumberWF.GetProjectIdResponse + ) + + rpc(:Create, InternalApi.PlumberWF.CreateRequest, InternalApi.PlumberWF.CreateResponse) end defmodule InternalApi.PlumberWF.WorkflowService.Stub do diff --git a/plumber/proto/lib/internal_api/projecthub.pb.ex b/plumber/proto/lib/internal_api/projecthub.pb.ex index 8cb1ba837..98009d1b6 100644 --- a/plumber/proto/lib/internal_api/projecthub.pb.ex +++ b/plumber/proto/lib/internal_api/projecthub.pb.ex @@ -172,13 +172,17 @@ defmodule InternalApi.Projecthub.Project.Spec do field(:public, 4, type: :bool) field(:visibility, 5, type: InternalApi.Projecthub.Project.Spec.Visibility, enum: true) - field(:debug_permissions, 6, + field( + :debug_permissions, + 6, repeated: true, type: InternalApi.Projecthub.Project.Spec.PermissionType, enum: true ) - field(:attach_permissions, 7, + field( + :attach_permissions, + 7, repeated: true, type: InternalApi.Projecthub.Project.Spec.PermissionType, enum: true @@ -234,13 +238,17 @@ defmodule InternalApi.Projecthub.Project.Spec.Repository do field(:name, 2, type: :string) field(:owner, 3, type: :string) - field(:run_on, 4, + field( + :run_on, + 4, repeated: true, type: InternalApi.Projecthub.Project.Spec.Repository.RunType, enum: true ) - field(:forked_pull_requests, 5, + field( + :forked_pull_requests, + 5, type: InternalApi.Projecthub.Project.Spec.Repository.ForkedPullRequests ) @@ -278,7 +286,9 @@ defmodule InternalApi.Projecthub.Project.Spec.Repository.Status do } defstruct [:pipeline_files] - field(:pipeline_files, 1, + field( + :pipeline_files, + 1, repeated: true, type: InternalApi.Projecthub.Project.Spec.Repository.Status.PipelineFile ) @@ -296,7 +306,9 @@ defmodule InternalApi.Projecthub.Project.Spec.Repository.Status.PipelineFile do field(:path, 1, type: :string) - field(:level, 2, + field( + :level, + 2, type: InternalApi.Projecthub.Project.Spec.Repository.Status.PipelineFile.Level, enum: true ) diff --git a/plumber/proto/lib/internal_api/repository.pb.ex b/plumber/proto/lib/internal_api/repository.pb.ex index 06aa6b023..6284c4e61 100644 --- a/plumber/proto/lib/internal_api/repository.pb.ex +++ b/plumber/proto/lib/internal_api/repository.pb.ex @@ -638,7 +638,9 @@ defmodule InternalApi.Repository.GetChangedFilePathsRequest do field(:base_rev, 2, type: InternalApi.Repository.Revision) field(:repository_id, 3, type: :string) - field(:comparison_type, 4, + field( + :comparison_type, + 4, type: InternalApi.Repository.GetChangedFilePathsRequest.ComparisonType, enum: true ) diff --git a/plumber/proto/lib/internal_api/repository_integrator.pb.ex b/plumber/proto/lib/internal_api/repository_integrator.pb.ex index 6d778f449..5bd2798d7 100644 --- a/plumber/proto/lib/internal_api/repository_integrator.pb.ex +++ b/plumber/proto/lib/internal_api/repository_integrator.pb.ex @@ -54,7 +54,12 @@ defmodule InternalApi.RepositoryIntegrator.CheckTokenResponse do field(:valid, 1, type: :bool) - field(:integration_scope, 2, type: InternalApi.RepositoryIntegrator.IntegrationScope, enum: true) + field( + :integration_scope, + 2, + type: InternalApi.RepositoryIntegrator.IntegrationScope, + enum: true + ) end defmodule InternalApi.RepositoryIntegrator.PreheatFileCacheRequest do diff --git a/plumber/proto/lib/internal_api/task.pb.ex b/plumber/proto/lib/internal_api/task.pb.ex index f81b72496..fae4662ed 100644 --- a/plumber/proto/lib/internal_api/task.pb.ex +++ b/plumber/proto/lib/internal_api/task.pb.ex @@ -218,9 +218,16 @@ defmodule InternalApi.Task.ScheduleRequest.Job.Agent do field(:machine, 1, type: InternalApi.Task.ScheduleRequest.Job.Agent.Machine) - field(:containers, 2, repeated: true, type: InternalApi.Task.ScheduleRequest.Job.Agent.Container) + field( + :containers, + 2, + repeated: true, + type: InternalApi.Task.ScheduleRequest.Job.Agent.Container + ) - field(:image_pull_secrets, 3, + field( + :image_pull_secrets, + 3, repeated: true, type: InternalApi.Task.ScheduleRequest.Job.Agent.ImagePullSecret ) diff --git a/plumber/proto/lib/internal_api/usage.pb.ex b/plumber/proto/lib/internal_api/usage.pb.ex new file mode 100644 index 000000000..b72ab1d74 --- /dev/null +++ b/plumber/proto/lib/internal_api/usage.pb.ex @@ -0,0 +1,358 @@ +defmodule InternalApi.Usage.ListDailyUsageRequest do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + org_id: String.t(), + period_started_at: Google.Protobuf.Timestamp.t(), + period_finished_at: Google.Protobuf.Timestamp.t() + } + defstruct [:org_id, :period_started_at, :period_finished_at] + + field(:org_id, 1, type: :string) + field(:period_started_at, 2, type: Google.Protobuf.Timestamp) + field(:period_finished_at, 3, type: Google.Protobuf.Timestamp) +end + +defmodule InternalApi.Usage.ListDailyUsageResponse do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + status: Google.Rpc.Status.t(), + daily_usages: [InternalApi.Usage.DailyUsage.t()] + } + defstruct [:status, :daily_usages] + + field(:status, 1, type: Google.Rpc.Status) + field(:daily_usages, 2, repeated: true, type: InternalApi.Usage.DailyUsage) +end + +defmodule InternalApi.Usage.DailyUsage do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + resource_usages: [InternalApi.Usage.DailyResourceUsage.t()], + date: Google.Protobuf.Timestamp.t() + } + defstruct [:resource_usages, :date] + + field(:resource_usages, 1, repeated: true, type: InternalApi.Usage.DailyResourceUsage) + field(:date, 2, type: Google.Protobuf.Timestamp) +end + +defmodule InternalApi.Usage.DailyResourceUsage do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + machine_type: String.t(), + minutes_used: integer, + seconds_used: integer + } + defstruct [:machine_type, :minutes_used, :seconds_used] + + field(:machine_type, 1, type: :string) + field(:minutes_used, 2, type: :int32) + field(:seconds_used, 3, type: :int32) +end + +defmodule InternalApi.Usage.ProjectsUsageRequest do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + org_id: String.t(), + period_started_at: Google.Protobuf.Timestamp.t(), + period_finished_at: Google.Protobuf.Timestamp.t() + } + defstruct [:org_id, :period_started_at, :period_finished_at] + + field(:org_id, 1, type: :string) + field(:period_started_at, 2, type: Google.Protobuf.Timestamp) + field(:period_finished_at, 3, type: Google.Protobuf.Timestamp) +end + +defmodule InternalApi.Usage.ProjectsUsageResponse do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + status: Google.Rpc.Status.t(), + project_usages: [InternalApi.Usage.ProjectUsage.t()] + } + defstruct [:status, :project_usages] + + field(:status, 1, type: Google.Rpc.Status) + field(:project_usages, 2, repeated: true, type: InternalApi.Usage.ProjectUsage) +end + +defmodule InternalApi.Usage.ProjectUsage do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + project_id: String.t(), + resource_usages: [InternalApi.Usage.ResourceUsage.t()] + } + defstruct [:project_id, :resource_usages] + + field(:project_id, 1, type: :string) + field(:resource_usages, 2, repeated: true, type: InternalApi.Usage.ResourceUsage) +end + +defmodule InternalApi.Usage.TotalUsageRequest do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + period_started_at: Google.Protobuf.Timestamp.t(), + period_finished_at: Google.Protobuf.Timestamp.t(), + org_id: String.t() + } + defstruct [:period_started_at, :period_finished_at, :org_id] + + field(:period_started_at, 1, type: Google.Protobuf.Timestamp) + field(:period_finished_at, 2, type: Google.Protobuf.Timestamp) + field(:org_id, 3, type: :string) +end + +defmodule InternalApi.Usage.TotalUsageResponse do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + status: Google.Rpc.Status.t(), + resource_usages: [InternalApi.Usage.ResourceUsage.t()] + } + defstruct [:status, :resource_usages] + + field(:status, 1, type: Google.Rpc.Status) + field(:resource_usages, 2, repeated: true, type: InternalApi.Usage.ResourceUsage) +end + +defmodule InternalApi.Usage.TotalMembersUsageRequest do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + org_id: String.t(), + period_started_at: Google.Protobuf.Timestamp.t(), + period_finished_at: Google.Protobuf.Timestamp.t() + } + defstruct [:org_id, :period_started_at, :period_finished_at] + + field(:org_id, 1, type: :string) + field(:period_started_at, 3, type: Google.Protobuf.Timestamp) + field(:period_finished_at, 4, type: Google.Protobuf.Timestamp) +end + +defmodule InternalApi.Usage.TotalMembersUsageResponse do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + members: integer, + requesters: integer + } + defstruct [:members, :requesters] + + field(:members, 1, type: :int32) + field(:requesters, 2, type: :int32) +end + +defmodule InternalApi.Usage.ResourceUsage do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + machine_type: String.t(), + seconds_used: integer + } + defstruct [:machine_type, :seconds_used] + + field(:machine_type, 1, type: :string) + field(:seconds_used, 2, type: :int32) +end + +defmodule InternalApi.Usage.ListQuotaUsageRequest do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + org_id: String.t(), + points: integer, + period_started_at: Google.Protobuf.Timestamp.t(), + period_finished_at: Google.Protobuf.Timestamp.t() + } + defstruct [:org_id, :points, :period_started_at, :period_finished_at] + + field(:org_id, 1, type: :string) + field(:points, 2, type: :int32) + field(:period_started_at, 3, type: Google.Protobuf.Timestamp) + field(:period_finished_at, 4, type: Google.Protobuf.Timestamp) +end + +defmodule InternalApi.Usage.ListQuotaUsageResponse do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + status: Google.Rpc.Status.t(), + usages: [InternalApi.Usage.QuotaUsage.t()] + } + defstruct [:status, :usages] + + field(:status, 1, type: Google.Rpc.Status) + field(:usages, 2, repeated: true, type: InternalApi.Usage.QuotaUsage) +end + +defmodule InternalApi.Usage.QuotaUsage do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + machine_type: String.t(), + points: [InternalApi.Usage.QuotaUsage.Point.t()] + } + defstruct [:machine_type, :points] + + field(:machine_type, 1, type: :string) + field(:points, 2, repeated: true, type: InternalApi.Usage.QuotaUsage.Point) +end + +defmodule InternalApi.Usage.QuotaUsage.Point do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + usage: integer, + date: Google.Protobuf.Timestamp.t() + } + defstruct [:usage, :date] + + field(:usage, 1, type: :int32) + field(:date, 2, type: Google.Protobuf.Timestamp) +end + +defmodule InternalApi.Usage.ListSeatsRequest do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + org_id: String.t(), + from_gte: Google.Protobuf.Timestamp.t(), + to_lt: Google.Protobuf.Timestamp.t() + } + defstruct [:org_id, :from_gte, :to_lt] + + field(:org_id, 1, type: :string) + field(:from_gte, 2, type: Google.Protobuf.Timestamp) + field(:to_lt, 3, type: Google.Protobuf.Timestamp) +end + +defmodule InternalApi.Usage.ListSeatsResponse do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + seats: [InternalApi.Usage.Seat.t()] + } + defstruct [:seats] + + field(:seats, 1, repeated: true, type: InternalApi.Usage.Seat) +end + +defmodule InternalApi.Usage.Seat do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + user_id: String.t(), + display_name: String.t(), + origin: integer, + status: integer, + date: Google.Protobuf.Timestamp.t() + } + defstruct [:user_id, :display_name, :origin, :status, :date] + + field(:user_id, 1, type: :string) + field(:display_name, 2, type: :string) + field(:origin, 3, type: InternalApi.Usage.SeatOrigin, enum: true) + field(:status, 4, type: InternalApi.Usage.SeatStatus, enum: true) + field(:date, 5, type: Google.Protobuf.Timestamp) +end + +defmodule InternalApi.Usage.OrganizationPolicyApply do + @moduledoc false + use Protobuf, syntax: :proto3 + + @type t :: %__MODULE__{ + org_id: String.t(), + cutoff_date: Google.Protobuf.Timestamp.t() + } + defstruct [:org_id, :cutoff_date] + + field(:org_id, 1, type: :string) + field(:cutoff_date, 2, type: Google.Protobuf.Timestamp) +end + +defmodule InternalApi.Usage.SeatOrigin do + @moduledoc false + use Protobuf, enum: true, syntax: :proto3 + + field(:SEAT_ORIGIN_UNSPECIFIED, 0) + field(:SEAT_ORIGIN_SEMAPHORE, 1) + field(:SEAT_ORIGIN_GITHUB, 2) + field(:SEAT_ORIGIN_BITBUCKET, 3) + field(:SEAT_ORIGIN_GITLAB, 4) +end + +defmodule InternalApi.Usage.SeatStatus do + @moduledoc false + use Protobuf, enum: true, syntax: :proto3 + + field(:SEAT_TYPE_UNSPECIFIED, 0) + field(:SEAT_TYPE_ACTIVE_MEMBER, 1) + field(:SEAT_TYPE_NON_ACTIVE_MEMBER, 2) + field(:SEAT_TYPE_NON_MEMBER, 3) +end + +defmodule InternalApi.Usage.UsageService.Service do + @moduledoc false + use GRPC.Service, name: "InternalApi.Usage.UsageService" + + rpc( + :ListDailyUsage, + InternalApi.Usage.ListDailyUsageRequest, + InternalApi.Usage.ListDailyUsageResponse + ) + + rpc( + :ProjectsUsage, + InternalApi.Usage.ProjectsUsageRequest, + InternalApi.Usage.ProjectsUsageResponse + ) + + rpc(:TotalUsage, InternalApi.Usage.TotalUsageRequest, InternalApi.Usage.TotalUsageResponse) + + rpc( + :ListQuotaUsage, + InternalApi.Usage.ListQuotaUsageRequest, + InternalApi.Usage.ListQuotaUsageResponse + ) + + rpc( + :TotalMembersUsage, + InternalApi.Usage.TotalMembersUsageRequest, + InternalApi.Usage.TotalMembersUsageResponse + ) + + rpc(:ListSeats, InternalApi.Usage.ListSeatsRequest, InternalApi.Usage.ListSeatsResponse) +end + +defmodule InternalApi.Usage.UsageService.Stub do + @moduledoc false + use GRPC.Stub, service: InternalApi.Usage.UsageService.Service +end