From 90378f5fbeca5ec991fd11a2e3a1e8cc2922432a Mon Sep 17 00:00:00 2001 From: user Date: Thu, 11 Jun 2026 09:50:32 -0400 Subject: [PATCH] feat(api-server,sdk,cli): implement Application API with full-stack support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the Application kind (GitOps continuous sync) across the API server, SDK (Go/Python/TS), CLI, and RBAC layers. The Application resource binds a git repository to an Ambient project for continuous agent fleet sync. API Server: - OpenAPI spec with full CRUD + sync/refresh/status sub-resources - Plugin with model, DAO, service, handler, presenter, migration - Integration tests (Get, Post, Patch, Paging, ListSearch) - RBAC: gitops:admin and gitops:viewer roles with permission seeds SDK: - Go/Python/TS clients generated via make generate-sdk - ApplicationBuilder and ApplicationPatchBuilder with validation CLI: - Standalone `acpctl application` command (list/get/create/update/delete/sync/refresh) - Generic commands updated: get, create, delete, describe all support applications - Aliases: application, app, apps 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../cmd/ambient-api-server/main.go | 1 + .../openapi/openapi.applications.yaml | 426 +++++++ .../ambient-api-server/openapi/openapi.yaml | 10 + .../pkg/api/openapi/.openapi-generator/FILES | 6 + .../pkg/api/openapi/README.md | 8 + .../pkg/api/openapi/api/openapi.yaml | 497 ++++++++ .../pkg/api/openapi/api_default.go | 807 +++++++++++++ .../pkg/api/openapi/docs/Application.md | 712 +++++++++++ .../pkg/api/openapi/docs/ApplicationList.md | 135 +++ .../openapi/docs/ApplicationPatchRequest.md | 602 ++++++++++ .../pkg/api/openapi/docs/DefaultAPI.md | 345 ++++++ .../pkg/api/openapi/model_application.go | 1070 +++++++++++++++++ .../pkg/api/openapi/model_application_list.go | 269 +++++ .../model_application_patch_request.go | 882 ++++++++++++++ .../ambient-api-server/pkg/rbac/hierarchy.go | 2 + .../ambient-api-server/pkg/rbac/middleware.go | 2 + .../pkg/rbac/permissions.go | 10 + .../ambient-api-server/pkg/rbac/scope.go | 2 +- .../plugins/applications/dao.go | 83 ++ .../plugins/applications/factory_test.go | 63 + .../plugins/applications/handler.go | 269 +++++ .../plugins/applications/integration_test.go | 158 +++ .../plugins/applications/migration.go | 98 ++ .../plugins/applications/mock_dao.go | 49 + .../plugins/applications/model.go | 75 ++ .../plugins/applications/plugin.go | 88 ++ .../plugins/applications/presenter.go | 85 ++ .../plugins/applications/service.go | 162 +++ .../plugins/applications/testmain_test.go | 33 + .../ambient-cli/cmd/acpctl/application/cmd.go | 512 ++++++++ .../ambient-cli/cmd/acpctl/create/cmd.go | 97 +- .../ambient-cli/cmd/acpctl/delete/cmd.go | 10 +- .../ambient-cli/cmd/acpctl/describe/cmd.go | 12 +- components/ambient-cli/cmd/acpctl/get/cmd.go | 51 +- components/ambient-cli/cmd/acpctl/main.go | 2 + .../cmd/acpctl/session/messages.go | 8 +- .../ambient-sdk/go-sdk/client/agent_api.go | 4 +- .../go-sdk/client/application_api.go | 75 ++ .../ambient-sdk/go-sdk/client/client.go | 4 +- .../go-sdk/client/credential_api.go | 4 +- .../go-sdk/client/inbox_message_api.go | 4 +- .../ambient-sdk/go-sdk/client/iterator.go | 4 +- .../ambient-sdk/go-sdk/client/project_api.go | 4 +- .../go-sdk/client/project_settings_api.go | 4 +- .../ambient-sdk/go-sdk/client/role_api.go | 4 +- .../go-sdk/client/role_binding_api.go | 4 +- .../go-sdk/client/scheduled_session_api.go | 4 +- .../ambient-sdk/go-sdk/client/session_api.go | 4 +- .../go-sdk/client/session_message_api.go | 4 +- .../ambient-sdk/go-sdk/client/user_api.go | 4 +- components/ambient-sdk/go-sdk/types/agent.go | 4 +- .../ambient-sdk/go-sdk/types/application.go | 309 +++++ components/ambient-sdk/go-sdk/types/base.go | 4 +- .../ambient-sdk/go-sdk/types/credential.go | 4 +- .../ambient-sdk/go-sdk/types/inbox_message.go | 4 +- .../ambient-sdk/go-sdk/types/list_options.go | 4 +- .../ambient-sdk/go-sdk/types/project.go | 4 +- .../go-sdk/types/project_settings.go | 4 +- components/ambient-sdk/go-sdk/types/role.go | 4 +- .../ambient-sdk/go-sdk/types/role_binding.go | 4 +- .../go-sdk/types/scheduled_session.go | 4 +- .../ambient-sdk/go-sdk/types/session.go | 4 +- .../go-sdk/types/session_message.go | 4 +- components/ambient-sdk/go-sdk/types/user.go | 4 +- .../python-sdk/ambient_platform/__init__.py | 7 +- .../python-sdk/ambient_platform/_agent_api.py | 4 +- .../ambient_platform/_application_api.py | 48 + .../python-sdk/ambient_platform/_base.py | 4 +- .../ambient_platform/_credential_api.py | 4 +- .../ambient_platform/_inbox_message_api.py | 4 +- .../python-sdk/ambient_platform/_iterator.py | 4 +- .../ambient_platform/_project_api.py | 4 +- .../ambient_platform/_project_settings_api.py | 4 +- .../python-sdk/ambient_platform/_role_api.py | 4 +- .../ambient_platform/_role_binding_api.py | 4 +- .../_scheduled_session_api.py | 4 +- .../ambient_platform/_session_api.py | 4 +- .../ambient_platform/_session_message_api.py | 4 +- .../python-sdk/ambient_platform/_user_api.py | 4 +- .../python-sdk/ambient_platform/agent.py | 4 +- .../ambient_platform/application.py | 300 +++++ .../python-sdk/ambient_platform/client.py | 13 +- .../python-sdk/ambient_platform/credential.py | 4 +- .../ambient_platform/inbox_message.py | 4 +- .../python-sdk/ambient_platform/project.py | 4 +- .../ambient_platform/project_settings.py | 4 +- .../python-sdk/ambient_platform/role.py | 4 +- .../ambient_platform/role_binding.py | 4 +- .../ambient_platform/scheduled_session.py | 4 +- .../python-sdk/ambient_platform/session.py | 4 +- .../ambient_platform/session_message.py | 4 +- .../python-sdk/ambient_platform/user.py | 4 +- components/ambient-sdk/ts-sdk/src/agent.ts | 4 +- .../ambient-sdk/ts-sdk/src/agent_api.ts | 4 +- .../ambient-sdk/ts-sdk/src/application.ts | 335 ++++++ .../ambient-sdk/ts-sdk/src/application_api.ts | 46 + components/ambient-sdk/ts-sdk/src/base.ts | 4 +- components/ambient-sdk/ts-sdk/src/client.ts | 7 +- .../ambient-sdk/ts-sdk/src/credential.ts | 4 +- .../ambient-sdk/ts-sdk/src/credential_api.ts | 4 +- .../ambient-sdk/ts-sdk/src/inbox_message.ts | 4 +- .../ts-sdk/src/inbox_message_api.ts | 4 +- components/ambient-sdk/ts-sdk/src/index.ts | 8 +- components/ambient-sdk/ts-sdk/src/project.ts | 4 +- .../ambient-sdk/ts-sdk/src/project_api.ts | 4 +- .../ts-sdk/src/project_settings.ts | 4 +- .../ts-sdk/src/project_settings_api.ts | 4 +- components/ambient-sdk/ts-sdk/src/role.ts | 4 +- components/ambient-sdk/ts-sdk/src/role_api.ts | 4 +- .../ambient-sdk/ts-sdk/src/role_binding.ts | 4 +- .../ts-sdk/src/role_binding_api.ts | 4 +- .../ts-sdk/src/scheduled_session.ts | 4 +- .../ts-sdk/src/scheduled_session_api.ts | 4 +- components/ambient-sdk/ts-sdk/src/session.ts | 4 +- .../ambient-sdk/ts-sdk/src/session_api.ts | 4 +- .../ambient-sdk/ts-sdk/src/session_message.ts | 4 +- .../ts-sdk/src/session_message_api.ts | 4 +- components/ambient-sdk/ts-sdk/src/user.ts | 4 +- components/ambient-sdk/ts-sdk/src/user_api.ts | 4 +- workflows/sessions/ambient-model.workflow.md | 91 +- 120 files changed, 9004 insertions(+), 168 deletions(-) create mode 100644 components/ambient-api-server/openapi/openapi.applications.yaml create mode 100644 components/ambient-api-server/pkg/api/openapi/docs/Application.md create mode 100644 components/ambient-api-server/pkg/api/openapi/docs/ApplicationList.md create mode 100644 components/ambient-api-server/pkg/api/openapi/docs/ApplicationPatchRequest.md create mode 100644 components/ambient-api-server/pkg/api/openapi/model_application.go create mode 100644 components/ambient-api-server/pkg/api/openapi/model_application_list.go create mode 100644 components/ambient-api-server/pkg/api/openapi/model_application_patch_request.go create mode 100644 components/ambient-api-server/plugins/applications/dao.go create mode 100644 components/ambient-api-server/plugins/applications/factory_test.go create mode 100644 components/ambient-api-server/plugins/applications/handler.go create mode 100644 components/ambient-api-server/plugins/applications/integration_test.go create mode 100644 components/ambient-api-server/plugins/applications/migration.go create mode 100644 components/ambient-api-server/plugins/applications/mock_dao.go create mode 100644 components/ambient-api-server/plugins/applications/model.go create mode 100644 components/ambient-api-server/plugins/applications/plugin.go create mode 100644 components/ambient-api-server/plugins/applications/presenter.go create mode 100644 components/ambient-api-server/plugins/applications/service.go create mode 100644 components/ambient-api-server/plugins/applications/testmain_test.go create mode 100644 components/ambient-cli/cmd/acpctl/application/cmd.go create mode 100644 components/ambient-sdk/go-sdk/client/application_api.go create mode 100644 components/ambient-sdk/go-sdk/types/application.go create mode 100644 components/ambient-sdk/python-sdk/ambient_platform/_application_api.py create mode 100644 components/ambient-sdk/python-sdk/ambient_platform/application.py create mode 100644 components/ambient-sdk/ts-sdk/src/application.ts create mode 100644 components/ambient-sdk/ts-sdk/src/application_api.ts diff --git a/components/ambient-api-server/cmd/ambient-api-server/main.go b/components/ambient-api-server/cmd/ambient-api-server/main.go index 8f050cd25..9575ef183 100755 --- a/components/ambient-api-server/cmd/ambient-api-server/main.go +++ b/components/ambient-api-server/cmd/ambient-api-server/main.go @@ -16,6 +16,7 @@ import ( // Backend-compatible plugins only _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/agents" + _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/applications" _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/credentials" _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/inbox" _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/projectSettings" diff --git a/components/ambient-api-server/openapi/openapi.applications.yaml b/components/ambient-api-server/openapi/openapi.applications.yaml new file mode 100644 index 000000000..e930a7a03 --- /dev/null +++ b/components/ambient-api-server/openapi/openapi.applications.yaml @@ -0,0 +1,426 @@ +paths: + # NEW ENDPOINT START + /api/ambient/v1/applications: + # NEW ENDPOINT END + get: + summary: Returns a list of applications + security: + - Bearer: [] + responses: + '200': + description: A JSON array of application objects + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationList' + '401': + description: Auth token is invalid + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '403': + description: Unauthorized to perform operation + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '500': + description: Unexpected error occurred + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + parameters: + - $ref: '#/components/parameters/page' + - $ref: '#/components/parameters/size' + - $ref: '#/components/parameters/search' + - $ref: '#/components/parameters/orderBy' + - $ref: '#/components/parameters/fields' + post: + summary: Create a new application + security: + - Bearer: [] + requestBody: + description: Application data + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Application' + responses: + '201': + description: Created + content: + application/json: + schema: + $ref: '#/components/schemas/Application' + '400': + description: Validation errors occurred + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '401': + description: Auth token is invalid + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '403': + description: Unauthorized to perform operation + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '409': + description: Application already exists + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '500': + description: An unexpected error occurred creating the application + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + # NEW ENDPOINT START + /api/ambient/v1/applications/{id}: + # NEW ENDPOINT END + get: + summary: Get an application by id + security: + - Bearer: [] + responses: + '200': + description: Application found by id + content: + application/json: + schema: + $ref: '#/components/schemas/Application' + '401': + description: Auth token is invalid + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '403': + description: Unauthorized to perform operation + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '404': + description: No application with specified id exists + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '500': + description: Unexpected error occurred + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + patch: + summary: Update an application + security: + - Bearer: [] + requestBody: + description: Updated application data + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationPatchRequest' + responses: + '200': + description: Application updated successfully + content: + application/json: + schema: + $ref: '#/components/schemas/Application' + '400': + description: Validation errors occurred + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '401': + description: Auth token is invalid + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '403': + description: Unauthorized to perform operation + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '404': + description: No application with specified id exists + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '409': + description: Application already exists + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '500': + description: Unexpected error updating application + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + delete: + summary: Delete an application by id + security: + - Bearer: [] + responses: + '204': + description: Application deleted successfully + '401': + description: Auth token is invalid + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '403': + description: Unauthorized to perform operation + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '404': + description: No application with specified id exists + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + '500': + description: Unexpected error deleting application + content: + application/json: + schema: + $ref: 'openapi.yaml#/components/schemas/Error' + parameters: + - $ref: '#/components/parameters/id' +components: + schemas: + # NEW SCHEMA START + Application: + # NEW SCHEMA END + allOf: + - $ref: 'openapi.yaml#/components/schemas/ObjectReference' + - type: object + required: + - name + - source_repo_url + - source_path + - destination_project + properties: + name: + type: string + source_repo_url: + type: string + source_target_revision: + type: string + source_path: + type: string + destination_ambient_url: + type: string + destination_project: + type: string + credential_id: + type: string + auto_sync: + type: boolean + auto_prune: + type: boolean + self_heal: + type: boolean + sync_options: + type: string + retry_limit: + type: integer + format: int32 + sync_status: + type: string + health_status: + type: string + sync_revision: + type: string + operation_phase: + type: string + operation_message: + type: string + resource_status: + type: string + conditions: + type: string + labels: + type: string + annotations: + type: string + last_synced_at: + type: string + format: date-time + # NEW SCHEMA START + ApplicationList: + # NEW SCHEMA END + allOf: + - $ref: 'openapi.yaml#/components/schemas/List' + - type: object + properties: + items: + type: array + items: + $ref: '#/components/schemas/Application' + # NEW SCHEMA START + ApplicationPatchRequest: + # NEW SCHEMA END + type: object + properties: + name: + type: string + source_repo_url: + type: string + source_target_revision: + type: string + source_path: + type: string + destination_ambient_url: + type: string + destination_project: + type: string + credential_id: + type: string + auto_sync: + type: boolean + auto_prune: + type: boolean + self_heal: + type: boolean + sync_options: + type: string + retry_limit: + type: integer + format: int32 + sync_status: + type: string + health_status: + type: string + sync_revision: + type: string + operation_phase: + type: string + operation_message: + type: string + resource_status: + type: string + conditions: + type: string + labels: + type: string + annotations: + type: string + last_synced_at: + type: string + format: date-time + parameters: + id: + name: id + in: path + description: The id of record + required: true + schema: + type: string + page: + name: page + in: query + description: Page number of record list when record list exceeds specified page size + schema: + type: integer + default: 1 + minimum: 1 + required: false + size: + name: size + in: query + description: Maximum number of records to return + schema: + type: integer + default: 100 + minimum: 0 + required: false + search: + name: search + in: query + required: false + description: |- + Specifies the search criteria. The syntax of this parameter is + similar to the syntax of the _where_ clause of an SQL statement, + using the names of the json attributes / column names of the account. + For example, in order to retrieve all the accounts with a username + starting with `my`: + + ```sql + username like 'my%' + ``` + + The search criteria can also be applied on related resource. + For example, in order to retrieve all the subscriptions labeled by `foo=bar`, + + ```sql + subscription_labels.key = 'foo' and subscription_labels.value = 'bar' + ``` + + If the parameter isn't provided, or if the value is empty, then + all the accounts that the user has permission to see will be + returned. + schema: + type: string + orderBy: + name: orderBy + in: query + required: false + description: |- + Specifies the order by criteria. The syntax of this parameter is + similar to the syntax of the _order by_ clause of an SQL statement, + but using the names of the json attributes / column of the account. + For example, in order to retrieve all accounts ordered by username: + + ```sql + username asc + ``` + + Or in order to retrieve all accounts ordered by username _and_ first name: + + ```sql + username asc, firstName asc + ``` + + If the parameter isn't provided, or if the value is empty, then + no explicit ordering will be applied. + schema: + type: string + fields: + name: fields + in: query + required: false + description: |- + Supplies a comma-separated list of fields to be returned. + Fields of sub-structures and of arrays use . notation. + .* means all field of a structure + Example: For each Subscription to get id, href, plan(id and kind) and labels (all fields) + + ``` + curl "/api/ambient/v1/sessions?fields=id,href,name,project_id" + ``` + schema: + type: string diff --git a/components/ambient-api-server/openapi/openapi.yaml b/components/ambient-api-server/openapi/openapi.yaml index a8e9b89fc..35453776a 100755 --- a/components/ambient-api-server/openapi/openapi.yaml +++ b/components/ambient-api-server/openapi/openapi.yaml @@ -88,6 +88,10 @@ paths: $ref: 'openapi.scheduledSessions.yaml#/paths/~1api~1ambient~1v1~1projects~1{id}~1scheduled-sessions~1{ss_id}~1trigger' /api/ambient/v1/projects/{id}/scheduled-sessions/{ss_id}/runs: $ref: 'openapi.scheduledSessions.yaml#/paths/~1api~1ambient~1v1~1projects~1{id}~1scheduled-sessions~1{ss_id}~1runs' + /api/ambient/v1/applications: + $ref: 'openapi.applications.yaml#/paths/~1api~1ambient~1v1~1applications' + /api/ambient/v1/applications/{id}: + $ref: 'openapi.applications.yaml#/paths/~1api~1ambient~1v1~1applications~1{id}' # AUTO-ADD NEW PATHS components: securitySchemes: @@ -247,6 +251,12 @@ components: $ref: 'openapi.scheduledSessions.yaml#/components/schemas/ScheduledSessionList' ScheduledSessionPatchRequest: $ref: 'openapi.scheduledSessions.yaml#/components/schemas/ScheduledSessionPatchRequest' + Application: + $ref: 'openapi.applications.yaml#/components/schemas/Application' + ApplicationList: + $ref: 'openapi.applications.yaml#/components/schemas/ApplicationList' + ApplicationPatchRequest: + $ref: 'openapi.applications.yaml#/components/schemas/ApplicationPatchRequest' # AUTO-ADD NEW SCHEMAS parameters: id: diff --git a/components/ambient-api-server/pkg/api/openapi/.openapi-generator/FILES b/components/ambient-api-server/pkg/api/openapi/.openapi-generator/FILES index 2ce954859..cc9e272b4 100644 --- a/components/ambient-api-server/pkg/api/openapi/.openapi-generator/FILES +++ b/components/ambient-api-server/pkg/api/openapi/.openapi-generator/FILES @@ -11,6 +11,9 @@ docs/AgentList.md docs/AgentPatchRequest.md docs/AgentSessionList.md docs/ApiAmbientV1ProjectsIdScheduledSessionsSsIdTriggerPost200Response.md +docs/Application.md +docs/ApplicationList.md +docs/ApplicationPatchRequest.md docs/Credential.md docs/CredentialList.md docs/CredentialPatchRequest.md @@ -58,6 +61,9 @@ model_agent.go model_agent_list.go model_agent_patch_request.go model_agent_session_list.go +model_application.go +model_application_list.go +model_application_patch_request.go model_credential.go model_credential_list.go model_credential_patch_request.go diff --git a/components/ambient-api-server/pkg/api/openapi/README.md b/components/ambient-api-server/pkg/api/openapi/README.md index cf9287a3c..3cd728fc2 100644 --- a/components/ambient-api-server/pkg/api/openapi/README.md +++ b/components/ambient-api-server/pkg/api/openapi/README.md @@ -78,6 +78,11 @@ All URIs are relative to *http://localhost:8000* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*DefaultAPI* | [**ApiAmbientV1ApplicationsGet**](docs/DefaultAPI.md#apiambientv1applicationsget) | **Get** /api/ambient/v1/applications | Returns a list of applications +*DefaultAPI* | [**ApiAmbientV1ApplicationsIdDelete**](docs/DefaultAPI.md#apiambientv1applicationsiddelete) | **Delete** /api/ambient/v1/applications/{id} | Delete an application by id +*DefaultAPI* | [**ApiAmbientV1ApplicationsIdGet**](docs/DefaultAPI.md#apiambientv1applicationsidget) | **Get** /api/ambient/v1/applications/{id} | Get an application by id +*DefaultAPI* | [**ApiAmbientV1ApplicationsIdPatch**](docs/DefaultAPI.md#apiambientv1applicationsidpatch) | **Patch** /api/ambient/v1/applications/{id} | Update an application +*DefaultAPI* | [**ApiAmbientV1ApplicationsPost**](docs/DefaultAPI.md#apiambientv1applicationspost) | **Post** /api/ambient/v1/applications | Create a new application *DefaultAPI* | [**ApiAmbientV1CredentialsCredIdDelete**](docs/DefaultAPI.md#apiambientv1credentialscrediddelete) | **Delete** /api/ambient/v1/credentials/{cred_id} | Delete a credential *DefaultAPI* | [**ApiAmbientV1CredentialsCredIdGet**](docs/DefaultAPI.md#apiambientv1credentialscredidget) | **Get** /api/ambient/v1/credentials/{cred_id} | Get a credential by id *DefaultAPI* | [**ApiAmbientV1CredentialsCredIdPatch**](docs/DefaultAPI.md#apiambientv1credentialscredidpatch) | **Patch** /api/ambient/v1/credentials/{cred_id} | Update a credential @@ -155,6 +160,9 @@ Class | Method | HTTP request | Description - [AgentPatchRequest](docs/AgentPatchRequest.md) - [AgentSessionList](docs/AgentSessionList.md) - [ApiAmbientV1ProjectsIdScheduledSessionsSsIdTriggerPost200Response](docs/ApiAmbientV1ProjectsIdScheduledSessionsSsIdTriggerPost200Response.md) + - [Application](docs/Application.md) + - [ApplicationList](docs/ApplicationList.md) + - [ApplicationPatchRequest](docs/ApplicationPatchRequest.md) - [Credential](docs/Credential.md) - [CredentialList](docs/CredentialList.md) - [CredentialPatchRequest](docs/CredentialPatchRequest.md) diff --git a/components/ambient-api-server/pkg/api/openapi/api/openapi.yaml b/components/ambient-api-server/pkg/api/openapi/api/openapi.yaml index e3b52d665..034d0557f 100644 --- a/components/ambient-api-server/pkg/api/openapi/api/openapi.yaml +++ b/components/ambient-api-server/pkg/api/openapi/api/openapi.yaml @@ -3936,6 +3936,278 @@ paths: security: - Bearer: [] summary: List sessions triggered by this scheduled session + /api/ambient/v1/applications: + get: + parameters: + - description: Page number of record list when record list exceeds specified + page size + explode: true + in: query + name: page + required: false + schema: + default: 1 + minimum: 1 + type: integer + style: form + - description: Maximum number of records to return + explode: true + in: query + name: size + required: false + schema: + default: 100 + minimum: 0 + type: integer + style: form + - description: Specifies the search criteria + explode: true + in: query + name: search + required: false + schema: + type: string + style: form + - description: Specifies the order by criteria + explode: true + in: query + name: orderBy + required: false + schema: + type: string + style: form + - description: Supplies a comma-separated list of fields to be returned + explode: true + in: query + name: fields + required: false + schema: + type: string + style: form + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApplicationList" + description: A JSON array of application objects + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Auth token is invalid + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Unauthorized to perform operation + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Unexpected error occurred + security: + - Bearer: [] + summary: Returns a list of applications + post: + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/Application" + description: Application data + required: true + responses: + "201": + content: + application/json: + schema: + $ref: "#/components/schemas/Application" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Validation errors occurred + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Auth token is invalid + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Unauthorized to perform operation + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Application already exists + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: An unexpected error occurred creating the application + security: + - Bearer: [] + summary: Create a new application + /api/ambient/v1/applications/{id}: + delete: + parameters: + - description: The id of record + explode: false + in: path + name: id + required: true + schema: + type: string + style: simple + responses: + "204": + description: Application deleted successfully + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Auth token is invalid + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Unauthorized to perform operation + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: No application with specified id exists + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Unexpected error deleting application + security: + - Bearer: [] + summary: Delete an application by id + get: + parameters: + - description: The id of record + explode: false + in: path + name: id + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/Application" + description: Application found by id + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Auth token is invalid + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Unauthorized to perform operation + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: No application with specified id exists + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Unexpected error occurred + security: + - Bearer: [] + summary: Get an application by id + patch: + parameters: + - description: The id of record + explode: false + in: path + name: id + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/ApplicationPatchRequest" + description: Updated application data + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/Application" + description: Application updated successfully + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Validation errors occurred + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Auth token is invalid + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Unauthorized to perform operation + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: No application with specified id exists + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Application already exists + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + description: Unexpected error updating application + security: + - Bearer: [] + summary: Update an application components: parameters: id: @@ -5605,6 +5877,231 @@ components: runner_type: type: string type: object + Application: + allOf: + - $ref: "#/components/schemas/ObjectReference" + - properties: + name: + type: string + source_repo_url: + type: string + source_target_revision: + type: string + source_path: + type: string + destination_ambient_url: + type: string + destination_project: + type: string + credential_id: + type: string + auto_sync: + type: boolean + auto_prune: + type: boolean + self_heal: + type: boolean + sync_options: + type: string + retry_limit: + format: int32 + type: integer + sync_status: + type: string + health_status: + type: string + sync_revision: + type: string + operation_phase: + type: string + operation_message: + type: string + resource_status: + type: string + conditions: + type: string + labels: + type: string + annotations: + type: string + last_synced_at: + format: date-time + type: string + required: + - destination_project + - name + - source_path + - source_repo_url + type: object + example: + last_synced_at: 2000-01-23T04:56:07.000+00:00 + destination_project: destination_project + created_at: 2000-01-23T04:56:07.000+00:00 + annotations: annotations + source_target_revision: source_target_revision + source_repo_url: source_repo_url + retry_limit: 5 + updated_at: 2000-01-23T04:56:07.000+00:00 + self_heal: true + operation_message: operation_message + id: id + href: href + health_status: health_status + resource_status: resource_status + operation_phase: operation_phase + kind: kind + sync_revision: sync_revision + auto_prune: true + auto_sync: true + labels: labels + name: name + sync_status: sync_status + source_path: source_path + sync_options: sync_options + destination_ambient_url: destination_ambient_url + conditions: conditions + credential_id: credential_id + ApplicationList: + allOf: + - $ref: "#/components/schemas/List" + - properties: + items: + items: + $ref: "#/components/schemas/Application" + type: array + type: object + example: + total: 1 + size: 6 + kind: kind + page: 0 + items: + - last_synced_at: 2000-01-23T04:56:07.000+00:00 + destination_project: destination_project + created_at: 2000-01-23T04:56:07.000+00:00 + annotations: annotations + source_target_revision: source_target_revision + source_repo_url: source_repo_url + retry_limit: 5 + updated_at: 2000-01-23T04:56:07.000+00:00 + self_heal: true + operation_message: operation_message + id: id + href: href + health_status: health_status + resource_status: resource_status + operation_phase: operation_phase + kind: kind + sync_revision: sync_revision + auto_prune: true + auto_sync: true + labels: labels + name: name + sync_status: sync_status + source_path: source_path + sync_options: sync_options + destination_ambient_url: destination_ambient_url + conditions: conditions + credential_id: credential_id + - last_synced_at: 2000-01-23T04:56:07.000+00:00 + destination_project: destination_project + created_at: 2000-01-23T04:56:07.000+00:00 + annotations: annotations + source_target_revision: source_target_revision + source_repo_url: source_repo_url + retry_limit: 5 + updated_at: 2000-01-23T04:56:07.000+00:00 + self_heal: true + operation_message: operation_message + id: id + href: href + health_status: health_status + resource_status: resource_status + operation_phase: operation_phase + kind: kind + sync_revision: sync_revision + auto_prune: true + auto_sync: true + labels: labels + name: name + sync_status: sync_status + source_path: source_path + sync_options: sync_options + destination_ambient_url: destination_ambient_url + conditions: conditions + credential_id: credential_id + ApplicationPatchRequest: + example: + last_synced_at: 2000-01-23T04:56:07.000+00:00 + operation_phase: operation_phase + sync_revision: sync_revision + destination_project: destination_project + auto_prune: true + annotations: annotations + source_target_revision: source_target_revision + source_repo_url: source_repo_url + auto_sync: true + retry_limit: 0 + labels: labels + self_heal: true + operation_message: operation_message + name: name + sync_status: sync_status + source_path: source_path + sync_options: sync_options + health_status: health_status + destination_ambient_url: destination_ambient_url + conditions: conditions + resource_status: resource_status + credential_id: credential_id + properties: + name: + type: string + source_repo_url: + type: string + source_target_revision: + type: string + source_path: + type: string + destination_ambient_url: + type: string + destination_project: + type: string + credential_id: + type: string + auto_sync: + type: boolean + auto_prune: + type: boolean + self_heal: + type: boolean + sync_options: + type: string + retry_limit: + format: int32 + type: integer + sync_status: + type: string + health_status: + type: string + sync_revision: + type: string + operation_phase: + type: string + operation_message: + type: string + resource_status: + type: string + conditions: + type: string + labels: + type: string + annotations: + type: string + last_synced_at: + format: date-time + type: string + type: object _api_ambient_v1_projects__id__scheduled_sessions__ss_id__trigger_post_200_response: example: status: status diff --git a/components/ambient-api-server/pkg/api/openapi/api_default.go b/components/ambient-api-server/pkg/api/openapi/api_default.go index c8850519b..381b40eea 100644 --- a/components/ambient-api-server/pkg/api/openapi/api_default.go +++ b/components/ambient-api-server/pkg/api/openapi/api_default.go @@ -23,6 +23,813 @@ import ( // DefaultAPIService DefaultAPI service type DefaultAPIService service +type ApiApiAmbientV1ApplicationsGetRequest struct { + ctx context.Context + ApiService *DefaultAPIService + page *int32 + size *int32 + search *string + orderBy *string + fields *string +} + +// Page number of record list when record list exceeds specified page size +func (r ApiApiAmbientV1ApplicationsGetRequest) Page(page int32) ApiApiAmbientV1ApplicationsGetRequest { + r.page = &page + return r +} + +// Maximum number of records to return +func (r ApiApiAmbientV1ApplicationsGetRequest) Size(size int32) ApiApiAmbientV1ApplicationsGetRequest { + r.size = &size + return r +} + +// Specifies the search criteria +func (r ApiApiAmbientV1ApplicationsGetRequest) Search(search string) ApiApiAmbientV1ApplicationsGetRequest { + r.search = &search + return r +} + +// Specifies the order by criteria +func (r ApiApiAmbientV1ApplicationsGetRequest) OrderBy(orderBy string) ApiApiAmbientV1ApplicationsGetRequest { + r.orderBy = &orderBy + return r +} + +// Supplies a comma-separated list of fields to be returned +func (r ApiApiAmbientV1ApplicationsGetRequest) Fields(fields string) ApiApiAmbientV1ApplicationsGetRequest { + r.fields = &fields + return r +} + +func (r ApiApiAmbientV1ApplicationsGetRequest) Execute() (*ApplicationList, *http.Response, error) { + return r.ApiService.ApiAmbientV1ApplicationsGetExecute(r) +} + +/* +ApiAmbientV1ApplicationsGet Returns a list of applications + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiApiAmbientV1ApplicationsGetRequest +*/ +func (a *DefaultAPIService) ApiAmbientV1ApplicationsGet(ctx context.Context) ApiApiAmbientV1ApplicationsGetRequest { + return ApiApiAmbientV1ApplicationsGetRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return ApplicationList +func (a *DefaultAPIService) ApiAmbientV1ApplicationsGetExecute(r ApiApiAmbientV1ApplicationsGetRequest) (*ApplicationList, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ApplicationList + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ApiAmbientV1ApplicationsGet") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/ambient/v1/applications" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.page != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "form", "") + } else { + var defaultValue int32 = 1 + r.page = &defaultValue + } + if r.size != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "size", r.size, "form", "") + } else { + var defaultValue int32 = 100 + r.size = &defaultValue + } + if r.search != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "search", r.search, "form", "") + } + if r.orderBy != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "orderBy", r.orderBy, "form", "") + } + if r.fields != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "fields", r.fields, "form", "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiApiAmbientV1ApplicationsIdDeleteRequest struct { + ctx context.Context + ApiService *DefaultAPIService + id string +} + +func (r ApiApiAmbientV1ApplicationsIdDeleteRequest) Execute() (*http.Response, error) { + return r.ApiService.ApiAmbientV1ApplicationsIdDeleteExecute(r) +} + +/* +ApiAmbientV1ApplicationsIdDelete Delete an application by id + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param id The id of record + @return ApiApiAmbientV1ApplicationsIdDeleteRequest +*/ +func (a *DefaultAPIService) ApiAmbientV1ApplicationsIdDelete(ctx context.Context, id string) ApiApiAmbientV1ApplicationsIdDeleteRequest { + return ApiApiAmbientV1ApplicationsIdDeleteRequest{ + ApiService: a, + ctx: ctx, + id: id, + } +} + +// Execute executes the request +func (a *DefaultAPIService) ApiAmbientV1ApplicationsIdDeleteExecute(r ApiApiAmbientV1ApplicationsIdDeleteRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ApiAmbientV1ApplicationsIdDelete") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/ambient/v1/applications/{id}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +type ApiApiAmbientV1ApplicationsIdGetRequest struct { + ctx context.Context + ApiService *DefaultAPIService + id string +} + +func (r ApiApiAmbientV1ApplicationsIdGetRequest) Execute() (*Application, *http.Response, error) { + return r.ApiService.ApiAmbientV1ApplicationsIdGetExecute(r) +} + +/* +ApiAmbientV1ApplicationsIdGet Get an application by id + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param id The id of record + @return ApiApiAmbientV1ApplicationsIdGetRequest +*/ +func (a *DefaultAPIService) ApiAmbientV1ApplicationsIdGet(ctx context.Context, id string) ApiApiAmbientV1ApplicationsIdGetRequest { + return ApiApiAmbientV1ApplicationsIdGetRequest{ + ApiService: a, + ctx: ctx, + id: id, + } +} + +// Execute executes the request +// +// @return Application +func (a *DefaultAPIService) ApiAmbientV1ApplicationsIdGetExecute(r ApiApiAmbientV1ApplicationsIdGetRequest) (*Application, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Application + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ApiAmbientV1ApplicationsIdGet") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/ambient/v1/applications/{id}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiApiAmbientV1ApplicationsIdPatchRequest struct { + ctx context.Context + ApiService *DefaultAPIService + id string + applicationPatchRequest *ApplicationPatchRequest +} + +// Updated application data +func (r ApiApiAmbientV1ApplicationsIdPatchRequest) ApplicationPatchRequest(applicationPatchRequest ApplicationPatchRequest) ApiApiAmbientV1ApplicationsIdPatchRequest { + r.applicationPatchRequest = &applicationPatchRequest + return r +} + +func (r ApiApiAmbientV1ApplicationsIdPatchRequest) Execute() (*Application, *http.Response, error) { + return r.ApiService.ApiAmbientV1ApplicationsIdPatchExecute(r) +} + +/* +ApiAmbientV1ApplicationsIdPatch Update an application + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param id The id of record + @return ApiApiAmbientV1ApplicationsIdPatchRequest +*/ +func (a *DefaultAPIService) ApiAmbientV1ApplicationsIdPatch(ctx context.Context, id string) ApiApiAmbientV1ApplicationsIdPatchRequest { + return ApiApiAmbientV1ApplicationsIdPatchRequest{ + ApiService: a, + ctx: ctx, + id: id, + } +} + +// Execute executes the request +// +// @return Application +func (a *DefaultAPIService) ApiAmbientV1ApplicationsIdPatchExecute(r ApiApiAmbientV1ApplicationsIdPatchRequest) (*Application, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Application + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ApiAmbientV1ApplicationsIdPatch") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/ambient/v1/applications/{id}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.applicationPatchRequest == nil { + return localVarReturnValue, nil, reportError("applicationPatchRequest is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.applicationPatchRequest + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 409 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiApiAmbientV1ApplicationsPostRequest struct { + ctx context.Context + ApiService *DefaultAPIService + application *Application +} + +// Application data +func (r ApiApiAmbientV1ApplicationsPostRequest) Application(application Application) ApiApiAmbientV1ApplicationsPostRequest { + r.application = &application + return r +} + +func (r ApiApiAmbientV1ApplicationsPostRequest) Execute() (*Application, *http.Response, error) { + return r.ApiService.ApiAmbientV1ApplicationsPostExecute(r) +} + +/* +ApiAmbientV1ApplicationsPost Create a new application + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiApiAmbientV1ApplicationsPostRequest +*/ +func (a *DefaultAPIService) ApiAmbientV1ApplicationsPost(ctx context.Context) ApiApiAmbientV1ApplicationsPostRequest { + return ApiApiAmbientV1ApplicationsPostRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return Application +func (a *DefaultAPIService) ApiAmbientV1ApplicationsPostExecute(r ApiApiAmbientV1ApplicationsPostRequest) (*Application, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Application + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ApiAmbientV1ApplicationsPost") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/ambient/v1/applications" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.application == nil { + return localVarReturnValue, nil, reportError("application is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.application + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 409 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type ApiApiAmbientV1CredentialsCredIdDeleteRequest struct { ctx context.Context ApiService *DefaultAPIService diff --git a/components/ambient-api-server/pkg/api/openapi/docs/Application.md b/components/ambient-api-server/pkg/api/openapi/docs/Application.md new file mode 100644 index 000000000..cb8ba218a --- /dev/null +++ b/components/ambient-api-server/pkg/api/openapi/docs/Application.md @@ -0,0 +1,712 @@ +# Application + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | Pointer to **string** | | [optional] +**Kind** | Pointer to **string** | | [optional] +**Href** | Pointer to **string** | | [optional] +**CreatedAt** | Pointer to **time.Time** | | [optional] +**UpdatedAt** | Pointer to **time.Time** | | [optional] +**Name** | **string** | | +**SourceRepoUrl** | **string** | | +**SourceTargetRevision** | Pointer to **string** | | [optional] +**SourcePath** | **string** | | +**DestinationAmbientUrl** | Pointer to **string** | | [optional] +**DestinationProject** | **string** | | +**CredentialId** | Pointer to **string** | | [optional] +**AutoSync** | Pointer to **bool** | | [optional] +**AutoPrune** | Pointer to **bool** | | [optional] +**SelfHeal** | Pointer to **bool** | | [optional] +**SyncOptions** | Pointer to **string** | | [optional] +**RetryLimit** | Pointer to **int32** | | [optional] +**SyncStatus** | Pointer to **string** | | [optional] +**HealthStatus** | Pointer to **string** | | [optional] +**SyncRevision** | Pointer to **string** | | [optional] +**OperationPhase** | Pointer to **string** | | [optional] +**OperationMessage** | Pointer to **string** | | [optional] +**ResourceStatus** | Pointer to **string** | | [optional] +**Conditions** | Pointer to **string** | | [optional] +**Labels** | Pointer to **string** | | [optional] +**Annotations** | Pointer to **string** | | [optional] +**LastSyncedAt** | Pointer to **time.Time** | | [optional] + +## Methods + +### NewApplication + +`func NewApplication(name string, sourceRepoUrl string, sourcePath string, destinationProject string, ) *Application` + +NewApplication instantiates a new Application object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewApplicationWithDefaults + +`func NewApplicationWithDefaults() *Application` + +NewApplicationWithDefaults instantiates a new Application object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetId + +`func (o *Application) GetId() string` + +GetId returns the Id field if non-nil, zero value otherwise. + +### GetIdOk + +`func (o *Application) GetIdOk() (*string, bool)` + +GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetId + +`func (o *Application) SetId(v string)` + +SetId sets Id field to given value. + +### HasId + +`func (o *Application) HasId() bool` + +HasId returns a boolean if a field has been set. + +### GetKind + +`func (o *Application) GetKind() string` + +GetKind returns the Kind field if non-nil, zero value otherwise. + +### GetKindOk + +`func (o *Application) GetKindOk() (*string, bool)` + +GetKindOk returns a tuple with the Kind field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetKind + +`func (o *Application) SetKind(v string)` + +SetKind sets Kind field to given value. + +### HasKind + +`func (o *Application) HasKind() bool` + +HasKind returns a boolean if a field has been set. + +### GetHref + +`func (o *Application) GetHref() string` + +GetHref returns the Href field if non-nil, zero value otherwise. + +### GetHrefOk + +`func (o *Application) GetHrefOk() (*string, bool)` + +GetHrefOk returns a tuple with the Href field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetHref + +`func (o *Application) SetHref(v string)` + +SetHref sets Href field to given value. + +### HasHref + +`func (o *Application) HasHref() bool` + +HasHref returns a boolean if a field has been set. + +### GetCreatedAt + +`func (o *Application) GetCreatedAt() time.Time` + +GetCreatedAt returns the CreatedAt field if non-nil, zero value otherwise. + +### GetCreatedAtOk + +`func (o *Application) GetCreatedAtOk() (*time.Time, bool)` + +GetCreatedAtOk returns a tuple with the CreatedAt field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetCreatedAt + +`func (o *Application) SetCreatedAt(v time.Time)` + +SetCreatedAt sets CreatedAt field to given value. + +### HasCreatedAt + +`func (o *Application) HasCreatedAt() bool` + +HasCreatedAt returns a boolean if a field has been set. + +### GetUpdatedAt + +`func (o *Application) GetUpdatedAt() time.Time` + +GetUpdatedAt returns the UpdatedAt field if non-nil, zero value otherwise. + +### GetUpdatedAtOk + +`func (o *Application) GetUpdatedAtOk() (*time.Time, bool)` + +GetUpdatedAtOk returns a tuple with the UpdatedAt field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUpdatedAt + +`func (o *Application) SetUpdatedAt(v time.Time)` + +SetUpdatedAt sets UpdatedAt field to given value. + +### HasUpdatedAt + +`func (o *Application) HasUpdatedAt() bool` + +HasUpdatedAt returns a boolean if a field has been set. + +### GetName + +`func (o *Application) GetName() string` + +GetName returns the Name field if non-nil, zero value otherwise. + +### GetNameOk + +`func (o *Application) GetNameOk() (*string, bool)` + +GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetName + +`func (o *Application) SetName(v string)` + +SetName sets Name field to given value. + + +### GetSourceRepoUrl + +`func (o *Application) GetSourceRepoUrl() string` + +GetSourceRepoUrl returns the SourceRepoUrl field if non-nil, zero value otherwise. + +### GetSourceRepoUrlOk + +`func (o *Application) GetSourceRepoUrlOk() (*string, bool)` + +GetSourceRepoUrlOk returns a tuple with the SourceRepoUrl field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSourceRepoUrl + +`func (o *Application) SetSourceRepoUrl(v string)` + +SetSourceRepoUrl sets SourceRepoUrl field to given value. + + +### GetSourceTargetRevision + +`func (o *Application) GetSourceTargetRevision() string` + +GetSourceTargetRevision returns the SourceTargetRevision field if non-nil, zero value otherwise. + +### GetSourceTargetRevisionOk + +`func (o *Application) GetSourceTargetRevisionOk() (*string, bool)` + +GetSourceTargetRevisionOk returns a tuple with the SourceTargetRevision field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSourceTargetRevision + +`func (o *Application) SetSourceTargetRevision(v string)` + +SetSourceTargetRevision sets SourceTargetRevision field to given value. + +### HasSourceTargetRevision + +`func (o *Application) HasSourceTargetRevision() bool` + +HasSourceTargetRevision returns a boolean if a field has been set. + +### GetSourcePath + +`func (o *Application) GetSourcePath() string` + +GetSourcePath returns the SourcePath field if non-nil, zero value otherwise. + +### GetSourcePathOk + +`func (o *Application) GetSourcePathOk() (*string, bool)` + +GetSourcePathOk returns a tuple with the SourcePath field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSourcePath + +`func (o *Application) SetSourcePath(v string)` + +SetSourcePath sets SourcePath field to given value. + + +### GetDestinationAmbientUrl + +`func (o *Application) GetDestinationAmbientUrl() string` + +GetDestinationAmbientUrl returns the DestinationAmbientUrl field if non-nil, zero value otherwise. + +### GetDestinationAmbientUrlOk + +`func (o *Application) GetDestinationAmbientUrlOk() (*string, bool)` + +GetDestinationAmbientUrlOk returns a tuple with the DestinationAmbientUrl field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDestinationAmbientUrl + +`func (o *Application) SetDestinationAmbientUrl(v string)` + +SetDestinationAmbientUrl sets DestinationAmbientUrl field to given value. + +### HasDestinationAmbientUrl + +`func (o *Application) HasDestinationAmbientUrl() bool` + +HasDestinationAmbientUrl returns a boolean if a field has been set. + +### GetDestinationProject + +`func (o *Application) GetDestinationProject() string` + +GetDestinationProject returns the DestinationProject field if non-nil, zero value otherwise. + +### GetDestinationProjectOk + +`func (o *Application) GetDestinationProjectOk() (*string, bool)` + +GetDestinationProjectOk returns a tuple with the DestinationProject field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDestinationProject + +`func (o *Application) SetDestinationProject(v string)` + +SetDestinationProject sets DestinationProject field to given value. + + +### GetCredentialId + +`func (o *Application) GetCredentialId() string` + +GetCredentialId returns the CredentialId field if non-nil, zero value otherwise. + +### GetCredentialIdOk + +`func (o *Application) GetCredentialIdOk() (*string, bool)` + +GetCredentialIdOk returns a tuple with the CredentialId field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetCredentialId + +`func (o *Application) SetCredentialId(v string)` + +SetCredentialId sets CredentialId field to given value. + +### HasCredentialId + +`func (o *Application) HasCredentialId() bool` + +HasCredentialId returns a boolean if a field has been set. + +### GetAutoSync + +`func (o *Application) GetAutoSync() bool` + +GetAutoSync returns the AutoSync field if non-nil, zero value otherwise. + +### GetAutoSyncOk + +`func (o *Application) GetAutoSyncOk() (*bool, bool)` + +GetAutoSyncOk returns a tuple with the AutoSync field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetAutoSync + +`func (o *Application) SetAutoSync(v bool)` + +SetAutoSync sets AutoSync field to given value. + +### HasAutoSync + +`func (o *Application) HasAutoSync() bool` + +HasAutoSync returns a boolean if a field has been set. + +### GetAutoPrune + +`func (o *Application) GetAutoPrune() bool` + +GetAutoPrune returns the AutoPrune field if non-nil, zero value otherwise. + +### GetAutoPruneOk + +`func (o *Application) GetAutoPruneOk() (*bool, bool)` + +GetAutoPruneOk returns a tuple with the AutoPrune field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetAutoPrune + +`func (o *Application) SetAutoPrune(v bool)` + +SetAutoPrune sets AutoPrune field to given value. + +### HasAutoPrune + +`func (o *Application) HasAutoPrune() bool` + +HasAutoPrune returns a boolean if a field has been set. + +### GetSelfHeal + +`func (o *Application) GetSelfHeal() bool` + +GetSelfHeal returns the SelfHeal field if non-nil, zero value otherwise. + +### GetSelfHealOk + +`func (o *Application) GetSelfHealOk() (*bool, bool)` + +GetSelfHealOk returns a tuple with the SelfHeal field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSelfHeal + +`func (o *Application) SetSelfHeal(v bool)` + +SetSelfHeal sets SelfHeal field to given value. + +### HasSelfHeal + +`func (o *Application) HasSelfHeal() bool` + +HasSelfHeal returns a boolean if a field has been set. + +### GetSyncOptions + +`func (o *Application) GetSyncOptions() string` + +GetSyncOptions returns the SyncOptions field if non-nil, zero value otherwise. + +### GetSyncOptionsOk + +`func (o *Application) GetSyncOptionsOk() (*string, bool)` + +GetSyncOptionsOk returns a tuple with the SyncOptions field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSyncOptions + +`func (o *Application) SetSyncOptions(v string)` + +SetSyncOptions sets SyncOptions field to given value. + +### HasSyncOptions + +`func (o *Application) HasSyncOptions() bool` + +HasSyncOptions returns a boolean if a field has been set. + +### GetRetryLimit + +`func (o *Application) GetRetryLimit() int32` + +GetRetryLimit returns the RetryLimit field if non-nil, zero value otherwise. + +### GetRetryLimitOk + +`func (o *Application) GetRetryLimitOk() (*int32, bool)` + +GetRetryLimitOk returns a tuple with the RetryLimit field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetRetryLimit + +`func (o *Application) SetRetryLimit(v int32)` + +SetRetryLimit sets RetryLimit field to given value. + +### HasRetryLimit + +`func (o *Application) HasRetryLimit() bool` + +HasRetryLimit returns a boolean if a field has been set. + +### GetSyncStatus + +`func (o *Application) GetSyncStatus() string` + +GetSyncStatus returns the SyncStatus field if non-nil, zero value otherwise. + +### GetSyncStatusOk + +`func (o *Application) GetSyncStatusOk() (*string, bool)` + +GetSyncStatusOk returns a tuple with the SyncStatus field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSyncStatus + +`func (o *Application) SetSyncStatus(v string)` + +SetSyncStatus sets SyncStatus field to given value. + +### HasSyncStatus + +`func (o *Application) HasSyncStatus() bool` + +HasSyncStatus returns a boolean if a field has been set. + +### GetHealthStatus + +`func (o *Application) GetHealthStatus() string` + +GetHealthStatus returns the HealthStatus field if non-nil, zero value otherwise. + +### GetHealthStatusOk + +`func (o *Application) GetHealthStatusOk() (*string, bool)` + +GetHealthStatusOk returns a tuple with the HealthStatus field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetHealthStatus + +`func (o *Application) SetHealthStatus(v string)` + +SetHealthStatus sets HealthStatus field to given value. + +### HasHealthStatus + +`func (o *Application) HasHealthStatus() bool` + +HasHealthStatus returns a boolean if a field has been set. + +### GetSyncRevision + +`func (o *Application) GetSyncRevision() string` + +GetSyncRevision returns the SyncRevision field if non-nil, zero value otherwise. + +### GetSyncRevisionOk + +`func (o *Application) GetSyncRevisionOk() (*string, bool)` + +GetSyncRevisionOk returns a tuple with the SyncRevision field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSyncRevision + +`func (o *Application) SetSyncRevision(v string)` + +SetSyncRevision sets SyncRevision field to given value. + +### HasSyncRevision + +`func (o *Application) HasSyncRevision() bool` + +HasSyncRevision returns a boolean if a field has been set. + +### GetOperationPhase + +`func (o *Application) GetOperationPhase() string` + +GetOperationPhase returns the OperationPhase field if non-nil, zero value otherwise. + +### GetOperationPhaseOk + +`func (o *Application) GetOperationPhaseOk() (*string, bool)` + +GetOperationPhaseOk returns a tuple with the OperationPhase field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetOperationPhase + +`func (o *Application) SetOperationPhase(v string)` + +SetOperationPhase sets OperationPhase field to given value. + +### HasOperationPhase + +`func (o *Application) HasOperationPhase() bool` + +HasOperationPhase returns a boolean if a field has been set. + +### GetOperationMessage + +`func (o *Application) GetOperationMessage() string` + +GetOperationMessage returns the OperationMessage field if non-nil, zero value otherwise. + +### GetOperationMessageOk + +`func (o *Application) GetOperationMessageOk() (*string, bool)` + +GetOperationMessageOk returns a tuple with the OperationMessage field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetOperationMessage + +`func (o *Application) SetOperationMessage(v string)` + +SetOperationMessage sets OperationMessage field to given value. + +### HasOperationMessage + +`func (o *Application) HasOperationMessage() bool` + +HasOperationMessage returns a boolean if a field has been set. + +### GetResourceStatus + +`func (o *Application) GetResourceStatus() string` + +GetResourceStatus returns the ResourceStatus field if non-nil, zero value otherwise. + +### GetResourceStatusOk + +`func (o *Application) GetResourceStatusOk() (*string, bool)` + +GetResourceStatusOk returns a tuple with the ResourceStatus field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetResourceStatus + +`func (o *Application) SetResourceStatus(v string)` + +SetResourceStatus sets ResourceStatus field to given value. + +### HasResourceStatus + +`func (o *Application) HasResourceStatus() bool` + +HasResourceStatus returns a boolean if a field has been set. + +### GetConditions + +`func (o *Application) GetConditions() string` + +GetConditions returns the Conditions field if non-nil, zero value otherwise. + +### GetConditionsOk + +`func (o *Application) GetConditionsOk() (*string, bool)` + +GetConditionsOk returns a tuple with the Conditions field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetConditions + +`func (o *Application) SetConditions(v string)` + +SetConditions sets Conditions field to given value. + +### HasConditions + +`func (o *Application) HasConditions() bool` + +HasConditions returns a boolean if a field has been set. + +### GetLabels + +`func (o *Application) GetLabels() string` + +GetLabels returns the Labels field if non-nil, zero value otherwise. + +### GetLabelsOk + +`func (o *Application) GetLabelsOk() (*string, bool)` + +GetLabelsOk returns a tuple with the Labels field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetLabels + +`func (o *Application) SetLabels(v string)` + +SetLabels sets Labels field to given value. + +### HasLabels + +`func (o *Application) HasLabels() bool` + +HasLabels returns a boolean if a field has been set. + +### GetAnnotations + +`func (o *Application) GetAnnotations() string` + +GetAnnotations returns the Annotations field if non-nil, zero value otherwise. + +### GetAnnotationsOk + +`func (o *Application) GetAnnotationsOk() (*string, bool)` + +GetAnnotationsOk returns a tuple with the Annotations field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetAnnotations + +`func (o *Application) SetAnnotations(v string)` + +SetAnnotations sets Annotations field to given value. + +### HasAnnotations + +`func (o *Application) HasAnnotations() bool` + +HasAnnotations returns a boolean if a field has been set. + +### GetLastSyncedAt + +`func (o *Application) GetLastSyncedAt() time.Time` + +GetLastSyncedAt returns the LastSyncedAt field if non-nil, zero value otherwise. + +### GetLastSyncedAtOk + +`func (o *Application) GetLastSyncedAtOk() (*time.Time, bool)` + +GetLastSyncedAtOk returns a tuple with the LastSyncedAt field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetLastSyncedAt + +`func (o *Application) SetLastSyncedAt(v time.Time)` + +SetLastSyncedAt sets LastSyncedAt field to given value. + +### HasLastSyncedAt + +`func (o *Application) HasLastSyncedAt() bool` + +HasLastSyncedAt returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/components/ambient-api-server/pkg/api/openapi/docs/ApplicationList.md b/components/ambient-api-server/pkg/api/openapi/docs/ApplicationList.md new file mode 100644 index 000000000..0ee607692 --- /dev/null +++ b/components/ambient-api-server/pkg/api/openapi/docs/ApplicationList.md @@ -0,0 +1,135 @@ +# ApplicationList + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Kind** | **string** | | +**Page** | **int32** | | +**Size** | **int32** | | +**Total** | **int32** | | +**Items** | [**[]Application**](Application.md) | | + +## Methods + +### NewApplicationList + +`func NewApplicationList(kind string, page int32, size int32, total int32, items []Application, ) *ApplicationList` + +NewApplicationList instantiates a new ApplicationList object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewApplicationListWithDefaults + +`func NewApplicationListWithDefaults() *ApplicationList` + +NewApplicationListWithDefaults instantiates a new ApplicationList object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetKind + +`func (o *ApplicationList) GetKind() string` + +GetKind returns the Kind field if non-nil, zero value otherwise. + +### GetKindOk + +`func (o *ApplicationList) GetKindOk() (*string, bool)` + +GetKindOk returns a tuple with the Kind field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetKind + +`func (o *ApplicationList) SetKind(v string)` + +SetKind sets Kind field to given value. + + +### GetPage + +`func (o *ApplicationList) GetPage() int32` + +GetPage returns the Page field if non-nil, zero value otherwise. + +### GetPageOk + +`func (o *ApplicationList) GetPageOk() (*int32, bool)` + +GetPageOk returns a tuple with the Page field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetPage + +`func (o *ApplicationList) SetPage(v int32)` + +SetPage sets Page field to given value. + + +### GetSize + +`func (o *ApplicationList) GetSize() int32` + +GetSize returns the Size field if non-nil, zero value otherwise. + +### GetSizeOk + +`func (o *ApplicationList) GetSizeOk() (*int32, bool)` + +GetSizeOk returns a tuple with the Size field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSize + +`func (o *ApplicationList) SetSize(v int32)` + +SetSize sets Size field to given value. + + +### GetTotal + +`func (o *ApplicationList) GetTotal() int32` + +GetTotal returns the Total field if non-nil, zero value otherwise. + +### GetTotalOk + +`func (o *ApplicationList) GetTotalOk() (*int32, bool)` + +GetTotalOk returns a tuple with the Total field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTotal + +`func (o *ApplicationList) SetTotal(v int32)` + +SetTotal sets Total field to given value. + + +### GetItems + +`func (o *ApplicationList) GetItems() []Application` + +GetItems returns the Items field if non-nil, zero value otherwise. + +### GetItemsOk + +`func (o *ApplicationList) GetItemsOk() (*[]Application, bool)` + +GetItemsOk returns a tuple with the Items field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetItems + +`func (o *ApplicationList) SetItems(v []Application)` + +SetItems sets Items field to given value. + + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/components/ambient-api-server/pkg/api/openapi/docs/ApplicationPatchRequest.md b/components/ambient-api-server/pkg/api/openapi/docs/ApplicationPatchRequest.md new file mode 100644 index 000000000..01b2b1804 --- /dev/null +++ b/components/ambient-api-server/pkg/api/openapi/docs/ApplicationPatchRequest.md @@ -0,0 +1,602 @@ +# ApplicationPatchRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | Pointer to **string** | | [optional] +**SourceRepoUrl** | Pointer to **string** | | [optional] +**SourceTargetRevision** | Pointer to **string** | | [optional] +**SourcePath** | Pointer to **string** | | [optional] +**DestinationAmbientUrl** | Pointer to **string** | | [optional] +**DestinationProject** | Pointer to **string** | | [optional] +**CredentialId** | Pointer to **string** | | [optional] +**AutoSync** | Pointer to **bool** | | [optional] +**AutoPrune** | Pointer to **bool** | | [optional] +**SelfHeal** | Pointer to **bool** | | [optional] +**SyncOptions** | Pointer to **string** | | [optional] +**RetryLimit** | Pointer to **int32** | | [optional] +**SyncStatus** | Pointer to **string** | | [optional] +**HealthStatus** | Pointer to **string** | | [optional] +**SyncRevision** | Pointer to **string** | | [optional] +**OperationPhase** | Pointer to **string** | | [optional] +**OperationMessage** | Pointer to **string** | | [optional] +**ResourceStatus** | Pointer to **string** | | [optional] +**Conditions** | Pointer to **string** | | [optional] +**Labels** | Pointer to **string** | | [optional] +**Annotations** | Pointer to **string** | | [optional] +**LastSyncedAt** | Pointer to **time.Time** | | [optional] + +## Methods + +### NewApplicationPatchRequest + +`func NewApplicationPatchRequest() *ApplicationPatchRequest` + +NewApplicationPatchRequest instantiates a new ApplicationPatchRequest object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewApplicationPatchRequestWithDefaults + +`func NewApplicationPatchRequestWithDefaults() *ApplicationPatchRequest` + +NewApplicationPatchRequestWithDefaults instantiates a new ApplicationPatchRequest object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetName + +`func (o *ApplicationPatchRequest) GetName() string` + +GetName returns the Name field if non-nil, zero value otherwise. + +### GetNameOk + +`func (o *ApplicationPatchRequest) GetNameOk() (*string, bool)` + +GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetName + +`func (o *ApplicationPatchRequest) SetName(v string)` + +SetName sets Name field to given value. + +### HasName + +`func (o *ApplicationPatchRequest) HasName() bool` + +HasName returns a boolean if a field has been set. + +### GetSourceRepoUrl + +`func (o *ApplicationPatchRequest) GetSourceRepoUrl() string` + +GetSourceRepoUrl returns the SourceRepoUrl field if non-nil, zero value otherwise. + +### GetSourceRepoUrlOk + +`func (o *ApplicationPatchRequest) GetSourceRepoUrlOk() (*string, bool)` + +GetSourceRepoUrlOk returns a tuple with the SourceRepoUrl field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSourceRepoUrl + +`func (o *ApplicationPatchRequest) SetSourceRepoUrl(v string)` + +SetSourceRepoUrl sets SourceRepoUrl field to given value. + +### HasSourceRepoUrl + +`func (o *ApplicationPatchRequest) HasSourceRepoUrl() bool` + +HasSourceRepoUrl returns a boolean if a field has been set. + +### GetSourceTargetRevision + +`func (o *ApplicationPatchRequest) GetSourceTargetRevision() string` + +GetSourceTargetRevision returns the SourceTargetRevision field if non-nil, zero value otherwise. + +### GetSourceTargetRevisionOk + +`func (o *ApplicationPatchRequest) GetSourceTargetRevisionOk() (*string, bool)` + +GetSourceTargetRevisionOk returns a tuple with the SourceTargetRevision field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSourceTargetRevision + +`func (o *ApplicationPatchRequest) SetSourceTargetRevision(v string)` + +SetSourceTargetRevision sets SourceTargetRevision field to given value. + +### HasSourceTargetRevision + +`func (o *ApplicationPatchRequest) HasSourceTargetRevision() bool` + +HasSourceTargetRevision returns a boolean if a field has been set. + +### GetSourcePath + +`func (o *ApplicationPatchRequest) GetSourcePath() string` + +GetSourcePath returns the SourcePath field if non-nil, zero value otherwise. + +### GetSourcePathOk + +`func (o *ApplicationPatchRequest) GetSourcePathOk() (*string, bool)` + +GetSourcePathOk returns a tuple with the SourcePath field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSourcePath + +`func (o *ApplicationPatchRequest) SetSourcePath(v string)` + +SetSourcePath sets SourcePath field to given value. + +### HasSourcePath + +`func (o *ApplicationPatchRequest) HasSourcePath() bool` + +HasSourcePath returns a boolean if a field has been set. + +### GetDestinationAmbientUrl + +`func (o *ApplicationPatchRequest) GetDestinationAmbientUrl() string` + +GetDestinationAmbientUrl returns the DestinationAmbientUrl field if non-nil, zero value otherwise. + +### GetDestinationAmbientUrlOk + +`func (o *ApplicationPatchRequest) GetDestinationAmbientUrlOk() (*string, bool)` + +GetDestinationAmbientUrlOk returns a tuple with the DestinationAmbientUrl field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDestinationAmbientUrl + +`func (o *ApplicationPatchRequest) SetDestinationAmbientUrl(v string)` + +SetDestinationAmbientUrl sets DestinationAmbientUrl field to given value. + +### HasDestinationAmbientUrl + +`func (o *ApplicationPatchRequest) HasDestinationAmbientUrl() bool` + +HasDestinationAmbientUrl returns a boolean if a field has been set. + +### GetDestinationProject + +`func (o *ApplicationPatchRequest) GetDestinationProject() string` + +GetDestinationProject returns the DestinationProject field if non-nil, zero value otherwise. + +### GetDestinationProjectOk + +`func (o *ApplicationPatchRequest) GetDestinationProjectOk() (*string, bool)` + +GetDestinationProjectOk returns a tuple with the DestinationProject field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDestinationProject + +`func (o *ApplicationPatchRequest) SetDestinationProject(v string)` + +SetDestinationProject sets DestinationProject field to given value. + +### HasDestinationProject + +`func (o *ApplicationPatchRequest) HasDestinationProject() bool` + +HasDestinationProject returns a boolean if a field has been set. + +### GetCredentialId + +`func (o *ApplicationPatchRequest) GetCredentialId() string` + +GetCredentialId returns the CredentialId field if non-nil, zero value otherwise. + +### GetCredentialIdOk + +`func (o *ApplicationPatchRequest) GetCredentialIdOk() (*string, bool)` + +GetCredentialIdOk returns a tuple with the CredentialId field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetCredentialId + +`func (o *ApplicationPatchRequest) SetCredentialId(v string)` + +SetCredentialId sets CredentialId field to given value. + +### HasCredentialId + +`func (o *ApplicationPatchRequest) HasCredentialId() bool` + +HasCredentialId returns a boolean if a field has been set. + +### GetAutoSync + +`func (o *ApplicationPatchRequest) GetAutoSync() bool` + +GetAutoSync returns the AutoSync field if non-nil, zero value otherwise. + +### GetAutoSyncOk + +`func (o *ApplicationPatchRequest) GetAutoSyncOk() (*bool, bool)` + +GetAutoSyncOk returns a tuple with the AutoSync field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetAutoSync + +`func (o *ApplicationPatchRequest) SetAutoSync(v bool)` + +SetAutoSync sets AutoSync field to given value. + +### HasAutoSync + +`func (o *ApplicationPatchRequest) HasAutoSync() bool` + +HasAutoSync returns a boolean if a field has been set. + +### GetAutoPrune + +`func (o *ApplicationPatchRequest) GetAutoPrune() bool` + +GetAutoPrune returns the AutoPrune field if non-nil, zero value otherwise. + +### GetAutoPruneOk + +`func (o *ApplicationPatchRequest) GetAutoPruneOk() (*bool, bool)` + +GetAutoPruneOk returns a tuple with the AutoPrune field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetAutoPrune + +`func (o *ApplicationPatchRequest) SetAutoPrune(v bool)` + +SetAutoPrune sets AutoPrune field to given value. + +### HasAutoPrune + +`func (o *ApplicationPatchRequest) HasAutoPrune() bool` + +HasAutoPrune returns a boolean if a field has been set. + +### GetSelfHeal + +`func (o *ApplicationPatchRequest) GetSelfHeal() bool` + +GetSelfHeal returns the SelfHeal field if non-nil, zero value otherwise. + +### GetSelfHealOk + +`func (o *ApplicationPatchRequest) GetSelfHealOk() (*bool, bool)` + +GetSelfHealOk returns a tuple with the SelfHeal field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSelfHeal + +`func (o *ApplicationPatchRequest) SetSelfHeal(v bool)` + +SetSelfHeal sets SelfHeal field to given value. + +### HasSelfHeal + +`func (o *ApplicationPatchRequest) HasSelfHeal() bool` + +HasSelfHeal returns a boolean if a field has been set. + +### GetSyncOptions + +`func (o *ApplicationPatchRequest) GetSyncOptions() string` + +GetSyncOptions returns the SyncOptions field if non-nil, zero value otherwise. + +### GetSyncOptionsOk + +`func (o *ApplicationPatchRequest) GetSyncOptionsOk() (*string, bool)` + +GetSyncOptionsOk returns a tuple with the SyncOptions field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSyncOptions + +`func (o *ApplicationPatchRequest) SetSyncOptions(v string)` + +SetSyncOptions sets SyncOptions field to given value. + +### HasSyncOptions + +`func (o *ApplicationPatchRequest) HasSyncOptions() bool` + +HasSyncOptions returns a boolean if a field has been set. + +### GetRetryLimit + +`func (o *ApplicationPatchRequest) GetRetryLimit() int32` + +GetRetryLimit returns the RetryLimit field if non-nil, zero value otherwise. + +### GetRetryLimitOk + +`func (o *ApplicationPatchRequest) GetRetryLimitOk() (*int32, bool)` + +GetRetryLimitOk returns a tuple with the RetryLimit field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetRetryLimit + +`func (o *ApplicationPatchRequest) SetRetryLimit(v int32)` + +SetRetryLimit sets RetryLimit field to given value. + +### HasRetryLimit + +`func (o *ApplicationPatchRequest) HasRetryLimit() bool` + +HasRetryLimit returns a boolean if a field has been set. + +### GetSyncStatus + +`func (o *ApplicationPatchRequest) GetSyncStatus() string` + +GetSyncStatus returns the SyncStatus field if non-nil, zero value otherwise. + +### GetSyncStatusOk + +`func (o *ApplicationPatchRequest) GetSyncStatusOk() (*string, bool)` + +GetSyncStatusOk returns a tuple with the SyncStatus field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSyncStatus + +`func (o *ApplicationPatchRequest) SetSyncStatus(v string)` + +SetSyncStatus sets SyncStatus field to given value. + +### HasSyncStatus + +`func (o *ApplicationPatchRequest) HasSyncStatus() bool` + +HasSyncStatus returns a boolean if a field has been set. + +### GetHealthStatus + +`func (o *ApplicationPatchRequest) GetHealthStatus() string` + +GetHealthStatus returns the HealthStatus field if non-nil, zero value otherwise. + +### GetHealthStatusOk + +`func (o *ApplicationPatchRequest) GetHealthStatusOk() (*string, bool)` + +GetHealthStatusOk returns a tuple with the HealthStatus field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetHealthStatus + +`func (o *ApplicationPatchRequest) SetHealthStatus(v string)` + +SetHealthStatus sets HealthStatus field to given value. + +### HasHealthStatus + +`func (o *ApplicationPatchRequest) HasHealthStatus() bool` + +HasHealthStatus returns a boolean if a field has been set. + +### GetSyncRevision + +`func (o *ApplicationPatchRequest) GetSyncRevision() string` + +GetSyncRevision returns the SyncRevision field if non-nil, zero value otherwise. + +### GetSyncRevisionOk + +`func (o *ApplicationPatchRequest) GetSyncRevisionOk() (*string, bool)` + +GetSyncRevisionOk returns a tuple with the SyncRevision field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSyncRevision + +`func (o *ApplicationPatchRequest) SetSyncRevision(v string)` + +SetSyncRevision sets SyncRevision field to given value. + +### HasSyncRevision + +`func (o *ApplicationPatchRequest) HasSyncRevision() bool` + +HasSyncRevision returns a boolean if a field has been set. + +### GetOperationPhase + +`func (o *ApplicationPatchRequest) GetOperationPhase() string` + +GetOperationPhase returns the OperationPhase field if non-nil, zero value otherwise. + +### GetOperationPhaseOk + +`func (o *ApplicationPatchRequest) GetOperationPhaseOk() (*string, bool)` + +GetOperationPhaseOk returns a tuple with the OperationPhase field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetOperationPhase + +`func (o *ApplicationPatchRequest) SetOperationPhase(v string)` + +SetOperationPhase sets OperationPhase field to given value. + +### HasOperationPhase + +`func (o *ApplicationPatchRequest) HasOperationPhase() bool` + +HasOperationPhase returns a boolean if a field has been set. + +### GetOperationMessage + +`func (o *ApplicationPatchRequest) GetOperationMessage() string` + +GetOperationMessage returns the OperationMessage field if non-nil, zero value otherwise. + +### GetOperationMessageOk + +`func (o *ApplicationPatchRequest) GetOperationMessageOk() (*string, bool)` + +GetOperationMessageOk returns a tuple with the OperationMessage field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetOperationMessage + +`func (o *ApplicationPatchRequest) SetOperationMessage(v string)` + +SetOperationMessage sets OperationMessage field to given value. + +### HasOperationMessage + +`func (o *ApplicationPatchRequest) HasOperationMessage() bool` + +HasOperationMessage returns a boolean if a field has been set. + +### GetResourceStatus + +`func (o *ApplicationPatchRequest) GetResourceStatus() string` + +GetResourceStatus returns the ResourceStatus field if non-nil, zero value otherwise. + +### GetResourceStatusOk + +`func (o *ApplicationPatchRequest) GetResourceStatusOk() (*string, bool)` + +GetResourceStatusOk returns a tuple with the ResourceStatus field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetResourceStatus + +`func (o *ApplicationPatchRequest) SetResourceStatus(v string)` + +SetResourceStatus sets ResourceStatus field to given value. + +### HasResourceStatus + +`func (o *ApplicationPatchRequest) HasResourceStatus() bool` + +HasResourceStatus returns a boolean if a field has been set. + +### GetConditions + +`func (o *ApplicationPatchRequest) GetConditions() string` + +GetConditions returns the Conditions field if non-nil, zero value otherwise. + +### GetConditionsOk + +`func (o *ApplicationPatchRequest) GetConditionsOk() (*string, bool)` + +GetConditionsOk returns a tuple with the Conditions field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetConditions + +`func (o *ApplicationPatchRequest) SetConditions(v string)` + +SetConditions sets Conditions field to given value. + +### HasConditions + +`func (o *ApplicationPatchRequest) HasConditions() bool` + +HasConditions returns a boolean if a field has been set. + +### GetLabels + +`func (o *ApplicationPatchRequest) GetLabels() string` + +GetLabels returns the Labels field if non-nil, zero value otherwise. + +### GetLabelsOk + +`func (o *ApplicationPatchRequest) GetLabelsOk() (*string, bool)` + +GetLabelsOk returns a tuple with the Labels field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetLabels + +`func (o *ApplicationPatchRequest) SetLabels(v string)` + +SetLabels sets Labels field to given value. + +### HasLabels + +`func (o *ApplicationPatchRequest) HasLabels() bool` + +HasLabels returns a boolean if a field has been set. + +### GetAnnotations + +`func (o *ApplicationPatchRequest) GetAnnotations() string` + +GetAnnotations returns the Annotations field if non-nil, zero value otherwise. + +### GetAnnotationsOk + +`func (o *ApplicationPatchRequest) GetAnnotationsOk() (*string, bool)` + +GetAnnotationsOk returns a tuple with the Annotations field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetAnnotations + +`func (o *ApplicationPatchRequest) SetAnnotations(v string)` + +SetAnnotations sets Annotations field to given value. + +### HasAnnotations + +`func (o *ApplicationPatchRequest) HasAnnotations() bool` + +HasAnnotations returns a boolean if a field has been set. + +### GetLastSyncedAt + +`func (o *ApplicationPatchRequest) GetLastSyncedAt() time.Time` + +GetLastSyncedAt returns the LastSyncedAt field if non-nil, zero value otherwise. + +### GetLastSyncedAtOk + +`func (o *ApplicationPatchRequest) GetLastSyncedAtOk() (*time.Time, bool)` + +GetLastSyncedAtOk returns a tuple with the LastSyncedAt field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetLastSyncedAt + +`func (o *ApplicationPatchRequest) SetLastSyncedAt(v time.Time)` + +SetLastSyncedAt sets LastSyncedAt field to given value. + +### HasLastSyncedAt + +`func (o *ApplicationPatchRequest) HasLastSyncedAt() bool` + +HasLastSyncedAt returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/components/ambient-api-server/pkg/api/openapi/docs/DefaultAPI.md b/components/ambient-api-server/pkg/api/openapi/docs/DefaultAPI.md index a003ed9c3..555081ca2 100644 --- a/components/ambient-api-server/pkg/api/openapi/docs/DefaultAPI.md +++ b/components/ambient-api-server/pkg/api/openapi/docs/DefaultAPI.md @@ -4,6 +4,11 @@ All URIs are relative to *http://localhost:8000* Method | HTTP request | Description ------------- | ------------- | ------------- +[**ApiAmbientV1ApplicationsGet**](DefaultAPI.md#ApiAmbientV1ApplicationsGet) | **Get** /api/ambient/v1/applications | Returns a list of applications +[**ApiAmbientV1ApplicationsIdDelete**](DefaultAPI.md#ApiAmbientV1ApplicationsIdDelete) | **Delete** /api/ambient/v1/applications/{id} | Delete an application by id +[**ApiAmbientV1ApplicationsIdGet**](DefaultAPI.md#ApiAmbientV1ApplicationsIdGet) | **Get** /api/ambient/v1/applications/{id} | Get an application by id +[**ApiAmbientV1ApplicationsIdPatch**](DefaultAPI.md#ApiAmbientV1ApplicationsIdPatch) | **Patch** /api/ambient/v1/applications/{id} | Update an application +[**ApiAmbientV1ApplicationsPost**](DefaultAPI.md#ApiAmbientV1ApplicationsPost) | **Post** /api/ambient/v1/applications | Create a new application [**ApiAmbientV1CredentialsCredIdDelete**](DefaultAPI.md#ApiAmbientV1CredentialsCredIdDelete) | **Delete** /api/ambient/v1/credentials/{cred_id} | Delete a credential [**ApiAmbientV1CredentialsCredIdGet**](DefaultAPI.md#ApiAmbientV1CredentialsCredIdGet) | **Get** /api/ambient/v1/credentials/{cred_id} | Get a credential by id [**ApiAmbientV1CredentialsCredIdPatch**](DefaultAPI.md#ApiAmbientV1CredentialsCredIdPatch) | **Patch** /api/ambient/v1/credentials/{cred_id} | Update a credential @@ -75,6 +80,346 @@ Method | HTTP request | Description +## ApiAmbientV1ApplicationsGet + +> ApplicationList ApiAmbientV1ApplicationsGet(ctx).Page(page).Size(size).Search(search).OrderBy(orderBy).Fields(fields).Execute() + +Returns a list of applications + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + page := int32(56) // int32 | Page number of record list when record list exceeds specified page size (optional) (default to 1) + size := int32(56) // int32 | Maximum number of records to return (optional) (default to 100) + search := "search_example" // string | Specifies the search criteria (optional) + orderBy := "orderBy_example" // string | Specifies the order by criteria (optional) + fields := "fields_example" // string | Supplies a comma-separated list of fields to be returned (optional) + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.DefaultAPI.ApiAmbientV1ApplicationsGet(context.Background()).Page(page).Size(size).Search(search).OrderBy(orderBy).Fields(fields).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DefaultAPI.ApiAmbientV1ApplicationsGet``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `ApiAmbientV1ApplicationsGet`: ApplicationList + fmt.Fprintf(os.Stdout, "Response from `DefaultAPI.ApiAmbientV1ApplicationsGet`: %v\n", resp) +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiApiAmbientV1ApplicationsGetRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **page** | **int32** | Page number of record list when record list exceeds specified page size | [default to 1] + **size** | **int32** | Maximum number of records to return | [default to 100] + **search** | **string** | Specifies the search criteria | + **orderBy** | **string** | Specifies the order by criteria | + **fields** | **string** | Supplies a comma-separated list of fields to be returned | + +### Return type + +[**ApplicationList**](ApplicationList.md) + +### Authorization + +[Bearer](../README.md#Bearer) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + +## ApiAmbientV1ApplicationsIdDelete + +> ApiAmbientV1ApplicationsIdDelete(ctx, id).Execute() + +Delete an application by id + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + id := "id_example" // string | The id of record + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + r, err := apiClient.DefaultAPI.ApiAmbientV1ApplicationsIdDelete(context.Background(), id).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DefaultAPI.ApiAmbientV1ApplicationsIdDelete``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**id** | **string** | The id of record | + +### Other Parameters + +Other parameters are passed through a pointer to a apiApiAmbientV1ApplicationsIdDeleteRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + +### Return type + + (empty response body) + +### Authorization + +[Bearer](../README.md#Bearer) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + +## ApiAmbientV1ApplicationsIdGet + +> Application ApiAmbientV1ApplicationsIdGet(ctx, id).Execute() + +Get an application by id + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + id := "id_example" // string | The id of record + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.DefaultAPI.ApiAmbientV1ApplicationsIdGet(context.Background(), id).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DefaultAPI.ApiAmbientV1ApplicationsIdGet``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `ApiAmbientV1ApplicationsIdGet`: Application + fmt.Fprintf(os.Stdout, "Response from `DefaultAPI.ApiAmbientV1ApplicationsIdGet`: %v\n", resp) +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**id** | **string** | The id of record | + +### Other Parameters + +Other parameters are passed through a pointer to a apiApiAmbientV1ApplicationsIdGetRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + +### Return type + +[**Application**](Application.md) + +### Authorization + +[Bearer](../README.md#Bearer) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + +## ApiAmbientV1ApplicationsIdPatch + +> Application ApiAmbientV1ApplicationsIdPatch(ctx, id).ApplicationPatchRequest(applicationPatchRequest).Execute() + +Update an application + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + id := "id_example" // string | The id of record + applicationPatchRequest := *openapiclient.NewApplicationPatchRequest() // ApplicationPatchRequest | Updated application data + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.DefaultAPI.ApiAmbientV1ApplicationsIdPatch(context.Background(), id).ApplicationPatchRequest(applicationPatchRequest).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DefaultAPI.ApiAmbientV1ApplicationsIdPatch``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `ApiAmbientV1ApplicationsIdPatch`: Application + fmt.Fprintf(os.Stdout, "Response from `DefaultAPI.ApiAmbientV1ApplicationsIdPatch`: %v\n", resp) +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**id** | **string** | The id of record | + +### Other Parameters + +Other parameters are passed through a pointer to a apiApiAmbientV1ApplicationsIdPatchRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **applicationPatchRequest** | [**ApplicationPatchRequest**](ApplicationPatchRequest.md) | Updated application data | + +### Return type + +[**Application**](Application.md) + +### Authorization + +[Bearer](../README.md#Bearer) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + +## ApiAmbientV1ApplicationsPost + +> Application ApiAmbientV1ApplicationsPost(ctx).Application(application).Execute() + +Create a new application + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + application := *openapiclient.NewApplication("Name_example", "SourceRepoUrl_example", "SourcePath_example", "DestinationProject_example") // Application | Application data + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.DefaultAPI.ApiAmbientV1ApplicationsPost(context.Background()).Application(application).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DefaultAPI.ApiAmbientV1ApplicationsPost``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `ApiAmbientV1ApplicationsPost`: Application + fmt.Fprintf(os.Stdout, "Response from `DefaultAPI.ApiAmbientV1ApplicationsPost`: %v\n", resp) +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiApiAmbientV1ApplicationsPostRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **application** | [**Application**](Application.md) | Application data | + +### Return type + +[**Application**](Application.md) + +### Authorization + +[Bearer](../README.md#Bearer) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + ## ApiAmbientV1CredentialsCredIdDelete > ApiAmbientV1CredentialsCredIdDelete(ctx, credId).Execute() diff --git a/components/ambient-api-server/pkg/api/openapi/model_application.go b/components/ambient-api-server/pkg/api/openapi/model_application.go new file mode 100644 index 000000000..00d0be859 --- /dev/null +++ b/components/ambient-api-server/pkg/api/openapi/model_application.go @@ -0,0 +1,1070 @@ +/* +Ambient API Server + +Ambient API Server + +API version: 1.0.0 +Contact: ambient-code@redhat.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package openapi + +import ( + "bytes" + "encoding/json" + "fmt" + "time" +) + +// checks if the Application type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Application{} + +// Application struct for Application +type Application struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Href *string `json:"href,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + Name string `json:"name"` + SourceRepoUrl string `json:"source_repo_url"` + SourceTargetRevision *string `json:"source_target_revision,omitempty"` + SourcePath string `json:"source_path"` + DestinationAmbientUrl *string `json:"destination_ambient_url,omitempty"` + DestinationProject string `json:"destination_project"` + CredentialId *string `json:"credential_id,omitempty"` + AutoSync *bool `json:"auto_sync,omitempty"` + AutoPrune *bool `json:"auto_prune,omitempty"` + SelfHeal *bool `json:"self_heal,omitempty"` + SyncOptions *string `json:"sync_options,omitempty"` + RetryLimit *int32 `json:"retry_limit,omitempty"` + SyncStatus *string `json:"sync_status,omitempty"` + HealthStatus *string `json:"health_status,omitempty"` + SyncRevision *string `json:"sync_revision,omitempty"` + OperationPhase *string `json:"operation_phase,omitempty"` + OperationMessage *string `json:"operation_message,omitempty"` + ResourceStatus *string `json:"resource_status,omitempty"` + Conditions *string `json:"conditions,omitempty"` + Labels *string `json:"labels,omitempty"` + Annotations *string `json:"annotations,omitempty"` + LastSyncedAt *time.Time `json:"last_synced_at,omitempty"` +} + +type _Application Application + +// NewApplication instantiates a new Application object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewApplication(name string, sourceRepoUrl string, sourcePath string, destinationProject string) *Application { + this := Application{} + this.Name = name + this.SourceRepoUrl = sourceRepoUrl + this.SourcePath = sourcePath + this.DestinationProject = destinationProject + return &this +} + +// NewApplicationWithDefaults instantiates a new Application object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewApplicationWithDefaults() *Application { + this := Application{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *Application) GetId() string { + if o == nil || IsNil(o.Id) { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetIdOk() (*string, bool) { + if o == nil || IsNil(o.Id) { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *Application) HasId() bool { + if o != nil && !IsNil(o.Id) { + return true + } + + return false +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *Application) SetId(v string) { + o.Id = &v +} + +// GetKind returns the Kind field value if set, zero value otherwise. +func (o *Application) GetKind() string { + if o == nil || IsNil(o.Kind) { + var ret string + return ret + } + return *o.Kind +} + +// GetKindOk returns a tuple with the Kind field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetKindOk() (*string, bool) { + if o == nil || IsNil(o.Kind) { + return nil, false + } + return o.Kind, true +} + +// HasKind returns a boolean if a field has been set. +func (o *Application) HasKind() bool { + if o != nil && !IsNil(o.Kind) { + return true + } + + return false +} + +// SetKind gets a reference to the given string and assigns it to the Kind field. +func (o *Application) SetKind(v string) { + o.Kind = &v +} + +// GetHref returns the Href field value if set, zero value otherwise. +func (o *Application) GetHref() string { + if o == nil || IsNil(o.Href) { + var ret string + return ret + } + return *o.Href +} + +// GetHrefOk returns a tuple with the Href field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetHrefOk() (*string, bool) { + if o == nil || IsNil(o.Href) { + return nil, false + } + return o.Href, true +} + +// HasHref returns a boolean if a field has been set. +func (o *Application) HasHref() bool { + if o != nil && !IsNil(o.Href) { + return true + } + + return false +} + +// SetHref gets a reference to the given string and assigns it to the Href field. +func (o *Application) SetHref(v string) { + o.Href = &v +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *Application) GetCreatedAt() time.Time { + if o == nil || IsNil(o.CreatedAt) { + var ret time.Time + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetCreatedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.CreatedAt) { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *Application) HasCreatedAt() bool { + if o != nil && !IsNil(o.CreatedAt) { + return true + } + + return false +} + +// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. +func (o *Application) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. +func (o *Application) GetUpdatedAt() time.Time { + if o == nil || IsNil(o.UpdatedAt) { + var ret time.Time + return ret + } + return *o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.UpdatedAt) { + return nil, false + } + return o.UpdatedAt, true +} + +// HasUpdatedAt returns a boolean if a field has been set. +func (o *Application) HasUpdatedAt() bool { + if o != nil && !IsNil(o.UpdatedAt) { + return true + } + + return false +} + +// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field. +func (o *Application) SetUpdatedAt(v time.Time) { + o.UpdatedAt = &v +} + +// GetName returns the Name field value +func (o *Application) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *Application) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *Application) SetName(v string) { + o.Name = v +} + +// GetSourceRepoUrl returns the SourceRepoUrl field value +func (o *Application) GetSourceRepoUrl() string { + if o == nil { + var ret string + return ret + } + + return o.SourceRepoUrl +} + +// GetSourceRepoUrlOk returns a tuple with the SourceRepoUrl field value +// and a boolean to check if the value has been set. +func (o *Application) GetSourceRepoUrlOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.SourceRepoUrl, true +} + +// SetSourceRepoUrl sets field value +func (o *Application) SetSourceRepoUrl(v string) { + o.SourceRepoUrl = v +} + +// GetSourceTargetRevision returns the SourceTargetRevision field value if set, zero value otherwise. +func (o *Application) GetSourceTargetRevision() string { + if o == nil || IsNil(o.SourceTargetRevision) { + var ret string + return ret + } + return *o.SourceTargetRevision +} + +// GetSourceTargetRevisionOk returns a tuple with the SourceTargetRevision field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetSourceTargetRevisionOk() (*string, bool) { + if o == nil || IsNil(o.SourceTargetRevision) { + return nil, false + } + return o.SourceTargetRevision, true +} + +// HasSourceTargetRevision returns a boolean if a field has been set. +func (o *Application) HasSourceTargetRevision() bool { + if o != nil && !IsNil(o.SourceTargetRevision) { + return true + } + + return false +} + +// SetSourceTargetRevision gets a reference to the given string and assigns it to the SourceTargetRevision field. +func (o *Application) SetSourceTargetRevision(v string) { + o.SourceTargetRevision = &v +} + +// GetSourcePath returns the SourcePath field value +func (o *Application) GetSourcePath() string { + if o == nil { + var ret string + return ret + } + + return o.SourcePath +} + +// GetSourcePathOk returns a tuple with the SourcePath field value +// and a boolean to check if the value has been set. +func (o *Application) GetSourcePathOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.SourcePath, true +} + +// SetSourcePath sets field value +func (o *Application) SetSourcePath(v string) { + o.SourcePath = v +} + +// GetDestinationAmbientUrl returns the DestinationAmbientUrl field value if set, zero value otherwise. +func (o *Application) GetDestinationAmbientUrl() string { + if o == nil || IsNil(o.DestinationAmbientUrl) { + var ret string + return ret + } + return *o.DestinationAmbientUrl +} + +// GetDestinationAmbientUrlOk returns a tuple with the DestinationAmbientUrl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetDestinationAmbientUrlOk() (*string, bool) { + if o == nil || IsNil(o.DestinationAmbientUrl) { + return nil, false + } + return o.DestinationAmbientUrl, true +} + +// HasDestinationAmbientUrl returns a boolean if a field has been set. +func (o *Application) HasDestinationAmbientUrl() bool { + if o != nil && !IsNil(o.DestinationAmbientUrl) { + return true + } + + return false +} + +// SetDestinationAmbientUrl gets a reference to the given string and assigns it to the DestinationAmbientUrl field. +func (o *Application) SetDestinationAmbientUrl(v string) { + o.DestinationAmbientUrl = &v +} + +// GetDestinationProject returns the DestinationProject field value +func (o *Application) GetDestinationProject() string { + if o == nil { + var ret string + return ret + } + + return o.DestinationProject +} + +// GetDestinationProjectOk returns a tuple with the DestinationProject field value +// and a boolean to check if the value has been set. +func (o *Application) GetDestinationProjectOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DestinationProject, true +} + +// SetDestinationProject sets field value +func (o *Application) SetDestinationProject(v string) { + o.DestinationProject = v +} + +// GetCredentialId returns the CredentialId field value if set, zero value otherwise. +func (o *Application) GetCredentialId() string { + if o == nil || IsNil(o.CredentialId) { + var ret string + return ret + } + return *o.CredentialId +} + +// GetCredentialIdOk returns a tuple with the CredentialId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetCredentialIdOk() (*string, bool) { + if o == nil || IsNil(o.CredentialId) { + return nil, false + } + return o.CredentialId, true +} + +// HasCredentialId returns a boolean if a field has been set. +func (o *Application) HasCredentialId() bool { + if o != nil && !IsNil(o.CredentialId) { + return true + } + + return false +} + +// SetCredentialId gets a reference to the given string and assigns it to the CredentialId field. +func (o *Application) SetCredentialId(v string) { + o.CredentialId = &v +} + +// GetAutoSync returns the AutoSync field value if set, zero value otherwise. +func (o *Application) GetAutoSync() bool { + if o == nil || IsNil(o.AutoSync) { + var ret bool + return ret + } + return *o.AutoSync +} + +// GetAutoSyncOk returns a tuple with the AutoSync field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetAutoSyncOk() (*bool, bool) { + if o == nil || IsNil(o.AutoSync) { + return nil, false + } + return o.AutoSync, true +} + +// HasAutoSync returns a boolean if a field has been set. +func (o *Application) HasAutoSync() bool { + if o != nil && !IsNil(o.AutoSync) { + return true + } + + return false +} + +// SetAutoSync gets a reference to the given bool and assigns it to the AutoSync field. +func (o *Application) SetAutoSync(v bool) { + o.AutoSync = &v +} + +// GetAutoPrune returns the AutoPrune field value if set, zero value otherwise. +func (o *Application) GetAutoPrune() bool { + if o == nil || IsNil(o.AutoPrune) { + var ret bool + return ret + } + return *o.AutoPrune +} + +// GetAutoPruneOk returns a tuple with the AutoPrune field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetAutoPruneOk() (*bool, bool) { + if o == nil || IsNil(o.AutoPrune) { + return nil, false + } + return o.AutoPrune, true +} + +// HasAutoPrune returns a boolean if a field has been set. +func (o *Application) HasAutoPrune() bool { + if o != nil && !IsNil(o.AutoPrune) { + return true + } + + return false +} + +// SetAutoPrune gets a reference to the given bool and assigns it to the AutoPrune field. +func (o *Application) SetAutoPrune(v bool) { + o.AutoPrune = &v +} + +// GetSelfHeal returns the SelfHeal field value if set, zero value otherwise. +func (o *Application) GetSelfHeal() bool { + if o == nil || IsNil(o.SelfHeal) { + var ret bool + return ret + } + return *o.SelfHeal +} + +// GetSelfHealOk returns a tuple with the SelfHeal field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetSelfHealOk() (*bool, bool) { + if o == nil || IsNil(o.SelfHeal) { + return nil, false + } + return o.SelfHeal, true +} + +// HasSelfHeal returns a boolean if a field has been set. +func (o *Application) HasSelfHeal() bool { + if o != nil && !IsNil(o.SelfHeal) { + return true + } + + return false +} + +// SetSelfHeal gets a reference to the given bool and assigns it to the SelfHeal field. +func (o *Application) SetSelfHeal(v bool) { + o.SelfHeal = &v +} + +// GetSyncOptions returns the SyncOptions field value if set, zero value otherwise. +func (o *Application) GetSyncOptions() string { + if o == nil || IsNil(o.SyncOptions) { + var ret string + return ret + } + return *o.SyncOptions +} + +// GetSyncOptionsOk returns a tuple with the SyncOptions field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetSyncOptionsOk() (*string, bool) { + if o == nil || IsNil(o.SyncOptions) { + return nil, false + } + return o.SyncOptions, true +} + +// HasSyncOptions returns a boolean if a field has been set. +func (o *Application) HasSyncOptions() bool { + if o != nil && !IsNil(o.SyncOptions) { + return true + } + + return false +} + +// SetSyncOptions gets a reference to the given string and assigns it to the SyncOptions field. +func (o *Application) SetSyncOptions(v string) { + o.SyncOptions = &v +} + +// GetRetryLimit returns the RetryLimit field value if set, zero value otherwise. +func (o *Application) GetRetryLimit() int32 { + if o == nil || IsNil(o.RetryLimit) { + var ret int32 + return ret + } + return *o.RetryLimit +} + +// GetRetryLimitOk returns a tuple with the RetryLimit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetRetryLimitOk() (*int32, bool) { + if o == nil || IsNil(o.RetryLimit) { + return nil, false + } + return o.RetryLimit, true +} + +// HasRetryLimit returns a boolean if a field has been set. +func (o *Application) HasRetryLimit() bool { + if o != nil && !IsNil(o.RetryLimit) { + return true + } + + return false +} + +// SetRetryLimit gets a reference to the given int32 and assigns it to the RetryLimit field. +func (o *Application) SetRetryLimit(v int32) { + o.RetryLimit = &v +} + +// GetSyncStatus returns the SyncStatus field value if set, zero value otherwise. +func (o *Application) GetSyncStatus() string { + if o == nil || IsNil(o.SyncStatus) { + var ret string + return ret + } + return *o.SyncStatus +} + +// GetSyncStatusOk returns a tuple with the SyncStatus field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetSyncStatusOk() (*string, bool) { + if o == nil || IsNil(o.SyncStatus) { + return nil, false + } + return o.SyncStatus, true +} + +// HasSyncStatus returns a boolean if a field has been set. +func (o *Application) HasSyncStatus() bool { + if o != nil && !IsNil(o.SyncStatus) { + return true + } + + return false +} + +// SetSyncStatus gets a reference to the given string and assigns it to the SyncStatus field. +func (o *Application) SetSyncStatus(v string) { + o.SyncStatus = &v +} + +// GetHealthStatus returns the HealthStatus field value if set, zero value otherwise. +func (o *Application) GetHealthStatus() string { + if o == nil || IsNil(o.HealthStatus) { + var ret string + return ret + } + return *o.HealthStatus +} + +// GetHealthStatusOk returns a tuple with the HealthStatus field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetHealthStatusOk() (*string, bool) { + if o == nil || IsNil(o.HealthStatus) { + return nil, false + } + return o.HealthStatus, true +} + +// HasHealthStatus returns a boolean if a field has been set. +func (o *Application) HasHealthStatus() bool { + if o != nil && !IsNil(o.HealthStatus) { + return true + } + + return false +} + +// SetHealthStatus gets a reference to the given string and assigns it to the HealthStatus field. +func (o *Application) SetHealthStatus(v string) { + o.HealthStatus = &v +} + +// GetSyncRevision returns the SyncRevision field value if set, zero value otherwise. +func (o *Application) GetSyncRevision() string { + if o == nil || IsNil(o.SyncRevision) { + var ret string + return ret + } + return *o.SyncRevision +} + +// GetSyncRevisionOk returns a tuple with the SyncRevision field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetSyncRevisionOk() (*string, bool) { + if o == nil || IsNil(o.SyncRevision) { + return nil, false + } + return o.SyncRevision, true +} + +// HasSyncRevision returns a boolean if a field has been set. +func (o *Application) HasSyncRevision() bool { + if o != nil && !IsNil(o.SyncRevision) { + return true + } + + return false +} + +// SetSyncRevision gets a reference to the given string and assigns it to the SyncRevision field. +func (o *Application) SetSyncRevision(v string) { + o.SyncRevision = &v +} + +// GetOperationPhase returns the OperationPhase field value if set, zero value otherwise. +func (o *Application) GetOperationPhase() string { + if o == nil || IsNil(o.OperationPhase) { + var ret string + return ret + } + return *o.OperationPhase +} + +// GetOperationPhaseOk returns a tuple with the OperationPhase field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetOperationPhaseOk() (*string, bool) { + if o == nil || IsNil(o.OperationPhase) { + return nil, false + } + return o.OperationPhase, true +} + +// HasOperationPhase returns a boolean if a field has been set. +func (o *Application) HasOperationPhase() bool { + if o != nil && !IsNil(o.OperationPhase) { + return true + } + + return false +} + +// SetOperationPhase gets a reference to the given string and assigns it to the OperationPhase field. +func (o *Application) SetOperationPhase(v string) { + o.OperationPhase = &v +} + +// GetOperationMessage returns the OperationMessage field value if set, zero value otherwise. +func (o *Application) GetOperationMessage() string { + if o == nil || IsNil(o.OperationMessage) { + var ret string + return ret + } + return *o.OperationMessage +} + +// GetOperationMessageOk returns a tuple with the OperationMessage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetOperationMessageOk() (*string, bool) { + if o == nil || IsNil(o.OperationMessage) { + return nil, false + } + return o.OperationMessage, true +} + +// HasOperationMessage returns a boolean if a field has been set. +func (o *Application) HasOperationMessage() bool { + if o != nil && !IsNil(o.OperationMessage) { + return true + } + + return false +} + +// SetOperationMessage gets a reference to the given string and assigns it to the OperationMessage field. +func (o *Application) SetOperationMessage(v string) { + o.OperationMessage = &v +} + +// GetResourceStatus returns the ResourceStatus field value if set, zero value otherwise. +func (o *Application) GetResourceStatus() string { + if o == nil || IsNil(o.ResourceStatus) { + var ret string + return ret + } + return *o.ResourceStatus +} + +// GetResourceStatusOk returns a tuple with the ResourceStatus field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetResourceStatusOk() (*string, bool) { + if o == nil || IsNil(o.ResourceStatus) { + return nil, false + } + return o.ResourceStatus, true +} + +// HasResourceStatus returns a boolean if a field has been set. +func (o *Application) HasResourceStatus() bool { + if o != nil && !IsNil(o.ResourceStatus) { + return true + } + + return false +} + +// SetResourceStatus gets a reference to the given string and assigns it to the ResourceStatus field. +func (o *Application) SetResourceStatus(v string) { + o.ResourceStatus = &v +} + +// GetConditions returns the Conditions field value if set, zero value otherwise. +func (o *Application) GetConditions() string { + if o == nil || IsNil(o.Conditions) { + var ret string + return ret + } + return *o.Conditions +} + +// GetConditionsOk returns a tuple with the Conditions field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetConditionsOk() (*string, bool) { + if o == nil || IsNil(o.Conditions) { + return nil, false + } + return o.Conditions, true +} + +// HasConditions returns a boolean if a field has been set. +func (o *Application) HasConditions() bool { + if o != nil && !IsNil(o.Conditions) { + return true + } + + return false +} + +// SetConditions gets a reference to the given string and assigns it to the Conditions field. +func (o *Application) SetConditions(v string) { + o.Conditions = &v +} + +// GetLabels returns the Labels field value if set, zero value otherwise. +func (o *Application) GetLabels() string { + if o == nil || IsNil(o.Labels) { + var ret string + return ret + } + return *o.Labels +} + +// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetLabelsOk() (*string, bool) { + if o == nil || IsNil(o.Labels) { + return nil, false + } + return o.Labels, true +} + +// HasLabels returns a boolean if a field has been set. +func (o *Application) HasLabels() bool { + if o != nil && !IsNil(o.Labels) { + return true + } + + return false +} + +// SetLabels gets a reference to the given string and assigns it to the Labels field. +func (o *Application) SetLabels(v string) { + o.Labels = &v +} + +// GetAnnotations returns the Annotations field value if set, zero value otherwise. +func (o *Application) GetAnnotations() string { + if o == nil || IsNil(o.Annotations) { + var ret string + return ret + } + return *o.Annotations +} + +// GetAnnotationsOk returns a tuple with the Annotations field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetAnnotationsOk() (*string, bool) { + if o == nil || IsNil(o.Annotations) { + return nil, false + } + return o.Annotations, true +} + +// HasAnnotations returns a boolean if a field has been set. +func (o *Application) HasAnnotations() bool { + if o != nil && !IsNil(o.Annotations) { + return true + } + + return false +} + +// SetAnnotations gets a reference to the given string and assigns it to the Annotations field. +func (o *Application) SetAnnotations(v string) { + o.Annotations = &v +} + +// GetLastSyncedAt returns the LastSyncedAt field value if set, zero value otherwise. +func (o *Application) GetLastSyncedAt() time.Time { + if o == nil || IsNil(o.LastSyncedAt) { + var ret time.Time + return ret + } + return *o.LastSyncedAt +} + +// GetLastSyncedAtOk returns a tuple with the LastSyncedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Application) GetLastSyncedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.LastSyncedAt) { + return nil, false + } + return o.LastSyncedAt, true +} + +// HasLastSyncedAt returns a boolean if a field has been set. +func (o *Application) HasLastSyncedAt() bool { + if o != nil && !IsNil(o.LastSyncedAt) { + return true + } + + return false +} + +// SetLastSyncedAt gets a reference to the given time.Time and assigns it to the LastSyncedAt field. +func (o *Application) SetLastSyncedAt(v time.Time) { + o.LastSyncedAt = &v +} + +func (o Application) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Application) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Id) { + toSerialize["id"] = o.Id + } + if !IsNil(o.Kind) { + toSerialize["kind"] = o.Kind + } + if !IsNil(o.Href) { + toSerialize["href"] = o.Href + } + if !IsNil(o.CreatedAt) { + toSerialize["created_at"] = o.CreatedAt + } + if !IsNil(o.UpdatedAt) { + toSerialize["updated_at"] = o.UpdatedAt + } + toSerialize["name"] = o.Name + toSerialize["source_repo_url"] = o.SourceRepoUrl + if !IsNil(o.SourceTargetRevision) { + toSerialize["source_target_revision"] = o.SourceTargetRevision + } + toSerialize["source_path"] = o.SourcePath + if !IsNil(o.DestinationAmbientUrl) { + toSerialize["destination_ambient_url"] = o.DestinationAmbientUrl + } + toSerialize["destination_project"] = o.DestinationProject + if !IsNil(o.CredentialId) { + toSerialize["credential_id"] = o.CredentialId + } + if !IsNil(o.AutoSync) { + toSerialize["auto_sync"] = o.AutoSync + } + if !IsNil(o.AutoPrune) { + toSerialize["auto_prune"] = o.AutoPrune + } + if !IsNil(o.SelfHeal) { + toSerialize["self_heal"] = o.SelfHeal + } + if !IsNil(o.SyncOptions) { + toSerialize["sync_options"] = o.SyncOptions + } + if !IsNil(o.RetryLimit) { + toSerialize["retry_limit"] = o.RetryLimit + } + if !IsNil(o.SyncStatus) { + toSerialize["sync_status"] = o.SyncStatus + } + if !IsNil(o.HealthStatus) { + toSerialize["health_status"] = o.HealthStatus + } + if !IsNil(o.SyncRevision) { + toSerialize["sync_revision"] = o.SyncRevision + } + if !IsNil(o.OperationPhase) { + toSerialize["operation_phase"] = o.OperationPhase + } + if !IsNil(o.OperationMessage) { + toSerialize["operation_message"] = o.OperationMessage + } + if !IsNil(o.ResourceStatus) { + toSerialize["resource_status"] = o.ResourceStatus + } + if !IsNil(o.Conditions) { + toSerialize["conditions"] = o.Conditions + } + if !IsNil(o.Labels) { + toSerialize["labels"] = o.Labels + } + if !IsNil(o.Annotations) { + toSerialize["annotations"] = o.Annotations + } + if !IsNil(o.LastSyncedAt) { + toSerialize["last_synced_at"] = o.LastSyncedAt + } + return toSerialize, nil +} + +func (o *Application) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "name", + "source_repo_url", + "source_path", + "destination_project", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varApplication := _Application{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varApplication) + + if err != nil { + return err + } + + *o = Application(varApplication) + + return err +} + +type NullableApplication struct { + value *Application + isSet bool +} + +func (v NullableApplication) Get() *Application { + return v.value +} + +func (v *NullableApplication) Set(val *Application) { + v.value = val + v.isSet = true +} + +func (v NullableApplication) IsSet() bool { + return v.isSet +} + +func (v *NullableApplication) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableApplication(val *Application) *NullableApplication { + return &NullableApplication{value: val, isSet: true} +} + +func (v NullableApplication) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableApplication) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/components/ambient-api-server/pkg/api/openapi/model_application_list.go b/components/ambient-api-server/pkg/api/openapi/model_application_list.go new file mode 100644 index 000000000..d2c890920 --- /dev/null +++ b/components/ambient-api-server/pkg/api/openapi/model_application_list.go @@ -0,0 +1,269 @@ +/* +Ambient API Server + +Ambient API Server + +API version: 1.0.0 +Contact: ambient-code@redhat.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package openapi + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// checks if the ApplicationList type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ApplicationList{} + +// ApplicationList struct for ApplicationList +type ApplicationList struct { + Kind string `json:"kind"` + Page int32 `json:"page"` + Size int32 `json:"size"` + Total int32 `json:"total"` + Items []Application `json:"items"` +} + +type _ApplicationList ApplicationList + +// NewApplicationList instantiates a new ApplicationList object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewApplicationList(kind string, page int32, size int32, total int32, items []Application) *ApplicationList { + this := ApplicationList{} + this.Kind = kind + this.Page = page + this.Size = size + this.Total = total + this.Items = items + return &this +} + +// NewApplicationListWithDefaults instantiates a new ApplicationList object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewApplicationListWithDefaults() *ApplicationList { + this := ApplicationList{} + return &this +} + +// GetKind returns the Kind field value +func (o *ApplicationList) GetKind() string { + if o == nil { + var ret string + return ret + } + + return o.Kind +} + +// GetKindOk returns a tuple with the Kind field value +// and a boolean to check if the value has been set. +func (o *ApplicationList) GetKindOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Kind, true +} + +// SetKind sets field value +func (o *ApplicationList) SetKind(v string) { + o.Kind = v +} + +// GetPage returns the Page field value +func (o *ApplicationList) GetPage() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Page +} + +// GetPageOk returns a tuple with the Page field value +// and a boolean to check if the value has been set. +func (o *ApplicationList) GetPageOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Page, true +} + +// SetPage sets field value +func (o *ApplicationList) SetPage(v int32) { + o.Page = v +} + +// GetSize returns the Size field value +func (o *ApplicationList) GetSize() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Size +} + +// GetSizeOk returns a tuple with the Size field value +// and a boolean to check if the value has been set. +func (o *ApplicationList) GetSizeOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Size, true +} + +// SetSize sets field value +func (o *ApplicationList) SetSize(v int32) { + o.Size = v +} + +// GetTotal returns the Total field value +func (o *ApplicationList) GetTotal() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Total +} + +// GetTotalOk returns a tuple with the Total field value +// and a boolean to check if the value has been set. +func (o *ApplicationList) GetTotalOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Total, true +} + +// SetTotal sets field value +func (o *ApplicationList) SetTotal(v int32) { + o.Total = v +} + +// GetItems returns the Items field value +func (o *ApplicationList) GetItems() []Application { + if o == nil { + var ret []Application + return ret + } + + return o.Items +} + +// GetItemsOk returns a tuple with the Items field value +// and a boolean to check if the value has been set. +func (o *ApplicationList) GetItemsOk() ([]Application, bool) { + if o == nil { + return nil, false + } + return o.Items, true +} + +// SetItems sets field value +func (o *ApplicationList) SetItems(v []Application) { + o.Items = v +} + +func (o ApplicationList) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ApplicationList) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["kind"] = o.Kind + toSerialize["page"] = o.Page + toSerialize["size"] = o.Size + toSerialize["total"] = o.Total + toSerialize["items"] = o.Items + return toSerialize, nil +} + +func (o *ApplicationList) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "kind", + "page", + "size", + "total", + "items", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varApplicationList := _ApplicationList{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varApplicationList) + + if err != nil { + return err + } + + *o = ApplicationList(varApplicationList) + + return err +} + +type NullableApplicationList struct { + value *ApplicationList + isSet bool +} + +func (v NullableApplicationList) Get() *ApplicationList { + return v.value +} + +func (v *NullableApplicationList) Set(val *ApplicationList) { + v.value = val + v.isSet = true +} + +func (v NullableApplicationList) IsSet() bool { + return v.isSet +} + +func (v *NullableApplicationList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableApplicationList(val *ApplicationList) *NullableApplicationList { + return &NullableApplicationList{value: val, isSet: true} +} + +func (v NullableApplicationList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableApplicationList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/components/ambient-api-server/pkg/api/openapi/model_application_patch_request.go b/components/ambient-api-server/pkg/api/openapi/model_application_patch_request.go new file mode 100644 index 000000000..973320562 --- /dev/null +++ b/components/ambient-api-server/pkg/api/openapi/model_application_patch_request.go @@ -0,0 +1,882 @@ +/* +Ambient API Server + +Ambient API Server + +API version: 1.0.0 +Contact: ambient-code@redhat.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package openapi + +import ( + "encoding/json" + "time" +) + +// checks if the ApplicationPatchRequest type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ApplicationPatchRequest{} + +// ApplicationPatchRequest struct for ApplicationPatchRequest +type ApplicationPatchRequest struct { + Name *string `json:"name,omitempty"` + SourceRepoUrl *string `json:"source_repo_url,omitempty"` + SourceTargetRevision *string `json:"source_target_revision,omitempty"` + SourcePath *string `json:"source_path,omitempty"` + DestinationAmbientUrl *string `json:"destination_ambient_url,omitempty"` + DestinationProject *string `json:"destination_project,omitempty"` + CredentialId *string `json:"credential_id,omitempty"` + AutoSync *bool `json:"auto_sync,omitempty"` + AutoPrune *bool `json:"auto_prune,omitempty"` + SelfHeal *bool `json:"self_heal,omitempty"` + SyncOptions *string `json:"sync_options,omitempty"` + RetryLimit *int32 `json:"retry_limit,omitempty"` + SyncStatus *string `json:"sync_status,omitempty"` + HealthStatus *string `json:"health_status,omitempty"` + SyncRevision *string `json:"sync_revision,omitempty"` + OperationPhase *string `json:"operation_phase,omitempty"` + OperationMessage *string `json:"operation_message,omitempty"` + ResourceStatus *string `json:"resource_status,omitempty"` + Conditions *string `json:"conditions,omitempty"` + Labels *string `json:"labels,omitempty"` + Annotations *string `json:"annotations,omitempty"` + LastSyncedAt *time.Time `json:"last_synced_at,omitempty"` +} + +// NewApplicationPatchRequest instantiates a new ApplicationPatchRequest object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewApplicationPatchRequest() *ApplicationPatchRequest { + this := ApplicationPatchRequest{} + return &this +} + +// NewApplicationPatchRequestWithDefaults instantiates a new ApplicationPatchRequest object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewApplicationPatchRequestWithDefaults() *ApplicationPatchRequest { + this := ApplicationPatchRequest{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *ApplicationPatchRequest) SetName(v string) { + o.Name = &v +} + +// GetSourceRepoUrl returns the SourceRepoUrl field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetSourceRepoUrl() string { + if o == nil || IsNil(o.SourceRepoUrl) { + var ret string + return ret + } + return *o.SourceRepoUrl +} + +// GetSourceRepoUrlOk returns a tuple with the SourceRepoUrl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetSourceRepoUrlOk() (*string, bool) { + if o == nil || IsNil(o.SourceRepoUrl) { + return nil, false + } + return o.SourceRepoUrl, true +} + +// HasSourceRepoUrl returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasSourceRepoUrl() bool { + if o != nil && !IsNil(o.SourceRepoUrl) { + return true + } + + return false +} + +// SetSourceRepoUrl gets a reference to the given string and assigns it to the SourceRepoUrl field. +func (o *ApplicationPatchRequest) SetSourceRepoUrl(v string) { + o.SourceRepoUrl = &v +} + +// GetSourceTargetRevision returns the SourceTargetRevision field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetSourceTargetRevision() string { + if o == nil || IsNil(o.SourceTargetRevision) { + var ret string + return ret + } + return *o.SourceTargetRevision +} + +// GetSourceTargetRevisionOk returns a tuple with the SourceTargetRevision field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetSourceTargetRevisionOk() (*string, bool) { + if o == nil || IsNil(o.SourceTargetRevision) { + return nil, false + } + return o.SourceTargetRevision, true +} + +// HasSourceTargetRevision returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasSourceTargetRevision() bool { + if o != nil && !IsNil(o.SourceTargetRevision) { + return true + } + + return false +} + +// SetSourceTargetRevision gets a reference to the given string and assigns it to the SourceTargetRevision field. +func (o *ApplicationPatchRequest) SetSourceTargetRevision(v string) { + o.SourceTargetRevision = &v +} + +// GetSourcePath returns the SourcePath field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetSourcePath() string { + if o == nil || IsNil(o.SourcePath) { + var ret string + return ret + } + return *o.SourcePath +} + +// GetSourcePathOk returns a tuple with the SourcePath field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetSourcePathOk() (*string, bool) { + if o == nil || IsNil(o.SourcePath) { + return nil, false + } + return o.SourcePath, true +} + +// HasSourcePath returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasSourcePath() bool { + if o != nil && !IsNil(o.SourcePath) { + return true + } + + return false +} + +// SetSourcePath gets a reference to the given string and assigns it to the SourcePath field. +func (o *ApplicationPatchRequest) SetSourcePath(v string) { + o.SourcePath = &v +} + +// GetDestinationAmbientUrl returns the DestinationAmbientUrl field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetDestinationAmbientUrl() string { + if o == nil || IsNil(o.DestinationAmbientUrl) { + var ret string + return ret + } + return *o.DestinationAmbientUrl +} + +// GetDestinationAmbientUrlOk returns a tuple with the DestinationAmbientUrl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetDestinationAmbientUrlOk() (*string, bool) { + if o == nil || IsNil(o.DestinationAmbientUrl) { + return nil, false + } + return o.DestinationAmbientUrl, true +} + +// HasDestinationAmbientUrl returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasDestinationAmbientUrl() bool { + if o != nil && !IsNil(o.DestinationAmbientUrl) { + return true + } + + return false +} + +// SetDestinationAmbientUrl gets a reference to the given string and assigns it to the DestinationAmbientUrl field. +func (o *ApplicationPatchRequest) SetDestinationAmbientUrl(v string) { + o.DestinationAmbientUrl = &v +} + +// GetDestinationProject returns the DestinationProject field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetDestinationProject() string { + if o == nil || IsNil(o.DestinationProject) { + var ret string + return ret + } + return *o.DestinationProject +} + +// GetDestinationProjectOk returns a tuple with the DestinationProject field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetDestinationProjectOk() (*string, bool) { + if o == nil || IsNil(o.DestinationProject) { + return nil, false + } + return o.DestinationProject, true +} + +// HasDestinationProject returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasDestinationProject() bool { + if o != nil && !IsNil(o.DestinationProject) { + return true + } + + return false +} + +// SetDestinationProject gets a reference to the given string and assigns it to the DestinationProject field. +func (o *ApplicationPatchRequest) SetDestinationProject(v string) { + o.DestinationProject = &v +} + +// GetCredentialId returns the CredentialId field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetCredentialId() string { + if o == nil || IsNil(o.CredentialId) { + var ret string + return ret + } + return *o.CredentialId +} + +// GetCredentialIdOk returns a tuple with the CredentialId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetCredentialIdOk() (*string, bool) { + if o == nil || IsNil(o.CredentialId) { + return nil, false + } + return o.CredentialId, true +} + +// HasCredentialId returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasCredentialId() bool { + if o != nil && !IsNil(o.CredentialId) { + return true + } + + return false +} + +// SetCredentialId gets a reference to the given string and assigns it to the CredentialId field. +func (o *ApplicationPatchRequest) SetCredentialId(v string) { + o.CredentialId = &v +} + +// GetAutoSync returns the AutoSync field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetAutoSync() bool { + if o == nil || IsNil(o.AutoSync) { + var ret bool + return ret + } + return *o.AutoSync +} + +// GetAutoSyncOk returns a tuple with the AutoSync field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetAutoSyncOk() (*bool, bool) { + if o == nil || IsNil(o.AutoSync) { + return nil, false + } + return o.AutoSync, true +} + +// HasAutoSync returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasAutoSync() bool { + if o != nil && !IsNil(o.AutoSync) { + return true + } + + return false +} + +// SetAutoSync gets a reference to the given bool and assigns it to the AutoSync field. +func (o *ApplicationPatchRequest) SetAutoSync(v bool) { + o.AutoSync = &v +} + +// GetAutoPrune returns the AutoPrune field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetAutoPrune() bool { + if o == nil || IsNil(o.AutoPrune) { + var ret bool + return ret + } + return *o.AutoPrune +} + +// GetAutoPruneOk returns a tuple with the AutoPrune field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetAutoPruneOk() (*bool, bool) { + if o == nil || IsNil(o.AutoPrune) { + return nil, false + } + return o.AutoPrune, true +} + +// HasAutoPrune returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasAutoPrune() bool { + if o != nil && !IsNil(o.AutoPrune) { + return true + } + + return false +} + +// SetAutoPrune gets a reference to the given bool and assigns it to the AutoPrune field. +func (o *ApplicationPatchRequest) SetAutoPrune(v bool) { + o.AutoPrune = &v +} + +// GetSelfHeal returns the SelfHeal field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetSelfHeal() bool { + if o == nil || IsNil(o.SelfHeal) { + var ret bool + return ret + } + return *o.SelfHeal +} + +// GetSelfHealOk returns a tuple with the SelfHeal field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetSelfHealOk() (*bool, bool) { + if o == nil || IsNil(o.SelfHeal) { + return nil, false + } + return o.SelfHeal, true +} + +// HasSelfHeal returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasSelfHeal() bool { + if o != nil && !IsNil(o.SelfHeal) { + return true + } + + return false +} + +// SetSelfHeal gets a reference to the given bool and assigns it to the SelfHeal field. +func (o *ApplicationPatchRequest) SetSelfHeal(v bool) { + o.SelfHeal = &v +} + +// GetSyncOptions returns the SyncOptions field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetSyncOptions() string { + if o == nil || IsNil(o.SyncOptions) { + var ret string + return ret + } + return *o.SyncOptions +} + +// GetSyncOptionsOk returns a tuple with the SyncOptions field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetSyncOptionsOk() (*string, bool) { + if o == nil || IsNil(o.SyncOptions) { + return nil, false + } + return o.SyncOptions, true +} + +// HasSyncOptions returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasSyncOptions() bool { + if o != nil && !IsNil(o.SyncOptions) { + return true + } + + return false +} + +// SetSyncOptions gets a reference to the given string and assigns it to the SyncOptions field. +func (o *ApplicationPatchRequest) SetSyncOptions(v string) { + o.SyncOptions = &v +} + +// GetRetryLimit returns the RetryLimit field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetRetryLimit() int32 { + if o == nil || IsNil(o.RetryLimit) { + var ret int32 + return ret + } + return *o.RetryLimit +} + +// GetRetryLimitOk returns a tuple with the RetryLimit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetRetryLimitOk() (*int32, bool) { + if o == nil || IsNil(o.RetryLimit) { + return nil, false + } + return o.RetryLimit, true +} + +// HasRetryLimit returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasRetryLimit() bool { + if o != nil && !IsNil(o.RetryLimit) { + return true + } + + return false +} + +// SetRetryLimit gets a reference to the given int32 and assigns it to the RetryLimit field. +func (o *ApplicationPatchRequest) SetRetryLimit(v int32) { + o.RetryLimit = &v +} + +// GetSyncStatus returns the SyncStatus field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetSyncStatus() string { + if o == nil || IsNil(o.SyncStatus) { + var ret string + return ret + } + return *o.SyncStatus +} + +// GetSyncStatusOk returns a tuple with the SyncStatus field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetSyncStatusOk() (*string, bool) { + if o == nil || IsNil(o.SyncStatus) { + return nil, false + } + return o.SyncStatus, true +} + +// HasSyncStatus returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasSyncStatus() bool { + if o != nil && !IsNil(o.SyncStatus) { + return true + } + + return false +} + +// SetSyncStatus gets a reference to the given string and assigns it to the SyncStatus field. +func (o *ApplicationPatchRequest) SetSyncStatus(v string) { + o.SyncStatus = &v +} + +// GetHealthStatus returns the HealthStatus field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetHealthStatus() string { + if o == nil || IsNil(o.HealthStatus) { + var ret string + return ret + } + return *o.HealthStatus +} + +// GetHealthStatusOk returns a tuple with the HealthStatus field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetHealthStatusOk() (*string, bool) { + if o == nil || IsNil(o.HealthStatus) { + return nil, false + } + return o.HealthStatus, true +} + +// HasHealthStatus returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasHealthStatus() bool { + if o != nil && !IsNil(o.HealthStatus) { + return true + } + + return false +} + +// SetHealthStatus gets a reference to the given string and assigns it to the HealthStatus field. +func (o *ApplicationPatchRequest) SetHealthStatus(v string) { + o.HealthStatus = &v +} + +// GetSyncRevision returns the SyncRevision field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetSyncRevision() string { + if o == nil || IsNil(o.SyncRevision) { + var ret string + return ret + } + return *o.SyncRevision +} + +// GetSyncRevisionOk returns a tuple with the SyncRevision field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetSyncRevisionOk() (*string, bool) { + if o == nil || IsNil(o.SyncRevision) { + return nil, false + } + return o.SyncRevision, true +} + +// HasSyncRevision returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasSyncRevision() bool { + if o != nil && !IsNil(o.SyncRevision) { + return true + } + + return false +} + +// SetSyncRevision gets a reference to the given string and assigns it to the SyncRevision field. +func (o *ApplicationPatchRequest) SetSyncRevision(v string) { + o.SyncRevision = &v +} + +// GetOperationPhase returns the OperationPhase field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetOperationPhase() string { + if o == nil || IsNil(o.OperationPhase) { + var ret string + return ret + } + return *o.OperationPhase +} + +// GetOperationPhaseOk returns a tuple with the OperationPhase field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetOperationPhaseOk() (*string, bool) { + if o == nil || IsNil(o.OperationPhase) { + return nil, false + } + return o.OperationPhase, true +} + +// HasOperationPhase returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasOperationPhase() bool { + if o != nil && !IsNil(o.OperationPhase) { + return true + } + + return false +} + +// SetOperationPhase gets a reference to the given string and assigns it to the OperationPhase field. +func (o *ApplicationPatchRequest) SetOperationPhase(v string) { + o.OperationPhase = &v +} + +// GetOperationMessage returns the OperationMessage field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetOperationMessage() string { + if o == nil || IsNil(o.OperationMessage) { + var ret string + return ret + } + return *o.OperationMessage +} + +// GetOperationMessageOk returns a tuple with the OperationMessage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetOperationMessageOk() (*string, bool) { + if o == nil || IsNil(o.OperationMessage) { + return nil, false + } + return o.OperationMessage, true +} + +// HasOperationMessage returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasOperationMessage() bool { + if o != nil && !IsNil(o.OperationMessage) { + return true + } + + return false +} + +// SetOperationMessage gets a reference to the given string and assigns it to the OperationMessage field. +func (o *ApplicationPatchRequest) SetOperationMessage(v string) { + o.OperationMessage = &v +} + +// GetResourceStatus returns the ResourceStatus field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetResourceStatus() string { + if o == nil || IsNil(o.ResourceStatus) { + var ret string + return ret + } + return *o.ResourceStatus +} + +// GetResourceStatusOk returns a tuple with the ResourceStatus field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetResourceStatusOk() (*string, bool) { + if o == nil || IsNil(o.ResourceStatus) { + return nil, false + } + return o.ResourceStatus, true +} + +// HasResourceStatus returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasResourceStatus() bool { + if o != nil && !IsNil(o.ResourceStatus) { + return true + } + + return false +} + +// SetResourceStatus gets a reference to the given string and assigns it to the ResourceStatus field. +func (o *ApplicationPatchRequest) SetResourceStatus(v string) { + o.ResourceStatus = &v +} + +// GetConditions returns the Conditions field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetConditions() string { + if o == nil || IsNil(o.Conditions) { + var ret string + return ret + } + return *o.Conditions +} + +// GetConditionsOk returns a tuple with the Conditions field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetConditionsOk() (*string, bool) { + if o == nil || IsNil(o.Conditions) { + return nil, false + } + return o.Conditions, true +} + +// HasConditions returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasConditions() bool { + if o != nil && !IsNil(o.Conditions) { + return true + } + + return false +} + +// SetConditions gets a reference to the given string and assigns it to the Conditions field. +func (o *ApplicationPatchRequest) SetConditions(v string) { + o.Conditions = &v +} + +// GetLabels returns the Labels field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetLabels() string { + if o == nil || IsNil(o.Labels) { + var ret string + return ret + } + return *o.Labels +} + +// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetLabelsOk() (*string, bool) { + if o == nil || IsNil(o.Labels) { + return nil, false + } + return o.Labels, true +} + +// HasLabels returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasLabels() bool { + if o != nil && !IsNil(o.Labels) { + return true + } + + return false +} + +// SetLabels gets a reference to the given string and assigns it to the Labels field. +func (o *ApplicationPatchRequest) SetLabels(v string) { + o.Labels = &v +} + +// GetAnnotations returns the Annotations field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetAnnotations() string { + if o == nil || IsNil(o.Annotations) { + var ret string + return ret + } + return *o.Annotations +} + +// GetAnnotationsOk returns a tuple with the Annotations field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetAnnotationsOk() (*string, bool) { + if o == nil || IsNil(o.Annotations) { + return nil, false + } + return o.Annotations, true +} + +// HasAnnotations returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasAnnotations() bool { + if o != nil && !IsNil(o.Annotations) { + return true + } + + return false +} + +// SetAnnotations gets a reference to the given string and assigns it to the Annotations field. +func (o *ApplicationPatchRequest) SetAnnotations(v string) { + o.Annotations = &v +} + +// GetLastSyncedAt returns the LastSyncedAt field value if set, zero value otherwise. +func (o *ApplicationPatchRequest) GetLastSyncedAt() time.Time { + if o == nil || IsNil(o.LastSyncedAt) { + var ret time.Time + return ret + } + return *o.LastSyncedAt +} + +// GetLastSyncedAtOk returns a tuple with the LastSyncedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationPatchRequest) GetLastSyncedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.LastSyncedAt) { + return nil, false + } + return o.LastSyncedAt, true +} + +// HasLastSyncedAt returns a boolean if a field has been set. +func (o *ApplicationPatchRequest) HasLastSyncedAt() bool { + if o != nil && !IsNil(o.LastSyncedAt) { + return true + } + + return false +} + +// SetLastSyncedAt gets a reference to the given time.Time and assigns it to the LastSyncedAt field. +func (o *ApplicationPatchRequest) SetLastSyncedAt(v time.Time) { + o.LastSyncedAt = &v +} + +func (o ApplicationPatchRequest) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ApplicationPatchRequest) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.SourceRepoUrl) { + toSerialize["source_repo_url"] = o.SourceRepoUrl + } + if !IsNil(o.SourceTargetRevision) { + toSerialize["source_target_revision"] = o.SourceTargetRevision + } + if !IsNil(o.SourcePath) { + toSerialize["source_path"] = o.SourcePath + } + if !IsNil(o.DestinationAmbientUrl) { + toSerialize["destination_ambient_url"] = o.DestinationAmbientUrl + } + if !IsNil(o.DestinationProject) { + toSerialize["destination_project"] = o.DestinationProject + } + if !IsNil(o.CredentialId) { + toSerialize["credential_id"] = o.CredentialId + } + if !IsNil(o.AutoSync) { + toSerialize["auto_sync"] = o.AutoSync + } + if !IsNil(o.AutoPrune) { + toSerialize["auto_prune"] = o.AutoPrune + } + if !IsNil(o.SelfHeal) { + toSerialize["self_heal"] = o.SelfHeal + } + if !IsNil(o.SyncOptions) { + toSerialize["sync_options"] = o.SyncOptions + } + if !IsNil(o.RetryLimit) { + toSerialize["retry_limit"] = o.RetryLimit + } + if !IsNil(o.SyncStatus) { + toSerialize["sync_status"] = o.SyncStatus + } + if !IsNil(o.HealthStatus) { + toSerialize["health_status"] = o.HealthStatus + } + if !IsNil(o.SyncRevision) { + toSerialize["sync_revision"] = o.SyncRevision + } + if !IsNil(o.OperationPhase) { + toSerialize["operation_phase"] = o.OperationPhase + } + if !IsNil(o.OperationMessage) { + toSerialize["operation_message"] = o.OperationMessage + } + if !IsNil(o.ResourceStatus) { + toSerialize["resource_status"] = o.ResourceStatus + } + if !IsNil(o.Conditions) { + toSerialize["conditions"] = o.Conditions + } + if !IsNil(o.Labels) { + toSerialize["labels"] = o.Labels + } + if !IsNil(o.Annotations) { + toSerialize["annotations"] = o.Annotations + } + if !IsNil(o.LastSyncedAt) { + toSerialize["last_synced_at"] = o.LastSyncedAt + } + return toSerialize, nil +} + +type NullableApplicationPatchRequest struct { + value *ApplicationPatchRequest + isSet bool +} + +func (v NullableApplicationPatchRequest) Get() *ApplicationPatchRequest { + return v.value +} + +func (v *NullableApplicationPatchRequest) Set(val *ApplicationPatchRequest) { + v.value = val + v.isSet = true +} + +func (v NullableApplicationPatchRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableApplicationPatchRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableApplicationPatchRequest(val *ApplicationPatchRequest) *NullableApplicationPatchRequest { + return &NullableApplicationPatchRequest{value: val, isSet: true} +} + +func (v NullableApplicationPatchRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableApplicationPatchRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/components/ambient-api-server/pkg/rbac/hierarchy.go b/components/ambient-api-server/pkg/rbac/hierarchy.go index 95f85eb2d..69d4c6756 100644 --- a/components/ambient-api-server/pkg/rbac/hierarchy.go +++ b/components/ambient-api-server/pkg/rbac/hierarchy.go @@ -5,6 +5,7 @@ var RoleLevel = map[string]int{ RoleProjectOwner: 1, RoleCredentialOwner: 1, + RoleGitOpsAdmin: 1, RolePlatformViewer: 2, RoleProjectEditor: 2, @@ -16,6 +17,7 @@ var RoleLevel = map[string]int{ RoleProjectViewer: 3, RoleAgentObserver: 3, + RoleGitOpsViewer: 3, } var InternalRoles = map[string]bool{ diff --git a/components/ambient-api-server/pkg/rbac/middleware.go b/components/ambient-api-server/pkg/rbac/middleware.go index 50fb0460e..bac61f595 100644 --- a/components/ambient-api-server/pkg/rbac/middleware.go +++ b/components/ambient-api-server/pkg/rbac/middleware.go @@ -437,6 +437,8 @@ func pathToAction(method, path string) string { return "fetch_token" case "start", "stop": return last + case "sync", "refresh": + return "update" } } } diff --git a/components/ambient-api-server/pkg/rbac/permissions.go b/components/ambient-api-server/pkg/rbac/permissions.go index 8257459a4..ed7c5902f 100644 --- a/components/ambient-api-server/pkg/rbac/permissions.go +++ b/components/ambient-api-server/pkg/rbac/permissions.go @@ -13,6 +13,7 @@ const ( ResourceRole Resource = "role" ResourceRoleBinding Resource = "role_binding" ResourceCredential Resource = "credential" + ResourceApplication Resource = "application" ) type Action string @@ -54,6 +55,9 @@ const ( RoleCredentialOwner = "credential:owner" RoleCredentialReader = "credential:reader" RoleCredentialTokenReader = "credential:token-reader" + + RoleGitOpsAdmin = "gitops:admin" + RoleGitOpsViewer = "gitops:viewer" ) var ( @@ -104,4 +108,10 @@ var ( PermCredentialDelete = Permission{ResourceCredential, ActionDelete} PermCredentialList = Permission{ResourceCredential, ActionList} PermCredentialFetchToken = Permission{ResourceCredential, ActionFetchToken} + + PermApplicationCreate = Permission{ResourceApplication, ActionCreate} + PermApplicationRead = Permission{ResourceApplication, ActionRead} + PermApplicationUpdate = Permission{ResourceApplication, ActionUpdate} + PermApplicationDelete = Permission{ResourceApplication, ActionDelete} + PermApplicationList = Permission{ResourceApplication, ActionList} ) diff --git a/components/ambient-api-server/pkg/rbac/scope.go b/components/ambient-api-server/pkg/rbac/scope.go index 4ab1f5cc9..7ff08ec6e 100644 --- a/components/ambient-api-server/pkg/rbac/scope.go +++ b/components/ambient-api-server/pkg/rbac/scope.go @@ -138,7 +138,7 @@ func isListEndpoint(method, path string) bool { last := segments[len(segments)-1] switch last { case "projects", "agents", "sessions", "credentials", "roles", "role_bindings", - "users", "inbox", "session_messages", "scheduled-sessions", "messages": + "users", "inbox", "session_messages", "scheduled-sessions", "messages", "applications": return true } return false diff --git a/components/ambient-api-server/plugins/applications/dao.go b/components/ambient-api-server/plugins/applications/dao.go new file mode 100644 index 000000000..a2ed3d1b8 --- /dev/null +++ b/components/ambient-api-server/plugins/applications/dao.go @@ -0,0 +1,83 @@ +package applications + +import ( + "context" + + "gorm.io/gorm/clause" + + "github.com/openshift-online/rh-trex-ai/pkg/api" + "github.com/openshift-online/rh-trex-ai/pkg/db" +) + +type ApplicationDao interface { + Get(ctx context.Context, id string) (*Application, error) + Create(ctx context.Context, application *Application) (*Application, error) + Replace(ctx context.Context, application *Application) (*Application, error) + Delete(ctx context.Context, id string) error + FindByIDs(ctx context.Context, ids []string) (ApplicationList, error) + All(ctx context.Context) (ApplicationList, error) +} + +var _ ApplicationDao = &sqlApplicationDao{} + +type sqlApplicationDao struct { + sessionFactory *db.SessionFactory +} + +func NewApplicationDao(sessionFactory *db.SessionFactory) ApplicationDao { + return &sqlApplicationDao{sessionFactory: sessionFactory} +} + +func (d *sqlApplicationDao) Get(ctx context.Context, id string) (*Application, error) { + g2 := (*d.sessionFactory).New(ctx) + var application Application + if err := g2.Take(&application, "id = ?", id).Error; err != nil { + return nil, err + } + return &application, nil +} + +func (d *sqlApplicationDao) Create(ctx context.Context, application *Application) (*Application, error) { + g2 := (*d.sessionFactory).New(ctx) + if err := g2.Omit(clause.Associations).Create(application).Error; err != nil { + db.MarkForRollback(ctx, err) + return nil, err + } + return application, nil +} + +func (d *sqlApplicationDao) Replace(ctx context.Context, application *Application) (*Application, error) { + g2 := (*d.sessionFactory).New(ctx) + if err := g2.Omit(clause.Associations).Save(application).Error; err != nil { + db.MarkForRollback(ctx, err) + return nil, err + } + return application, nil +} + +func (d *sqlApplicationDao) Delete(ctx context.Context, id string) error { + g2 := (*d.sessionFactory).New(ctx) + if err := g2.Omit(clause.Associations).Delete(&Application{Meta: api.Meta{ID: id}}).Error; err != nil { + db.MarkForRollback(ctx, err) + return err + } + return nil +} + +func (d *sqlApplicationDao) FindByIDs(ctx context.Context, ids []string) (ApplicationList, error) { + g2 := (*d.sessionFactory).New(ctx) + applications := ApplicationList{} + if err := g2.Where("id in (?)", ids).Find(&applications).Error; err != nil { + return nil, err + } + return applications, nil +} + +func (d *sqlApplicationDao) All(ctx context.Context) (ApplicationList, error) { + g2 := (*d.sessionFactory).New(ctx) + applications := ApplicationList{} + if err := g2.Find(&applications).Error; err != nil { + return nil, err + } + return applications, nil +} diff --git a/components/ambient-api-server/plugins/applications/factory_test.go b/components/ambient-api-server/plugins/applications/factory_test.go new file mode 100644 index 000000000..6f4eb90bd --- /dev/null +++ b/components/ambient-api-server/plugins/applications/factory_test.go @@ -0,0 +1,63 @@ +package applications_test + +import ( + "context" + "fmt" + "time" + + "github.com/ambient-code/platform/components/ambient-api-server/plugins/applications" + "github.com/openshift-online/rh-trex-ai/pkg/environments" +) + +func newApplication(id string) (*applications.Application, error) { + applicationService := applications.Service(&environments.Environment().Services) + + application := &applications.Application{ + Name: "test-name", + SourceRepoUrl: "test-source_repo_url", + SourceTargetRevision: stringPtr("test-source_target_revision"), + SourcePath: "test-source_path", + DestinationAmbientUrl: stringPtr("test-destination_ambient_url"), + DestinationProject: "test-destination_project", + CredentialId: stringPtr("test-credential_id"), + AutoSync: boolPtr(true), + AutoPrune: boolPtr(true), + SelfHeal: boolPtr(true), + SyncOptions: stringPtr("test-sync_options"), + RetryLimit: intPtr(42), + SyncStatus: stringPtr("test-sync_status"), + HealthStatus: stringPtr("test-health_status"), + SyncRevision: stringPtr("test-sync_revision"), + OperationPhase: stringPtr("test-operation_phase"), + OperationMessage: stringPtr("test-operation_message"), + ResourceStatus: stringPtr("test-resource_status"), + Conditions: stringPtr("test-conditions"), + Labels: stringPtr("test-labels"), + Annotations: stringPtr("test-annotations"), + LastSyncedAt: timePtr(time.Now()), + } + + sub, err := applicationService.Create(context.Background(), application) + if err != nil { + return nil, err + } + + return sub, nil +} + +func newApplicationList(namePrefix string, count int) ([]*applications.Application, error) { + var items []*applications.Application + for i := 1; i <= count; i++ { + name := fmt.Sprintf("%s_%d", namePrefix, i) + c, err := newApplication(name) + if err != nil { + return nil, err + } + items = append(items, c) + } + return items, nil +} +func stringPtr(s string) *string { return &s } +func intPtr(i int) *int { return &i } +func boolPtr(b bool) *bool { return &b } +func timePtr(t time.Time) *time.Time { return &t } diff --git a/components/ambient-api-server/plugins/applications/handler.go b/components/ambient-api-server/plugins/applications/handler.go new file mode 100644 index 000000000..535a05450 --- /dev/null +++ b/components/ambient-api-server/plugins/applications/handler.go @@ -0,0 +1,269 @@ +package applications + +import ( + "net/http" + + "github.com/gorilla/mux" + + "github.com/ambient-code/platform/components/ambient-api-server/pkg/api/openapi" + "github.com/openshift-online/rh-trex-ai/pkg/api/presenters" + "github.com/openshift-online/rh-trex-ai/pkg/errors" + "github.com/openshift-online/rh-trex-ai/pkg/handlers" + "github.com/openshift-online/rh-trex-ai/pkg/services" +) + +var _ handlers.RestHandler = applicationHandler{} + +type applicationHandler struct { + application ApplicationService + generic services.GenericService +} + +func NewApplicationHandler(application ApplicationService, generic services.GenericService) *applicationHandler { + return &applicationHandler{ + application: application, + generic: generic, + } +} + +func (h applicationHandler) Create(w http.ResponseWriter, r *http.Request) { + var application openapi.Application + cfg := &handlers.HandlerConfig{ + Body: &application, + Validators: []handlers.Validate{ + handlers.ValidateEmpty(&application, "Id", "id"), + }, + Action: func() (interface{}, *errors.ServiceError) { + ctx := r.Context() + applicationModel := ConvertApplication(application) + applicationModel, err := h.application.Create(ctx, applicationModel) + if err != nil { + return nil, err + } + return PresentApplication(applicationModel), nil + }, + ErrorHandler: handlers.HandleError, + } + + handlers.Handle(w, r, cfg, http.StatusCreated) +} + +func (h applicationHandler) Patch(w http.ResponseWriter, r *http.Request) { + var patch openapi.ApplicationPatchRequest + + cfg := &handlers.HandlerConfig{ + Body: &patch, + Validators: []handlers.Validate{}, + Action: func() (interface{}, *errors.ServiceError) { + ctx := r.Context() + id := mux.Vars(r)["id"] + found, err := h.application.Get(ctx, id) + if err != nil { + return nil, err + } + + if patch.Name != nil { + found.Name = *patch.Name + } + if patch.SourceRepoUrl != nil { + found.SourceRepoUrl = *patch.SourceRepoUrl + } + if patch.SourceTargetRevision != nil { + found.SourceTargetRevision = patch.SourceTargetRevision + } + if patch.SourcePath != nil { + found.SourcePath = *patch.SourcePath + } + if patch.DestinationAmbientUrl != nil { + found.DestinationAmbientUrl = patch.DestinationAmbientUrl + } + if patch.DestinationProject != nil { + found.DestinationProject = *patch.DestinationProject + } + if patch.CredentialId != nil { + found.CredentialId = patch.CredentialId + } + if patch.AutoSync != nil { + found.AutoSync = patch.AutoSync + } + if patch.AutoPrune != nil { + found.AutoPrune = patch.AutoPrune + } + if patch.SelfHeal != nil { + found.SelfHeal = patch.SelfHeal + } + if patch.SyncOptions != nil { + found.SyncOptions = patch.SyncOptions + } + if patch.RetryLimit != nil { + retryLimitVal := int(*patch.RetryLimit) + found.RetryLimit = &retryLimitVal + } + if patch.SyncStatus != nil { + found.SyncStatus = patch.SyncStatus + } + if patch.HealthStatus != nil { + found.HealthStatus = patch.HealthStatus + } + if patch.SyncRevision != nil { + found.SyncRevision = patch.SyncRevision + } + if patch.OperationPhase != nil { + found.OperationPhase = patch.OperationPhase + } + if patch.OperationMessage != nil { + found.OperationMessage = patch.OperationMessage + } + if patch.ResourceStatus != nil { + found.ResourceStatus = patch.ResourceStatus + } + if patch.Conditions != nil { + found.Conditions = patch.Conditions + } + if patch.Labels != nil { + found.Labels = patch.Labels + } + if patch.Annotations != nil { + found.Annotations = patch.Annotations + } + if patch.LastSyncedAt != nil { + found.LastSyncedAt = patch.LastSyncedAt + } + + applicationModel, err := h.application.Replace(ctx, found) + if err != nil { + return nil, err + } + return PresentApplication(applicationModel), nil + }, + ErrorHandler: handlers.HandleError, + } + + handlers.Handle(w, r, cfg, http.StatusOK) +} + +func (h applicationHandler) List(w http.ResponseWriter, r *http.Request) { + cfg := &handlers.HandlerConfig{ + Action: func() (interface{}, *errors.ServiceError) { + ctx := r.Context() + + listArgs := services.NewListArguments(r.URL.Query()) + var applications []Application + paging, err := h.generic.List(ctx, "id", listArgs, &applications) + if err != nil { + return nil, err + } + applicationList := openapi.ApplicationList{ + Kind: "ApplicationList", + Page: int32(paging.Page), + Size: int32(paging.Size), + Total: int32(paging.Total), + Items: []openapi.Application{}, + } + + for _, application := range applications { + converted := PresentApplication(&application) + applicationList.Items = append(applicationList.Items, converted) + } + if listArgs.Fields != nil { + filteredItems, err := presenters.SliceFilter(listArgs.Fields, applicationList.Items) + if err != nil { + return nil, err + } + return filteredItems, nil + } + return applicationList, nil + }, + } + + handlers.HandleList(w, r, cfg) +} + +func (h applicationHandler) Get(w http.ResponseWriter, r *http.Request) { + cfg := &handlers.HandlerConfig{ + Action: func() (interface{}, *errors.ServiceError) { + id := mux.Vars(r)["id"] + ctx := r.Context() + application, err := h.application.Get(ctx, id) + if err != nil { + return nil, err + } + + return PresentApplication(application), nil + }, + } + + handlers.HandleGet(w, r, cfg) +} + +func (h applicationHandler) Delete(w http.ResponseWriter, r *http.Request) { + cfg := &handlers.HandlerConfig{ + Action: func() (interface{}, *errors.ServiceError) { + id := mux.Vars(r)["id"] + ctx := r.Context() + err := h.application.Delete(ctx, id) + if err != nil { + return nil, err + } + return nil, nil + }, + } + handlers.HandleDelete(w, r, cfg, http.StatusNoContent) +} + +func (h applicationHandler) Sync(w http.ResponseWriter, r *http.Request) { + cfg := &handlers.HandlerConfig{ + Action: func() (interface{}, *errors.ServiceError) { + id := mux.Vars(r)["id"] + ctx := r.Context() + app, err := h.application.Get(ctx, id) + if err != nil { + return nil, err + } + phase := "Running" + app.OperationPhase = &phase + app, err = h.application.Replace(ctx, app) + if err != nil { + return nil, err + } + return PresentApplication(app), nil + }, + } + handlers.HandleGet(w, r, cfg) +} + +func (h applicationHandler) Refresh(w http.ResponseWriter, r *http.Request) { + cfg := &handlers.HandlerConfig{ + Action: func() (interface{}, *errors.ServiceError) { + id := mux.Vars(r)["id"] + ctx := r.Context() + app, err := h.application.Get(ctx, id) + if err != nil { + return nil, err + } + unknown := "Unknown" + app.SyncStatus = &unknown + app, err = h.application.Replace(ctx, app) + if err != nil { + return nil, err + } + return PresentApplication(app), nil + }, + } + handlers.HandleGet(w, r, cfg) +} + +func (h applicationHandler) Status(w http.ResponseWriter, r *http.Request) { + cfg := &handlers.HandlerConfig{ + Action: func() (interface{}, *errors.ServiceError) { + id := mux.Vars(r)["id"] + ctx := r.Context() + app, err := h.application.Get(ctx, id) + if err != nil { + return nil, err + } + return PresentApplication(app), nil + }, + } + handlers.HandleGet(w, r, cfg) +} diff --git a/components/ambient-api-server/plugins/applications/integration_test.go b/components/ambient-api-server/plugins/applications/integration_test.go new file mode 100644 index 000000000..addb31d35 --- /dev/null +++ b/components/ambient-api-server/plugins/applications/integration_test.go @@ -0,0 +1,158 @@ +package applications_test + +import ( + "context" + "fmt" + "net/http" + "testing" + "time" + + . "github.com/onsi/gomega" + "gopkg.in/resty.v1" + + "github.com/ambient-code/platform/components/ambient-api-server/pkg/api/openapi" + "github.com/ambient-code/platform/components/ambient-api-server/test" +) + +func TestApplicationGet(t *testing.T) { + h, client := test.RegisterIntegration(t) + + account := h.NewRandAccount() + ctx := h.NewAuthenticatedContext(account) + + _, _, err := client.DefaultAPI.ApiAmbientV1ApplicationsIdGet(context.Background(), "foo").Execute() + Expect(err).To(HaveOccurred(), "Expected 401 but got nil error") + + _, resp, err := client.DefaultAPI.ApiAmbientV1ApplicationsIdGet(ctx, "foo").Execute() + Expect(err).To(HaveOccurred(), "Expected 404") + Expect(resp.StatusCode).To(Equal(http.StatusNotFound)) + + applicationModel, err := newApplication(h.NewID()) + Expect(err).NotTo(HaveOccurred()) + + applicationOutput, resp, err := client.DefaultAPI.ApiAmbientV1ApplicationsIdGet(ctx, applicationModel.ID).Execute() + Expect(err).NotTo(HaveOccurred()) + Expect(resp.StatusCode).To(Equal(http.StatusOK)) + + Expect(*applicationOutput.Id).To(Equal(applicationModel.ID), "found object does not match test object") + Expect(*applicationOutput.Kind).To(Equal("Application")) + Expect(*applicationOutput.Href).To(Equal(fmt.Sprintf("/api/ambient/v1/applications/%s", applicationModel.ID))) + Expect(*applicationOutput.CreatedAt).To(BeTemporally("~", applicationModel.CreatedAt)) + Expect(*applicationOutput.UpdatedAt).To(BeTemporally("~", applicationModel.UpdatedAt)) +} + +func TestApplicationPost(t *testing.T) { + h, client := test.RegisterIntegration(t) + + account := h.NewRandAccount() + ctx := h.NewAuthenticatedContext(account) + + applicationInput := openapi.Application{ + Name: "test-name", + SourceRepoUrl: "test-source_repo_url", + SourceTargetRevision: openapi.PtrString("test-source_target_revision"), + SourcePath: "test-source_path", + DestinationAmbientUrl: openapi.PtrString("test-destination_ambient_url"), + DestinationProject: "test-destination_project", + CredentialId: openapi.PtrString("test-credential_id"), + AutoSync: openapi.PtrBool(true), + AutoPrune: openapi.PtrBool(true), + SelfHeal: openapi.PtrBool(true), + SyncOptions: openapi.PtrString("test-sync_options"), + RetryLimit: openapi.PtrInt32(42), + SyncStatus: openapi.PtrString("test-sync_status"), + HealthStatus: openapi.PtrString("test-health_status"), + SyncRevision: openapi.PtrString("test-sync_revision"), + OperationPhase: openapi.PtrString("test-operation_phase"), + OperationMessage: openapi.PtrString("test-operation_message"), + ResourceStatus: openapi.PtrString("test-resource_status"), + Conditions: openapi.PtrString("test-conditions"), + Labels: openapi.PtrString("test-labels"), + Annotations: openapi.PtrString("test-annotations"), + LastSyncedAt: openapi.PtrTime(time.Now()), + } + + applicationOutput, resp, err := client.DefaultAPI.ApiAmbientV1ApplicationsPost(ctx).Application(applicationInput).Execute() + Expect(err).NotTo(HaveOccurred(), "Error posting object: %v", err) + Expect(resp.StatusCode).To(Equal(http.StatusCreated)) + Expect(*applicationOutput.Id).NotTo(BeEmpty(), "Expected ID assigned on creation") + Expect(*applicationOutput.Kind).To(Equal("Application")) + Expect(*applicationOutput.Href).To(Equal(fmt.Sprintf("/api/ambient/v1/applications/%s", *applicationOutput.Id))) + + jwtToken := ctx.Value(openapi.ContextAccessToken) + restyResp, _ := resty.R(). + SetHeader("Content-Type", "application/json"). + SetHeader("Authorization", fmt.Sprintf("Bearer %s", jwtToken)). + SetBody(`{ this is invalid }`). + Post(h.RestURL("/applications")) + + Expect(restyResp.StatusCode()).To(Equal(http.StatusBadRequest)) +} + +func TestApplicationPatch(t *testing.T) { + h, client := test.RegisterIntegration(t) + + account := h.NewRandAccount() + ctx := h.NewAuthenticatedContext(account) + + applicationModel, err := newApplication(h.NewID()) + Expect(err).NotTo(HaveOccurred()) + + applicationOutput, resp, err := client.DefaultAPI.ApiAmbientV1ApplicationsIdPatch(ctx, applicationModel.ID).ApplicationPatchRequest(openapi.ApplicationPatchRequest{}).Execute() + Expect(err).NotTo(HaveOccurred(), "Error posting object: %v", err) + Expect(resp.StatusCode).To(Equal(http.StatusOK)) + Expect(*applicationOutput.Id).To(Equal(applicationModel.ID)) + Expect(*applicationOutput.CreatedAt).To(BeTemporally("~", applicationModel.CreatedAt)) + Expect(*applicationOutput.Kind).To(Equal("Application")) + Expect(*applicationOutput.Href).To(Equal(fmt.Sprintf("/api/ambient/v1/applications/%s", *applicationOutput.Id))) + + jwtToken := ctx.Value(openapi.ContextAccessToken) + restyResp, _ := resty.R(). + SetHeader("Content-Type", "application/json"). + SetHeader("Authorization", fmt.Sprintf("Bearer %s", jwtToken)). + SetBody(`{ this is invalid }`). + Patch(h.RestURL("/applications/foo")) + + Expect(restyResp.StatusCode()).To(Equal(http.StatusBadRequest)) +} + +func TestApplicationPaging(t *testing.T) { + h, client := test.RegisterIntegration(t) + + account := h.NewRandAccount() + ctx := h.NewAuthenticatedContext(account) + + _, err := newApplicationList("Bronto", 20) + Expect(err).NotTo(HaveOccurred()) + + list, _, err := client.DefaultAPI.ApiAmbientV1ApplicationsGet(ctx).Execute() + Expect(err).NotTo(HaveOccurred(), "Error getting application list: %v", err) + Expect(len(list.Items)).To(Equal(20)) + Expect(list.Size).To(Equal(int32(20))) + Expect(list.Total).To(Equal(int32(20))) + Expect(list.Page).To(Equal(int32(1))) + + list, _, err = client.DefaultAPI.ApiAmbientV1ApplicationsGet(ctx).Page(2).Size(5).Execute() + Expect(err).NotTo(HaveOccurred(), "Error getting application list: %v", err) + Expect(len(list.Items)).To(Equal(5)) + Expect(list.Size).To(Equal(int32(5))) + Expect(list.Total).To(Equal(int32(20))) + Expect(list.Page).To(Equal(int32(2))) +} + +func TestApplicationListSearch(t *testing.T) { + h, client := test.RegisterIntegration(t) + + account := h.NewRandAccount() + ctx := h.NewAuthenticatedContext(account) + + applications, err := newApplicationList("bronto", 20) + Expect(err).NotTo(HaveOccurred()) + + search := fmt.Sprintf("id in ('%s')", applications[0].ID) + list, _, err := client.DefaultAPI.ApiAmbientV1ApplicationsGet(ctx).Search(search).Execute() + Expect(err).NotTo(HaveOccurred(), "Error getting application list: %v", err) + Expect(len(list.Items)).To(Equal(1)) + Expect(list.Total).To(Equal(int32(1))) + Expect(*list.Items[0].Id).To(Equal(applications[0].ID)) +} diff --git a/components/ambient-api-server/plugins/applications/migration.go b/components/ambient-api-server/plugins/applications/migration.go new file mode 100644 index 000000000..3f352c4cb --- /dev/null +++ b/components/ambient-api-server/plugins/applications/migration.go @@ -0,0 +1,98 @@ +package applications + +import ( + "encoding/json" + "time" + + "gorm.io/gorm" + + "github.com/go-gormigrate/gormigrate/v2" + "github.com/openshift-online/rh-trex-ai/pkg/api" + "github.com/openshift-online/rh-trex-ai/pkg/db" +) + +func migration() *gormigrate.Migration { + type Application struct { + db.Model + Name string + SourceRepoUrl string + SourceTargetRevision *string + SourcePath string + DestinationAmbientUrl *string + DestinationProject string + CredentialId *string + AutoSync *bool + AutoPrune *bool + SelfHeal *bool + SyncOptions *string + RetryLimit *int + SyncStatus *string + HealthStatus *string + SyncRevision *string + OperationPhase *string + OperationMessage *string + ResourceStatus *string + Conditions *string + Labels *string + Annotations *string + LastSyncedAt *time.Time + } + + return &gormigrate.Migration{ + ID: "202606102223", + Migrate: func(tx *gorm.DB) error { + return tx.AutoMigrate(&Application{}) + }, + Rollback: func(tx *gorm.DB) error { + return tx.Migrator().DropTable(&Application{}) + }, + } +} + +func gitopsRolesMigration() *gormigrate.Migration { + seed := []struct { + name string + displayName string + description string + permissions []string + }{ + { + name: "gitops:admin", + displayName: "GitOps Admin", + description: "Full CRUD on applications (GitOps continuous sync)", + permissions: []string{"application:create", "application:read", "application:update", "application:delete", "application:list"}, + }, + { + name: "gitops:viewer", + displayName: "GitOps Viewer", + description: "Read-only access to applications", + permissions: []string{"application:read", "application:list"}, + }, + } + + return &gormigrate.Migration{ + ID: "202606102224", + Migrate: func(tx *gorm.DB) error { + for _, r := range seed { + permsJSON, err := json.Marshal(r.permissions) + if err != nil { + return err + } + if err := tx.Exec( + `INSERT INTO roles (id, name, display_name, description, permissions, built_in) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT (name) DO NOTHING`, + api.NewID(), r.name, r.displayName, r.description, string(permsJSON), true, + ).Error; err != nil { + return err + } + } + return nil + }, + Rollback: func(tx *gorm.DB) error { + names := make([]string, len(seed)) + for i, r := range seed { + names[i] = r.name + } + return tx.Exec("DELETE FROM roles WHERE name IN ?", names).Error + }, + } +} diff --git a/components/ambient-api-server/plugins/applications/mock_dao.go b/components/ambient-api-server/plugins/applications/mock_dao.go new file mode 100644 index 000000000..786b10d5e --- /dev/null +++ b/components/ambient-api-server/plugins/applications/mock_dao.go @@ -0,0 +1,49 @@ +package applications + +import ( + "context" + + "gorm.io/gorm" + + "github.com/openshift-online/rh-trex-ai/pkg/errors" +) + +var _ ApplicationDao = &applicationDaoMock{} + +type applicationDaoMock struct { + applications ApplicationList +} + +func NewMockApplicationDao() *applicationDaoMock { + return &applicationDaoMock{} +} + +func (d *applicationDaoMock) Get(ctx context.Context, id string) (*Application, error) { + for _, application := range d.applications { + if application.ID == id { + return application, nil + } + } + return nil, gorm.ErrRecordNotFound +} + +func (d *applicationDaoMock) Create(ctx context.Context, application *Application) (*Application, error) { + d.applications = append(d.applications, application) + return application, nil +} + +func (d *applicationDaoMock) Replace(ctx context.Context, application *Application) (*Application, error) { + return nil, errors.NotImplemented("Application").AsError() +} + +func (d *applicationDaoMock) Delete(ctx context.Context, id string) error { + return errors.NotImplemented("Application").AsError() +} + +func (d *applicationDaoMock) FindByIDs(ctx context.Context, ids []string) (ApplicationList, error) { + return nil, errors.NotImplemented("Application").AsError() +} + +func (d *applicationDaoMock) All(ctx context.Context) (ApplicationList, error) { + return d.applications, nil +} diff --git a/components/ambient-api-server/plugins/applications/model.go b/components/ambient-api-server/plugins/applications/model.go new file mode 100644 index 000000000..5f63076d5 --- /dev/null +++ b/components/ambient-api-server/plugins/applications/model.go @@ -0,0 +1,75 @@ +package applications + +import ( + "time" + + "github.com/openshift-online/rh-trex-ai/pkg/api" + "gorm.io/gorm" +) + +type Application struct { + api.Meta + Name string `json:"name"` + SourceRepoUrl string `json:"source_repo_url"` + SourceTargetRevision *string `json:"source_target_revision"` + SourcePath string `json:"source_path"` + DestinationAmbientUrl *string `json:"destination_ambient_url"` + DestinationProject string `json:"destination_project"` + CredentialId *string `json:"credential_id"` + AutoSync *bool `json:"auto_sync"` + AutoPrune *bool `json:"auto_prune"` + SelfHeal *bool `json:"self_heal"` + SyncOptions *string `json:"sync_options"` + RetryLimit *int `json:"retry_limit"` + SyncStatus *string `json:"sync_status"` + HealthStatus *string `json:"health_status"` + SyncRevision *string `json:"sync_revision"` + OperationPhase *string `json:"operation_phase"` + OperationMessage *string `json:"operation_message"` + ResourceStatus *string `json:"resource_status"` + Conditions *string `json:"conditions"` + Labels *string `json:"labels"` + Annotations *string `json:"annotations"` + LastSyncedAt *time.Time `json:"last_synced_at"` +} + +type ApplicationList []*Application +type ApplicationIndex map[string]*Application + +func (l ApplicationList) Index() ApplicationIndex { + index := ApplicationIndex{} + for _, o := range l { + index[o.ID] = o + } + return index +} + +func (d *Application) BeforeCreate(tx *gorm.DB) error { + d.ID = api.NewID() + return nil +} + +type ApplicationPatchRequest struct { + Name *string `json:"name,omitempty"` + SourceRepoUrl *string `json:"source_repo_url,omitempty"` + SourceTargetRevision *string `json:"source_target_revision,omitempty"` + SourcePath *string `json:"source_path,omitempty"` + DestinationAmbientUrl *string `json:"destination_ambient_url,omitempty"` + DestinationProject *string `json:"destination_project,omitempty"` + CredentialId *string `json:"credential_id,omitempty"` + AutoSync *bool `json:"auto_sync,omitempty"` + AutoPrune *bool `json:"auto_prune,omitempty"` + SelfHeal *bool `json:"self_heal,omitempty"` + SyncOptions *string `json:"sync_options,omitempty"` + RetryLimit *int `json:"retry_limit,omitempty"` + SyncStatus *string `json:"sync_status,omitempty"` + HealthStatus *string `json:"health_status,omitempty"` + SyncRevision *string `json:"sync_revision,omitempty"` + OperationPhase *string `json:"operation_phase,omitempty"` + OperationMessage *string `json:"operation_message,omitempty"` + ResourceStatus *string `json:"resource_status,omitempty"` + Conditions *string `json:"conditions,omitempty"` + Labels *string `json:"labels,omitempty"` + Annotations *string `json:"annotations,omitempty"` + LastSyncedAt *time.Time `json:"last_synced_at,omitempty"` +} diff --git a/components/ambient-api-server/plugins/applications/plugin.go b/components/ambient-api-server/plugins/applications/plugin.go new file mode 100644 index 000000000..0973470ba --- /dev/null +++ b/components/ambient-api-server/plugins/applications/plugin.go @@ -0,0 +1,88 @@ +package applications + +import ( + "net/http" + + pkgrbac "github.com/ambient-code/platform/components/ambient-api-server/plugins/rbac" + "github.com/gorilla/mux" + "github.com/openshift-online/rh-trex-ai/pkg/api" + "github.com/openshift-online/rh-trex-ai/pkg/api/presenters" + "github.com/openshift-online/rh-trex-ai/pkg/auth" + "github.com/openshift-online/rh-trex-ai/pkg/controllers" + "github.com/openshift-online/rh-trex-ai/pkg/db" + "github.com/openshift-online/rh-trex-ai/pkg/environments" + "github.com/openshift-online/rh-trex-ai/pkg/registry" + pkgserver "github.com/openshift-online/rh-trex-ai/pkg/server" + "github.com/openshift-online/rh-trex-ai/plugins/events" + "github.com/openshift-online/rh-trex-ai/plugins/generic" +) + +type ServiceLocator func() ApplicationService + +func NewServiceLocator(env *environments.Env) ServiceLocator { + return func() ApplicationService { + return NewApplicationService( + db.NewAdvisoryLockFactory(env.Database.SessionFactory), + NewApplicationDao(&env.Database.SessionFactory), + events.Service(&env.Services), + ) + } +} + +func Service(s *environments.Services) ApplicationService { + if s == nil { + return nil + } + if obj := s.GetService("Applications"); obj != nil { + locator := obj.(ServiceLocator) + return locator() + } + return nil +} + +func init() { + registry.RegisterService("Applications", func(env interface{}) interface{} { + return NewServiceLocator(env.(*environments.Env)) + }) + + pkgserver.RegisterRoutes("applications", func(apiV1Router *mux.Router, services pkgserver.ServicesInterface, authMiddleware environments.JWTMiddleware, authzMiddleware auth.AuthorizationMiddleware) { + envServices := services.(*environments.Services) + if dbAuthz := pkgrbac.Middleware(envServices); dbAuthz != nil { + authzMiddleware = dbAuthz + } + applicationHandler := NewApplicationHandler(Service(envServices), generic.Service(envServices)) + + applicationsRouter := apiV1Router.PathPrefix("/applications").Subrouter() + applicationsRouter.HandleFunc("", applicationHandler.List).Methods(http.MethodGet) + applicationsRouter.HandleFunc("", applicationHandler.Create).Methods(http.MethodPost) + applicationsRouter.HandleFunc("/{id}", applicationHandler.Get).Methods(http.MethodGet) + applicationsRouter.HandleFunc("/{id}", applicationHandler.Patch).Methods(http.MethodPatch) + applicationsRouter.HandleFunc("/{id}", applicationHandler.Delete).Methods(http.MethodDelete) + applicationsRouter.HandleFunc("/{id}/sync", applicationHandler.Sync).Methods(http.MethodPost) + applicationsRouter.HandleFunc("/{id}/refresh", applicationHandler.Refresh).Methods(http.MethodPost) + applicationsRouter.HandleFunc("/{id}/status", applicationHandler.Status).Methods(http.MethodGet) + applicationsRouter.Use(authMiddleware.AuthenticateAccountJWT) + applicationsRouter.Use(authzMiddleware.AuthorizeApi) + }) + + pkgserver.RegisterController("Applications", func(manager *controllers.KindControllerManager, services pkgserver.ServicesInterface) { + applicationServices := Service(services.(*environments.Services)) + + manager.Add(&controllers.ControllerConfig{ + Source: "Applications", + Handlers: map[api.EventType][]controllers.ControllerHandlerFunc{ + api.CreateEventType: {applicationServices.OnUpsert}, + api.UpdateEventType: {applicationServices.OnUpsert}, + api.DeleteEventType: {applicationServices.OnDelete}, + }, + }) + }) + + presenters.RegisterPath(Application{}, "applications") + presenters.RegisterPath(&Application{}, "applications") + presenters.RegisterKind(Application{}, "Application") + presenters.RegisterKind(&Application{}, "Application") + + db.RegisterMigration(migration()) + db.RegisterMigration(gitopsRolesMigration()) +} diff --git a/components/ambient-api-server/plugins/applications/presenter.go b/components/ambient-api-server/plugins/applications/presenter.go new file mode 100644 index 000000000..e0cf70736 --- /dev/null +++ b/components/ambient-api-server/plugins/applications/presenter.go @@ -0,0 +1,85 @@ +package applications + +import ( + "github.com/ambient-code/platform/components/ambient-api-server/pkg/api/openapi" + "github.com/openshift-online/rh-trex-ai/pkg/api" + "github.com/openshift-online/rh-trex-ai/pkg/api/presenters" + "github.com/openshift-online/rh-trex-ai/pkg/util" +) + +func ConvertApplication(application openapi.Application) *Application { + c := &Application{ + Meta: api.Meta{ + ID: util.NilToEmptyString(application.Id), + }, + } + c.Name = application.Name + c.SourceRepoUrl = application.SourceRepoUrl + c.SourceTargetRevision = application.SourceTargetRevision + c.SourcePath = application.SourcePath + c.DestinationAmbientUrl = application.DestinationAmbientUrl + c.DestinationProject = application.DestinationProject + c.CredentialId = application.CredentialId + c.AutoSync = application.AutoSync + c.AutoPrune = application.AutoPrune + c.SelfHeal = application.SelfHeal + c.SyncOptions = application.SyncOptions + if application.RetryLimit != nil { + c.RetryLimit = openapi.PtrInt(int(*application.RetryLimit)) + } + c.SyncStatus = application.SyncStatus + c.HealthStatus = application.HealthStatus + c.SyncRevision = application.SyncRevision + c.OperationPhase = application.OperationPhase + c.OperationMessage = application.OperationMessage + c.ResourceStatus = application.ResourceStatus + c.Conditions = application.Conditions + c.Labels = application.Labels + c.Annotations = application.Annotations + c.LastSyncedAt = application.LastSyncedAt + + if application.CreatedAt != nil { + c.CreatedAt = *application.CreatedAt + c.UpdatedAt = *application.UpdatedAt + } + + return c +} + +func PresentApplication(application *Application) openapi.Application { + reference := presenters.PresentReference(application.ID, application) + return openapi.Application{ + Id: reference.Id, + Kind: reference.Kind, + Href: reference.Href, + CreatedAt: openapi.PtrTime(application.CreatedAt), + UpdatedAt: openapi.PtrTime(application.UpdatedAt), + Name: application.Name, + SourceRepoUrl: application.SourceRepoUrl, + SourceTargetRevision: application.SourceTargetRevision, + SourcePath: application.SourcePath, + DestinationAmbientUrl: application.DestinationAmbientUrl, + DestinationProject: application.DestinationProject, + CredentialId: application.CredentialId, + AutoSync: application.AutoSync, + AutoPrune: application.AutoPrune, + SelfHeal: application.SelfHeal, + SyncOptions: application.SyncOptions, + RetryLimit: func() *int32 { + if application.RetryLimit != nil { + return openapi.PtrInt32(int32(*application.RetryLimit)) + } + return nil + }(), + SyncStatus: application.SyncStatus, + HealthStatus: application.HealthStatus, + SyncRevision: application.SyncRevision, + OperationPhase: application.OperationPhase, + OperationMessage: application.OperationMessage, + ResourceStatus: application.ResourceStatus, + Conditions: application.Conditions, + Labels: application.Labels, + Annotations: application.Annotations, + LastSyncedAt: application.LastSyncedAt, + } +} diff --git a/components/ambient-api-server/plugins/applications/service.go b/components/ambient-api-server/plugins/applications/service.go new file mode 100644 index 000000000..7f85f8ba4 --- /dev/null +++ b/components/ambient-api-server/plugins/applications/service.go @@ -0,0 +1,162 @@ +package applications + +import ( + "context" + + "github.com/openshift-online/rh-trex-ai/pkg/api" + "github.com/openshift-online/rh-trex-ai/pkg/db" + "github.com/openshift-online/rh-trex-ai/pkg/errors" + "github.com/openshift-online/rh-trex-ai/pkg/logger" + "github.com/openshift-online/rh-trex-ai/pkg/services" +) + +const applicationsLockType db.LockType = "applications" + +var ( + DisableAdvisoryLock = false + UseBlockingAdvisoryLock = true +) + +type ApplicationService interface { + Get(ctx context.Context, id string) (*Application, *errors.ServiceError) + Create(ctx context.Context, application *Application) (*Application, *errors.ServiceError) + Replace(ctx context.Context, application *Application) (*Application, *errors.ServiceError) + Delete(ctx context.Context, id string) *errors.ServiceError + All(ctx context.Context) (ApplicationList, *errors.ServiceError) + + FindByIDs(ctx context.Context, ids []string) (ApplicationList, *errors.ServiceError) + + OnUpsert(ctx context.Context, id string) error + OnDelete(ctx context.Context, id string) error +} + +func NewApplicationService(lockFactory db.LockFactory, applicationDao ApplicationDao, events services.EventService) ApplicationService { + return &sqlApplicationService{ + lockFactory: lockFactory, + applicationDao: applicationDao, + events: events, + } +} + +var _ ApplicationService = &sqlApplicationService{} + +type sqlApplicationService struct { + lockFactory db.LockFactory + applicationDao ApplicationDao + events services.EventService +} + +func (s *sqlApplicationService) OnUpsert(ctx context.Context, id string) error { + logger := logger.NewLogger(ctx) + + application, err := s.applicationDao.Get(ctx, id) + if err != nil { + return err + } + + logger.Infof("Do idempotent somethings with this application: %s", application.ID) + + return nil +} + +func (s *sqlApplicationService) OnDelete(ctx context.Context, id string) error { + logger := logger.NewLogger(ctx) + logger.Infof("This application has been deleted: %s", id) + return nil +} + +func (s *sqlApplicationService) Get(ctx context.Context, id string) (*Application, *errors.ServiceError) { + application, err := s.applicationDao.Get(ctx, id) + if err != nil { + return nil, services.HandleGetError("Application", "id", id, err) + } + return application, nil +} + +func (s *sqlApplicationService) Create(ctx context.Context, application *Application) (*Application, *errors.ServiceError) { + application, err := s.applicationDao.Create(ctx, application) + if err != nil { + return nil, services.HandleCreateError("Application", err) + } + + _, evErr := s.events.Create(ctx, &api.Event{ + Source: "Applications", + SourceID: application.ID, + EventType: api.CreateEventType, + }) + if evErr != nil { + return nil, services.HandleCreateError("Application", evErr) + } + + return application, nil +} + +func (s *sqlApplicationService) Replace(ctx context.Context, application *Application) (*Application, *errors.ServiceError) { + if !DisableAdvisoryLock { + if UseBlockingAdvisoryLock { + lockOwnerID, err := s.lockFactory.NewAdvisoryLock(ctx, application.ID, applicationsLockType) + if err != nil { + return nil, errors.DatabaseAdvisoryLock(err) + } + defer s.lockFactory.Unlock(ctx, lockOwnerID) + } else { + lockOwnerID, locked, err := s.lockFactory.NewNonBlockingLock(ctx, application.ID, applicationsLockType) + if err != nil { + return nil, errors.DatabaseAdvisoryLock(err) + } + if !locked { + return nil, services.HandleCreateError("Application", errors.New(errors.ErrorConflict, "row locked")) + } + defer s.lockFactory.Unlock(ctx, lockOwnerID) + } + } + + application, err := s.applicationDao.Replace(ctx, application) + if err != nil { + return nil, services.HandleUpdateError("Application", err) + } + + _, evErr := s.events.Create(ctx, &api.Event{ + Source: "Applications", + SourceID: application.ID, + EventType: api.UpdateEventType, + }) + if evErr != nil { + return nil, services.HandleUpdateError("Application", evErr) + } + + return application, nil +} + +func (s *sqlApplicationService) Delete(ctx context.Context, id string) *errors.ServiceError { + if err := s.applicationDao.Delete(ctx, id); err != nil { + return services.HandleDeleteError("Application", errors.GeneralError("Unable to delete application: %s", err)) + } + + _, evErr := s.events.Create(ctx, &api.Event{ + Source: "Applications", + SourceID: id, + EventType: api.DeleteEventType, + }) + if evErr != nil { + return services.HandleDeleteError("Application", evErr) + } + + return nil +} + +func (s *sqlApplicationService) FindByIDs(ctx context.Context, ids []string) (ApplicationList, *errors.ServiceError) { + applications, err := s.applicationDao.FindByIDs(ctx, ids) + if err != nil { + return nil, errors.GeneralError("Unable to get all applications: %s", err) + } + return applications, nil +} + +func (s *sqlApplicationService) All(ctx context.Context) (ApplicationList, *errors.ServiceError) { + applications, err := s.applicationDao.All(ctx) + if err != nil { + return nil, errors.GeneralError("Unable to get all applications: %s", err) + } + return applications, nil +} diff --git a/components/ambient-api-server/plugins/applications/testmain_test.go b/components/ambient-api-server/plugins/applications/testmain_test.go new file mode 100644 index 000000000..b74f5042f --- /dev/null +++ b/components/ambient-api-server/plugins/applications/testmain_test.go @@ -0,0 +1,33 @@ +package applications_test + +import ( + "flag" + "os" + "runtime" + "testing" + + "github.com/golang/glog" + + "github.com/ambient-code/platform/components/ambient-api-server/test" + + _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/agents" + _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/inbox" + _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/projectSettings" + _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/projects" + _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/rbac" + _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/roleBindings" + _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/roles" + _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/sessions" + _ "github.com/ambient-code/platform/components/ambient-api-server/plugins/users" + _ "github.com/openshift-online/rh-trex-ai/plugins/events" + _ "github.com/openshift-online/rh-trex-ai/plugins/generic" +) + +func TestMain(m *testing.M) { + flag.Parse() + glog.Infof("Starting applications integration test using go version %s", runtime.Version()) + helper := test.NewHelper(&testing.T{}) + exitCode := m.Run() + helper.Teardown() + os.Exit(exitCode) +} diff --git a/components/ambient-cli/cmd/acpctl/application/cmd.go b/components/ambient-cli/cmd/acpctl/application/cmd.go new file mode 100644 index 000000000..b0ff65fbc --- /dev/null +++ b/components/ambient-cli/cmd/acpctl/application/cmd.go @@ -0,0 +1,512 @@ +// Package application implements the application subcommand for managing GitOps applications. +package application + +import ( + "context" + "fmt" + "time" + + "github.com/ambient-code/platform/components/ambient-cli/pkg/config" + "github.com/ambient-code/platform/components/ambient-cli/pkg/connection" + "github.com/ambient-code/platform/components/ambient-cli/pkg/output" + sdktypes "github.com/ambient-code/platform/components/ambient-sdk/go-sdk/types" + "github.com/spf13/cobra" +) + +var Cmd = &cobra.Command{ + Use: "application", + Aliases: []string{"app", "apps"}, + Short: "Manage GitOps applications", + Long: `Manage GitOps applications that continuously sync agent fleet definitions from git. + +Subcommands: + list List applications + get Get a specific application + create Create an application + update Update an application's fields + delete Delete an application + sync Trigger a sync for an application + refresh Refresh an application's sync status`, + RunE: func(cmd *cobra.Command, args []string) error { + return cmd.Help() + }, +} + +var listArgs struct { + outputFormat string + limit int +} + +var listCmd = &cobra.Command{ + Use: "list", + Short: "List applications", + Example: ` acpctl application list + acpctl app list -o json + acpctl app list --limit 10`, + RunE: func(cmd *cobra.Command, args []string) error { + client, err := connection.NewClientFromConfig() + if err != nil { + return err + } + + cfg, err := config.Load() + if err != nil { + return err + } + + ctx, cancel := context.WithTimeout(context.Background(), cfg.GetRequestTimeout()) + defer cancel() + + format, err := output.ParseFormat(listArgs.outputFormat) + if err != nil { + return err + } + printer := output.NewPrinter(format, cmd.OutOrStdout()) + + opts := sdktypes.NewListOptions().Size(listArgs.limit).Build() + list, err := client.Applications().List(ctx, opts) + if err != nil { + return fmt.Errorf("list applications: %w", err) + } + + if printer.Format() == output.FormatJSON { + return printer.PrintJSON(list) + } + + return printApplicationTable(printer, list.Items) + }, +} + +var getArgs struct { + outputFormat string +} + +var getCmd = &cobra.Command{ + Use: "get ", + Short: "Get a specific application", + Args: cobra.ExactArgs(1), + Example: ` acpctl application get + acpctl app get -o json`, + RunE: func(cmd *cobra.Command, args []string) error { + client, err := connection.NewClientFromConfig() + if err != nil { + return err + } + + cfg, err := config.Load() + if err != nil { + return err + } + + ctx, cancel := context.WithTimeout(context.Background(), cfg.GetRequestTimeout()) + defer cancel() + + app, err := client.Applications().Get(ctx, args[0]) + if err != nil { + return fmt.Errorf("get application %q: %w", args[0], err) + } + + format, err := output.ParseFormat(getArgs.outputFormat) + if err != nil { + return err + } + printer := output.NewPrinter(format, cmd.OutOrStdout()) + + if printer.Format() == output.FormatJSON { + return printer.PrintJSON(app) + } + return printApplicationTable(printer, []sdktypes.Application{*app}) + }, +} + +var createArgs struct { + name string + sourceRepoURL string + sourcePath string + sourceTargetRevision string + destinationProject string + destinationURL string + credentialID string + autoSync bool + autoPrune bool + selfHeal bool + retryLimit int32 + labels string + annotations string + outputFormat string +} + +var createCmd = &cobra.Command{ + Use: "create", + Short: "Create an application", + Example: ` acpctl app create --name my-fleet --source-repo-url https://github.com/org/repo --source-path manifests/ --destination-project my-project + acpctl app create --name prod-sync --source-repo-url https://github.com/org/repo --source-path . --destination-project prod --auto-sync --auto-prune`, + RunE: func(cmd *cobra.Command, args []string) error { + if createArgs.name == "" { + return fmt.Errorf("--name is required") + } + if createArgs.sourceRepoURL == "" { + return fmt.Errorf("--source-repo-url is required") + } + if createArgs.sourcePath == "" { + return fmt.Errorf("--source-path is required") + } + if createArgs.destinationProject == "" { + return fmt.Errorf("--destination-project is required") + } + + client, err := connection.NewClientFromConfig() + if err != nil { + return err + } + + cfg, err := config.Load() + if err != nil { + return err + } + + ctx, cancel := context.WithTimeout(context.Background(), cfg.GetRequestTimeout()) + defer cancel() + + builder := sdktypes.NewApplicationBuilder(). + Name(createArgs.name). + SourceRepoURL(createArgs.sourceRepoURL). + SourcePath(createArgs.sourcePath). + DestinationProject(createArgs.destinationProject) + + if createArgs.sourceTargetRevision != "" { + builder = builder.SourceTargetRevision(createArgs.sourceTargetRevision) + } + if createArgs.destinationURL != "" { + builder = builder.DestinationAmbientURL(createArgs.destinationURL) + } + if createArgs.credentialID != "" { + builder = builder.CredentialID(createArgs.credentialID) + } + if createArgs.autoSync { + builder = builder.AutoSync(true) + } + if createArgs.autoPrune { + builder = builder.AutoPrune(true) + } + if createArgs.selfHeal { + builder = builder.SelfHeal(true) + } + if cmd.Flags().Changed("retry-limit") { + builder = builder.RetryLimit(createArgs.retryLimit) + } + if createArgs.labels != "" { + builder = builder.Labels(createArgs.labels) + } + if createArgs.annotations != "" { + builder = builder.Annotations(createArgs.annotations) + } + + app, err := builder.Build() + if err != nil { + return fmt.Errorf("build application: %w", err) + } + + created, err := client.Applications().Create(ctx, app) + if err != nil { + return fmt.Errorf("create application: %w", err) + } + + format, err := output.ParseFormat(createArgs.outputFormat) + if err != nil { + return err + } + printer := output.NewPrinter(format, cmd.OutOrStdout()) + + if printer.Format() == output.FormatJSON { + return printer.PrintJSON(created) + } + fmt.Fprintf(cmd.OutOrStdout(), "application/%s created\n", created.Name) + return nil + }, +} + +var updateArgs struct { + name string + sourceRepoURL string + sourcePath string + sourceTargetRevision string + destinationProject string + destinationURL string + credentialID string + autoSync bool + autoPrune bool + selfHeal bool + retryLimit int32 + labels string + annotations string +} + +var updateCmd = &cobra.Command{ + Use: "update ", + Short: "Update an application", + Args: cobra.ExactArgs(1), + Example: ` acpctl app update --auto-sync --auto-prune --self-heal + acpctl app update --source-target-revision main`, + RunE: func(cmd *cobra.Command, args []string) error { + client, err := connection.NewClientFromConfig() + if err != nil { + return err + } + + cfg, err := config.Load() + if err != nil { + return err + } + + ctx, cancel := context.WithTimeout(context.Background(), cfg.GetRequestTimeout()) + defer cancel() + + patch := sdktypes.NewApplicationPatchBuilder() + if cmd.Flags().Changed("name") { + patch = patch.Name(updateArgs.name) + } + if cmd.Flags().Changed("source-repo-url") { + patch = patch.SourceRepoURL(updateArgs.sourceRepoURL) + } + if cmd.Flags().Changed("source-path") { + patch = patch.SourcePath(updateArgs.sourcePath) + } + if cmd.Flags().Changed("source-target-revision") { + patch = patch.SourceTargetRevision(updateArgs.sourceTargetRevision) + } + if cmd.Flags().Changed("destination-project") { + patch = patch.DestinationProject(updateArgs.destinationProject) + } + if cmd.Flags().Changed("destination-url") { + patch = patch.DestinationAmbientURL(updateArgs.destinationURL) + } + if cmd.Flags().Changed("credential-id") { + patch = patch.CredentialID(updateArgs.credentialID) + } + if cmd.Flags().Changed("auto-sync") { + patch = patch.AutoSync(updateArgs.autoSync) + } + if cmd.Flags().Changed("auto-prune") { + patch = patch.AutoPrune(updateArgs.autoPrune) + } + if cmd.Flags().Changed("self-heal") { + patch = patch.SelfHeal(updateArgs.selfHeal) + } + if cmd.Flags().Changed("retry-limit") { + patch = patch.RetryLimit(updateArgs.retryLimit) + } + if cmd.Flags().Changed("labels") { + patch = patch.Labels(updateArgs.labels) + } + if cmd.Flags().Changed("annotations") { + patch = patch.Annotations(updateArgs.annotations) + } + + updated, err := client.Applications().Update(ctx, args[0], patch.Build()) + if err != nil { + return fmt.Errorf("update application: %w", err) + } + + fmt.Fprintf(cmd.OutOrStdout(), "application/%s updated\n", updated.Name) + return nil + }, +} + +var deleteArgs struct { + confirm bool +} + +var deleteCmd = &cobra.Command{ + Use: "delete ", + Short: "Delete an application", + Args: cobra.ExactArgs(1), + Example: ` acpctl app delete --confirm`, + RunE: func(cmd *cobra.Command, args []string) error { + if !deleteArgs.confirm { + return fmt.Errorf("add --confirm to delete application/%s", args[0]) + } + + client, err := connection.NewClientFromConfig() + if err != nil { + return err + } + + cfg, err := config.Load() + if err != nil { + return err + } + + ctx, cancel := context.WithTimeout(context.Background(), cfg.GetRequestTimeout()) + defer cancel() + + if err := client.Applications().Delete(ctx, args[0]); err != nil { + return fmt.Errorf("delete application: %w", err) + } + + fmt.Fprintf(cmd.OutOrStdout(), "application/%s deleted\n", args[0]) + return nil + }, +} + +var syncArgs struct { + outputFormat string +} + +var syncCmd = &cobra.Command{ + Use: "sync ", + Short: "Trigger a sync for an application", + Args: cobra.ExactArgs(1), + Example: ` acpctl app sync + acpctl app sync -o json`, + RunE: func(cmd *cobra.Command, args []string) error { + client, err := connection.NewClientFromConfig() + if err != nil { + return err + } + + cfg, err := config.Load() + if err != nil { + return err + } + + ctx, cancel := context.WithTimeout(context.Background(), cfg.GetRequestTimeout()) + defer cancel() + + patch := sdktypes.NewApplicationPatchBuilder().OperationPhase("Running").Build() + updated, err := client.Applications().Update(ctx, args[0], patch) + if err != nil { + return fmt.Errorf("sync application: %w", err) + } + + format, err := output.ParseFormat(syncArgs.outputFormat) + if err != nil { + return err + } + printer := output.NewPrinter(format, cmd.OutOrStdout()) + + if printer.Format() == output.FormatJSON { + return printer.PrintJSON(updated) + } + fmt.Fprintf(cmd.OutOrStdout(), "application/%s sync triggered\n", updated.Name) + return nil + }, +} + +var refreshArgs struct { + outputFormat string +} + +var refreshCmd = &cobra.Command{ + Use: "refresh ", + Short: "Refresh an application's sync status", + Args: cobra.ExactArgs(1), + Example: ` acpctl app refresh + acpctl app refresh -o json`, + RunE: func(cmd *cobra.Command, args []string) error { + client, err := connection.NewClientFromConfig() + if err != nil { + return err + } + + cfg, err := config.Load() + if err != nil { + return err + } + + ctx, cancel := context.WithTimeout(context.Background(), cfg.GetRequestTimeout()) + defer cancel() + + patch := sdktypes.NewApplicationPatchBuilder().SyncStatus("Unknown").Build() + updated, err := client.Applications().Update(ctx, args[0], patch) + if err != nil { + return fmt.Errorf("refresh application: %w", err) + } + + format, err := output.ParseFormat(refreshArgs.outputFormat) + if err != nil { + return err + } + printer := output.NewPrinter(format, cmd.OutOrStdout()) + + if printer.Format() == output.FormatJSON { + return printer.PrintJSON(updated) + } + fmt.Fprintf(cmd.OutOrStdout(), "application/%s refresh triggered\n", updated.Name) + return nil + }, +} + +func init() { + Cmd.AddCommand(listCmd) + Cmd.AddCommand(getCmd) + Cmd.AddCommand(createCmd) + Cmd.AddCommand(updateCmd) + Cmd.AddCommand(deleteCmd) + Cmd.AddCommand(syncCmd) + Cmd.AddCommand(refreshCmd) + + listCmd.Flags().StringVarP(&listArgs.outputFormat, "output", "o", "", "Output format: json") + listCmd.Flags().IntVar(&listArgs.limit, "limit", 100, "Maximum number of items to return") + + getCmd.Flags().StringVarP(&getArgs.outputFormat, "output", "o", "", "Output format: json") + + createCmd.Flags().StringVar(&createArgs.name, "name", "", "Application name (required)") + createCmd.Flags().StringVar(&createArgs.sourceRepoURL, "source-repo-url", "", "Git repository URL (required)") + createCmd.Flags().StringVar(&createArgs.sourcePath, "source-path", "", "Path within the repository (required)") + createCmd.Flags().StringVar(&createArgs.sourceTargetRevision, "source-target-revision", "", "Git branch, tag, or commit") + createCmd.Flags().StringVar(&createArgs.destinationProject, "destination-project", "", "Target project (required)") + createCmd.Flags().StringVar(&createArgs.destinationURL, "destination-url", "", "Target Ambient instance URL") + createCmd.Flags().StringVar(&createArgs.credentialID, "credential-id", "", "Credential ID for private repos") + createCmd.Flags().BoolVar(&createArgs.autoSync, "auto-sync", false, "Enable automatic sync") + createCmd.Flags().BoolVar(&createArgs.autoPrune, "auto-prune", false, "Enable automatic pruning") + createCmd.Flags().BoolVar(&createArgs.selfHeal, "self-heal", false, "Enable self-healing") + createCmd.Flags().Int32Var(&createArgs.retryLimit, "retry-limit", 0, "Maximum retry attempts") + createCmd.Flags().StringVar(&createArgs.labels, "labels", "", "Labels (JSON string)") + createCmd.Flags().StringVar(&createArgs.annotations, "annotations", "", "Annotations (JSON string)") + createCmd.Flags().StringVarP(&createArgs.outputFormat, "output", "o", "", "Output format: json") + + updateCmd.Flags().StringVar(&updateArgs.name, "name", "", "New application name") + updateCmd.Flags().StringVar(&updateArgs.sourceRepoURL, "source-repo-url", "", "New git repository URL") + updateCmd.Flags().StringVar(&updateArgs.sourcePath, "source-path", "", "New path within the repository") + updateCmd.Flags().StringVar(&updateArgs.sourceTargetRevision, "source-target-revision", "", "New git branch, tag, or commit") + updateCmd.Flags().StringVar(&updateArgs.destinationProject, "destination-project", "", "New target project") + updateCmd.Flags().StringVar(&updateArgs.destinationURL, "destination-url", "", "New target Ambient instance URL") + updateCmd.Flags().StringVar(&updateArgs.credentialID, "credential-id", "", "New credential ID") + updateCmd.Flags().BoolVar(&updateArgs.autoSync, "auto-sync", false, "Enable automatic sync") + updateCmd.Flags().BoolVar(&updateArgs.autoPrune, "auto-prune", false, "Enable automatic pruning") + updateCmd.Flags().BoolVar(&updateArgs.selfHeal, "self-heal", false, "Enable self-healing") + updateCmd.Flags().Int32Var(&updateArgs.retryLimit, "retry-limit", 0, "Maximum retry attempts") + updateCmd.Flags().StringVar(&updateArgs.labels, "labels", "", "New labels (JSON string)") + updateCmd.Flags().StringVar(&updateArgs.annotations, "annotations", "", "New annotations (JSON string)") + + deleteCmd.Flags().BoolVar(&deleteArgs.confirm, "confirm", false, "Confirm deletion") + + syncCmd.Flags().StringVarP(&syncArgs.outputFormat, "output", "o", "", "Output format: json") + + refreshCmd.Flags().StringVarP(&refreshArgs.outputFormat, "output", "o", "", "Output format: json") +} + +func printApplicationTable(printer *output.Printer, applications []sdktypes.Application) error { + columns := []output.Column{ + {Name: "ID", Width: 27}, + {Name: "NAME", Width: 24}, + {Name: "REPO", Width: 36}, + {Name: "PROJECT", Width: 18}, + {Name: "SYNC", Width: 10}, + {Name: "HEALTH", Width: 10}, + {Name: "AGE", Width: 10}, + } + + table := output.NewTable(printer.Writer(), columns) + table.WriteHeaders() + + for _, a := range applications { + age := "" + if a.CreatedAt != nil { + age = output.FormatAge(time.Since(*a.CreatedAt)) + } + table.WriteRow(a.ID, a.Name, a.SourceRepoURL, a.DestinationProject, a.SyncStatus, a.HealthStatus, age) + } + return nil +} diff --git a/components/ambient-cli/cmd/acpctl/create/cmd.go b/components/ambient-cli/cmd/acpctl/create/cmd.go index 31e2b7d84..ce36175f1 100644 --- a/components/ambient-cli/cmd/acpctl/create/cmd.go +++ b/components/ambient-cli/cmd/acpctl/create/cmd.go @@ -27,6 +27,7 @@ Valid resource types: agent Create an agent role Create a role role-binding Create a role binding + application Create a GitOps application `, Args: cobra.MinimumNArgs(1), RunE: run, @@ -56,6 +57,19 @@ var createArgs struct { bindSessionID string bindCredID string scopeID string + + sourceRepoURL string + sourcePath string + sourceTargetRevision string + destinationProject string + destinationURL string + credentialID string + autoSync bool + autoPrune bool + selfHeal bool + retryLimit int32 + labels string + annotations string } func init() { @@ -82,6 +96,19 @@ func init() { Cmd.Flags().StringVar(&createArgs.bindSessionID, "session-id-fk", "", "Session FK for role-binding") Cmd.Flags().StringVar(&createArgs.bindCredID, "credential-id-fk", "", "Credential FK for role-binding") Cmd.Flags().StringVar(&createArgs.scopeID, "scope-id", "", "Scope target ID for role-binding (shorthand for --{scope}-id-fk)") + + Cmd.Flags().StringVar(&createArgs.sourceRepoURL, "source-repo-url", "", "Git repository URL (application)") + Cmd.Flags().StringVar(&createArgs.sourcePath, "source-path", "", "Path within the repository (application)") + Cmd.Flags().StringVar(&createArgs.sourceTargetRevision, "source-target-revision", "", "Git branch, tag, or commit (application)") + Cmd.Flags().StringVar(&createArgs.destinationProject, "destination-project", "", "Target project (application)") + Cmd.Flags().StringVar(&createArgs.destinationURL, "destination-url", "", "Target Ambient instance URL (application)") + Cmd.Flags().StringVar(&createArgs.credentialID, "credential-id", "", "Credential ID for private repos (application)") + Cmd.Flags().BoolVar(&createArgs.autoSync, "auto-sync", false, "Enable automatic sync (application)") + Cmd.Flags().BoolVar(&createArgs.autoPrune, "auto-prune", false, "Enable automatic pruning (application)") + Cmd.Flags().BoolVar(&createArgs.selfHeal, "self-heal", false, "Enable self-healing (application)") + Cmd.Flags().Int32Var(&createArgs.retryLimit, "retry-limit", 0, "Maximum retry attempts (application)") + Cmd.Flags().StringVar(&createArgs.labels, "labels", "", "Labels JSON string (application)") + Cmd.Flags().StringVar(&createArgs.annotations, "annotations", "", "Annotations JSON string (application)") } func run(cmd *cobra.Command, cmdArgs []string) error { @@ -113,8 +140,10 @@ func run(cmd *cobra.Command, cmdArgs []string) error { return createRole(cmd, ctx, client) case "role-binding", "rolebinding", "rb": return createRoleBinding(cmd, ctx, client) + case "application", "app": + return createApplication(cmd, ctx, client) default: - return fmt.Errorf("unknown resource type: %s\nValid types: session, project, project-agent, agent, role, role-binding", cmdArgs[0]) + return fmt.Errorf("unknown resource type: %s\nValid types: session, project, project-agent, agent, role, role-binding, application", cmdArgs[0]) } } @@ -291,6 +320,72 @@ func createRole(cmd *cobra.Command, ctx context.Context, client *sdkclient.Clien return printCreated(cmd, "role", created.ID, created) } +func createApplication(cmd *cobra.Command, ctx context.Context, client *sdkclient.Client) error { + warnUnusedFlags(cmd, "prompt", "model", "max-tokens", "temperature", "timeout", "display-name", "project-id", "agent-id", "owner-user-id", "permissions", "user-id", "role-id", "scope", "project-id-fk", "agent-id-fk", "session-id-fk", "credential-id-fk", "scope-id") + + if createArgs.name == "" { + return fmt.Errorf("--name is required") + } + if createArgs.sourceRepoURL == "" { + return fmt.Errorf("--source-repo-url is required") + } + if createArgs.sourcePath == "" { + return fmt.Errorf("--source-path is required") + } + if createArgs.destinationProject == "" { + return fmt.Errorf("--destination-project is required") + } + + builder := sdktypes.NewApplicationBuilder(). + Name(createArgs.name). + SourceRepoURL(createArgs.sourceRepoURL). + SourcePath(createArgs.sourcePath). + DestinationProject(createArgs.destinationProject) + + if createArgs.sourceTargetRevision != "" { + builder = builder.SourceTargetRevision(createArgs.sourceTargetRevision) + } + if createArgs.destinationURL != "" { + builder = builder.DestinationAmbientURL(createArgs.destinationURL) + } + if createArgs.credentialID != "" { + builder = builder.CredentialID(createArgs.credentialID) + } + if createArgs.autoSync { + builder = builder.AutoSync(true) + } + if createArgs.autoPrune { + builder = builder.AutoPrune(true) + } + if createArgs.selfHeal { + builder = builder.SelfHeal(true) + } + if cmd.Flags().Changed("retry-limit") { + builder = builder.RetryLimit(createArgs.retryLimit) + } + if createArgs.labels != "" { + builder = builder.Labels(createArgs.labels) + } + if createArgs.annotations != "" { + builder = builder.Annotations(createArgs.annotations) + } + if createArgs.description != "" { + builder = builder.Conditions(createArgs.description) + } + + app, err := builder.Build() + if err != nil { + return fmt.Errorf("build application: %w", err) + } + + created, err := client.Applications().Create(ctx, app) + if err != nil { + return fmt.Errorf("create application: %w", err) + } + + return printCreated(cmd, "application", created.ID, created) +} + func createRoleBinding(cmd *cobra.Command, ctx context.Context, client *sdkclient.Client) error { warnUnusedFlags(cmd, "name", "prompt", "repo-url", "model", "max-tokens", "temperature", "timeout", "display-name", "description", "project-id", "owner-user-id", "permissions", "recipient-agent-id", "body") diff --git a/components/ambient-cli/cmd/acpctl/delete/cmd.go b/components/ambient-cli/cmd/acpctl/delete/cmd.go index 9a0443f1e..daa6c4a76 100644 --- a/components/ambient-cli/cmd/acpctl/delete/cmd.go +++ b/components/ambient-cli/cmd/acpctl/delete/cmd.go @@ -33,6 +33,7 @@ Valid resource types: role role-binding (aliases: rolebinding, rb) credential (aliases: cred) + application (aliases: app) Use --all / -A to delete all resources of the given type. For sessions, active sessions are stopped before deletion.`, @@ -138,8 +139,15 @@ func run(cmd *cobra.Command, cmdArgs []string) error { fmt.Fprintf(cmd.OutOrStdout(), "credential/%s deleted\n", name) return nil + case "application", "applications", "app", "apps": + if err := client.Applications().Delete(ctx, name); err != nil { + return fmt.Errorf("delete application %q: %w", name, err) + } + fmt.Fprintf(cmd.OutOrStdout(), "application/%s deleted\n", name) + return nil + default: - return fmt.Errorf("unknown or non-deletable resource type: %s\nDeletable types: project, project-settings, session, agent, role, role-binding, credential", cmdArgs[0]) + return fmt.Errorf("unknown or non-deletable resource type: %s\nDeletable types: project, project-settings, session, agent, role, role-binding, credential, application", cmdArgs[0]) } } diff --git a/components/ambient-cli/cmd/acpctl/describe/cmd.go b/components/ambient-cli/cmd/acpctl/describe/cmd.go index e213b8ba8..f4354a966 100644 --- a/components/ambient-cli/cmd/acpctl/describe/cmd.go +++ b/components/ambient-cli/cmd/acpctl/describe/cmd.go @@ -25,7 +25,8 @@ Valid resource types: agent (aliases: agents) role role-binding (aliases: rb) - credential (aliases: cred)`, + credential (aliases: cred) + application (aliases: app)`, Args: cobra.ExactArgs(2), RunE: run, } @@ -106,7 +107,14 @@ func run(cmd *cobra.Command, cmdArgs []string) error { } return printer.PrintJSON(cred) + case "application", "applications", "app", "apps": + app, err := client.Applications().Get(ctx, name) + if err != nil { + return fmt.Errorf("describe application %q: %w", name, err) + } + return printer.PrintJSON(app) + default: - return fmt.Errorf("unknown resource type: %s\nValid types: session, project, project-settings, user, agent, role, role-binding, credential", cmdArgs[0]) + return fmt.Errorf("unknown resource type: %s\nValid types: session, project, project-settings, user, agent, role, role-binding, credential, application", cmdArgs[0]) } } diff --git a/components/ambient-cli/cmd/acpctl/get/cmd.go b/components/ambient-cli/cmd/acpctl/get/cmd.go index 395ec0d54..57b7fdd0f 100644 --- a/components/ambient-cli/cmd/acpctl/get/cmd.go +++ b/components/ambient-cli/cmd/acpctl/get/cmd.go @@ -40,6 +40,7 @@ Valid resource types: roles (aliases: role) role-bindings (aliases: role-binding, rb) credentials (aliases: credential, cred) + applications (aliases: application, app) `, Args: cobra.RangeArgs(1, 2), RunE: run, @@ -138,8 +139,10 @@ func run(cmd *cobra.Command, cmdArgs []string) error { return getRoleBindings(ctx, client, printer, name) case "credentials": return getCredentials(ctx, client, printer, name) + case "applications": + return getApplications(ctx, client, printer, name) default: - return fmt.Errorf("unknown resource type: %s\nValid types: sessions, projects, project-agents, project-settings, users, agents, roles, role-bindings, credentials", cmdArgs[0]) + return fmt.Errorf("unknown resource type: %s\nValid types: sessions, projects, project-agents, project-settings, users, agents, roles, role-bindings, credentials, applications", cmdArgs[0]) } } @@ -163,6 +166,8 @@ func normalizeResource(r string) string { return "role-bindings" case "credential", "credentials", "cred", "creds": return "credentials" + case "application", "applications", "app", "apps": + return "applications" default: return r } @@ -512,6 +517,50 @@ func printCredentialTable(printer *output.Printer, credentials []sdktypes.Creden return nil } +func getApplications(ctx context.Context, client *sdkclient.Client, printer *output.Printer, name string) error { + if name != "" { + app, err := client.Applications().Get(ctx, name) + if err != nil { + return fmt.Errorf("get application %q: %w", name, err) + } + if printer.Format() == output.FormatJSON { + return printer.PrintJSON(app) + } + return printApplicationTable(printer, []sdktypes.Application{*app}) + } + opts := sdktypes.NewListOptions().Size(args.limit).Build() + list, err := client.Applications().List(ctx, opts) + if err != nil { + return fmt.Errorf("list applications: %w", err) + } + if printer.Format() == output.FormatJSON { + return printer.PrintJSON(list) + } + return printApplicationTable(printer, list.Items) +} + +func printApplicationTable(printer *output.Printer, applications []sdktypes.Application) error { + columns := []output.Column{ + {Name: "ID", Width: 27}, + {Name: "NAME", Width: 24}, + {Name: "REPO", Width: 36}, + {Name: "PROJECT", Width: 18}, + {Name: "SYNC", Width: 10}, + {Name: "HEALTH", Width: 10}, + {Name: "AGE", Width: 10}, + } + table := output.NewTable(printer.Writer(), columns) + table.WriteHeaders() + for _, a := range applications { + age := "" + if a.CreatedAt != nil { + age = output.FormatAge(time.Since(*a.CreatedAt)) + } + table.WriteRow(a.ID, a.Name, a.SourceRepoURL, a.DestinationProject, a.SyncStatus, a.HealthStatus, age) + } + return nil +} + func printRoleBindingTable(printer *output.Printer, rbs []sdktypes.RoleBinding, names map[string]string) error { columns := []output.Column{ {Name: "ID", Width: 27}, diff --git a/components/ambient-cli/cmd/acpctl/main.go b/components/ambient-cli/cmd/acpctl/main.go index dab06a511..f7019f20f 100755 --- a/components/ambient-cli/cmd/acpctl/main.go +++ b/components/ambient-cli/cmd/acpctl/main.go @@ -6,6 +6,7 @@ import ( "github.com/ambient-code/platform/components/ambient-cli/cmd/acpctl/agent" "github.com/ambient-code/platform/components/ambient-cli/cmd/acpctl/ambient" + "github.com/ambient-code/platform/components/ambient-cli/cmd/acpctl/application" "github.com/ambient-code/platform/components/ambient-cli/cmd/acpctl/apply" "github.com/ambient-code/platform/components/ambient-cli/cmd/acpctl/completion" "github.com/ambient-code/platform/components/ambient-cli/cmd/acpctl/config" @@ -74,6 +75,7 @@ func init() { root.AddCommand(stop.Cmd) root.AddCommand(completion.Cmd) root.AddCommand(ambient.Cmd) + root.AddCommand(application.Cmd) root.AddCommand(apply.Cmd) } diff --git a/components/ambient-cli/cmd/acpctl/session/messages.go b/components/ambient-cli/cmd/acpctl/session/messages.go index e9587a1b7..42d8edec5 100644 --- a/components/ambient-cli/cmd/acpctl/session/messages.go +++ b/components/ambient-cli/cmd/acpctl/session/messages.go @@ -24,20 +24,20 @@ import ( var ( sseColorDim = lipgloss.Color("240") sseColorCyan = lipgloss.Color("36") - sseColorBlue = lipgloss.Color("69") + _ = lipgloss.Color("69") // sseColorBlue reserved for agent message rendering sseColorGreen = lipgloss.Color("28") sseColorRed = lipgloss.Color("196") - sseColorYellow = lipgloss.Color("214") + _ = lipgloss.Color("214") // sseColorYellow reserved for agent message rendering sseColorMagenta = lipgloss.Color("134") sseThinkTag = lipgloss.NewStyle().Foreground(sseColorDim).Bold(true) sseThinkText = lipgloss.NewStyle().Foreground(sseColorDim).Italic(true) sseToolTag = lipgloss.NewStyle().Foreground(sseColorCyan).Bold(true) sseToolResult = lipgloss.NewStyle().Foreground(sseColorDim) - sseAssistant = lipgloss.NewStyle().Foreground(lipgloss.Color("255")) + _ = lipgloss.NewStyle().Foreground(lipgloss.Color("255")) // sseAssistant reserved for agent message rendering sseRunTag = lipgloss.NewStyle().Foreground(sseColorGreen).Bold(true) sseErrorTag = lipgloss.NewStyle().Foreground(sseColorRed).Bold(true) - sseAgentTag = lipgloss.NewStyle().Foreground(sseColorYellow).Bold(true) + _ = lipgloss.NewStyle().Foreground(lipgloss.Color("214")).Bold(true) // sseAgentTag reserved for agent message rendering sseStepTag = lipgloss.NewStyle().Foreground(sseColorMagenta).Bold(true) sseArrow = lipgloss.NewStyle().Foreground(sseColorDim) ) diff --git a/components/ambient-sdk/go-sdk/client/agent_api.go b/components/ambient-sdk/go-sdk/client/agent_api.go index 531449dc3..90196d9b6 100644 --- a/components/ambient-sdk/go-sdk/client/agent_api.go +++ b/components/ambient-sdk/go-sdk/client/agent_api.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/application_api.go b/components/ambient-sdk/go-sdk/client/application_api.go new file mode 100644 index 000000000..010184693 --- /dev/null +++ b/components/ambient-sdk/go-sdk/client/application_api.go @@ -0,0 +1,75 @@ +// Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. +// Source: ../../ambient-api-server/openapi/openapi.yaml +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z + +package client + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "net/url" + + "github.com/ambient-code/platform/components/ambient-sdk/go-sdk/types" +) + +type ApplicationAPI struct { + client *Client +} + +func (c *Client) Applications() *ApplicationAPI { + return &ApplicationAPI{client: c} +} + +func (a *ApplicationAPI) Create(ctx context.Context, resource *types.Application) (*types.Application, error) { + body, err := json.Marshal(resource) + if err != nil { + return nil, fmt.Errorf("marshal application: %w", err) + } + var result types.Application + if err := a.client.do(ctx, http.MethodPost, "/applications", body, http.StatusCreated, &result); err != nil { + return nil, err + } + return &result, nil +} + +func (a *ApplicationAPI) Get(ctx context.Context, id string) (*types.Application, error) { + var result types.Application + if err := a.client.do(ctx, http.MethodGet, "/applications/"+url.PathEscape(id), nil, http.StatusOK, &result); err != nil { + return nil, err + } + return &result, nil +} + +func (a *ApplicationAPI) List(ctx context.Context, opts *types.ListOptions) (*types.ApplicationList, error) { + var result types.ApplicationList + if err := a.client.doWithQuery(ctx, http.MethodGet, "/applications", nil, http.StatusOK, &result, opts); err != nil { + return nil, err + } + return &result, nil +} +func (a *ApplicationAPI) Update(ctx context.Context, id string, patch map[string]any) (*types.Application, error) { + body, err := json.Marshal(patch) + if err != nil { + return nil, fmt.Errorf("marshal patch: %w", err) + } + var result types.Application + if err := a.client.do(ctx, http.MethodPatch, "/applications/"+url.PathEscape(id), body, http.StatusOK, &result); err != nil { + return nil, err + } + return &result, nil +} + +func (a *ApplicationAPI) Delete(ctx context.Context, id string) error { + return a.client.do(ctx, http.MethodDelete, "/applications/"+url.PathEscape(id), nil, http.StatusNoContent, nil) +} + +func (a *ApplicationAPI) ListAll(ctx context.Context, opts *types.ListOptions) *Iterator[types.Application] { + return NewIterator(func(page int) (*types.ApplicationList, error) { + o := *opts + o.Page = page + return a.List(ctx, &o) + }) +} diff --git a/components/ambient-sdk/go-sdk/client/client.go b/components/ambient-sdk/go-sdk/client/client.go index dc62bb9f2..e678b9de1 100644 --- a/components/ambient-sdk/go-sdk/client/client.go +++ b/components/ambient-sdk/go-sdk/client/client.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/credential_api.go b/components/ambient-sdk/go-sdk/client/credential_api.go index eb14e360c..7f0c0ffeb 100644 --- a/components/ambient-sdk/go-sdk/client/credential_api.go +++ b/components/ambient-sdk/go-sdk/client/credential_api.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/inbox_message_api.go b/components/ambient-sdk/go-sdk/client/inbox_message_api.go index 764c42063..b3e2abf8d 100644 --- a/components/ambient-sdk/go-sdk/client/inbox_message_api.go +++ b/components/ambient-sdk/go-sdk/client/inbox_message_api.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/iterator.go b/components/ambient-sdk/go-sdk/client/iterator.go index e6425dade..fb7890078 100644 --- a/components/ambient-sdk/go-sdk/client/iterator.go +++ b/components/ambient-sdk/go-sdk/client/iterator.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/project_api.go b/components/ambient-sdk/go-sdk/client/project_api.go index 731ce9565..20845fe68 100644 --- a/components/ambient-sdk/go-sdk/client/project_api.go +++ b/components/ambient-sdk/go-sdk/client/project_api.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/project_settings_api.go b/components/ambient-sdk/go-sdk/client/project_settings_api.go index 21dd80297..45b1931c6 100644 --- a/components/ambient-sdk/go-sdk/client/project_settings_api.go +++ b/components/ambient-sdk/go-sdk/client/project_settings_api.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/role_api.go b/components/ambient-sdk/go-sdk/client/role_api.go index 3319efe88..028403d26 100644 --- a/components/ambient-sdk/go-sdk/client/role_api.go +++ b/components/ambient-sdk/go-sdk/client/role_api.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/role_binding_api.go b/components/ambient-sdk/go-sdk/client/role_binding_api.go index df7d616d3..0a1457830 100644 --- a/components/ambient-sdk/go-sdk/client/role_binding_api.go +++ b/components/ambient-sdk/go-sdk/client/role_binding_api.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/scheduled_session_api.go b/components/ambient-sdk/go-sdk/client/scheduled_session_api.go index 7aeb05e34..bfff488cb 100644 --- a/components/ambient-sdk/go-sdk/client/scheduled_session_api.go +++ b/components/ambient-sdk/go-sdk/client/scheduled_session_api.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/session_api.go b/components/ambient-sdk/go-sdk/client/session_api.go index 97aaa119f..2b01ee810 100644 --- a/components/ambient-sdk/go-sdk/client/session_api.go +++ b/components/ambient-sdk/go-sdk/client/session_api.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/session_message_api.go b/components/ambient-sdk/go-sdk/client/session_message_api.go index 46364213d..693e99e14 100644 --- a/components/ambient-sdk/go-sdk/client/session_message_api.go +++ b/components/ambient-sdk/go-sdk/client/session_message_api.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/client/user_api.go b/components/ambient-sdk/go-sdk/client/user_api.go index 2e87c830d..2c09ffa12 100644 --- a/components/ambient-sdk/go-sdk/client/user_api.go +++ b/components/ambient-sdk/go-sdk/client/user_api.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package client diff --git a/components/ambient-sdk/go-sdk/types/agent.go b/components/ambient-sdk/go-sdk/types/agent.go index 6e54a6dee..d480ce164 100644 --- a/components/ambient-sdk/go-sdk/types/agent.go +++ b/components/ambient-sdk/go-sdk/types/agent.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/application.go b/components/ambient-sdk/go-sdk/types/application.go new file mode 100644 index 000000000..848e60433 --- /dev/null +++ b/components/ambient-sdk/go-sdk/types/application.go @@ -0,0 +1,309 @@ +// Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. +// Source: ../../ambient-api-server/openapi/openapi.yaml +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z + +package types + +import ( + "errors" + "fmt" + "time" +) + +type Application struct { + ObjectReference + + Annotations string `json:"annotations,omitempty"` + AutoPrune bool `json:"auto_prune,omitempty"` + AutoSync bool `json:"auto_sync,omitempty"` + Conditions string `json:"conditions,omitempty"` + CredentialID string `json:"credential_id,omitempty"` + DestinationAmbientURL string `json:"destination_ambient_url,omitempty"` + DestinationProject string `json:"destination_project"` + HealthStatus string `json:"health_status,omitempty"` + Labels string `json:"labels,omitempty"` + LastSyncedAt *time.Time `json:"last_synced_at,omitempty"` + Name string `json:"name"` + OperationMessage string `json:"operation_message,omitempty"` + OperationPhase string `json:"operation_phase,omitempty"` + ResourceStatus string `json:"resource_status,omitempty"` + RetryLimit int32 `json:"retry_limit,omitempty"` + SelfHeal bool `json:"self_heal,omitempty"` + SourcePath string `json:"source_path"` + SourceRepoURL string `json:"source_repo_url"` + SourceTargetRevision string `json:"source_target_revision,omitempty"` + SyncOptions string `json:"sync_options,omitempty"` + SyncRevision string `json:"sync_revision,omitempty"` + SyncStatus string `json:"sync_status,omitempty"` +} + +type ApplicationList struct { + ListMeta + Items []Application `json:"items"` +} + +func (l *ApplicationList) GetItems() []Application { return l.Items } +func (l *ApplicationList) GetTotal() int { return l.Total } +func (l *ApplicationList) GetPage() int { return l.Page } +func (l *ApplicationList) GetSize() int { return l.Size } + +type ApplicationBuilder struct { + resource Application + errors []error +} + +func NewApplicationBuilder() *ApplicationBuilder { + return &ApplicationBuilder{} +} + +func (b *ApplicationBuilder) Annotations(v string) *ApplicationBuilder { + b.resource.Annotations = v + return b +} + +func (b *ApplicationBuilder) AutoPrune(v bool) *ApplicationBuilder { + b.resource.AutoPrune = v + return b +} + +func (b *ApplicationBuilder) AutoSync(v bool) *ApplicationBuilder { + b.resource.AutoSync = v + return b +} + +func (b *ApplicationBuilder) Conditions(v string) *ApplicationBuilder { + b.resource.Conditions = v + return b +} + +func (b *ApplicationBuilder) CredentialID(v string) *ApplicationBuilder { + b.resource.CredentialID = v + return b +} + +func (b *ApplicationBuilder) DestinationAmbientURL(v string) *ApplicationBuilder { + b.resource.DestinationAmbientURL = v + return b +} + +func (b *ApplicationBuilder) DestinationProject(v string) *ApplicationBuilder { + b.resource.DestinationProject = v + return b +} + +func (b *ApplicationBuilder) HealthStatus(v string) *ApplicationBuilder { + b.resource.HealthStatus = v + return b +} + +func (b *ApplicationBuilder) Labels(v string) *ApplicationBuilder { + b.resource.Labels = v + return b +} + +func (b *ApplicationBuilder) LastSyncedAt(v time.Time) *ApplicationBuilder { + b.resource.LastSyncedAt = &v + return b +} + +func (b *ApplicationBuilder) Name(v string) *ApplicationBuilder { + b.resource.Name = v + return b +} + +func (b *ApplicationBuilder) OperationMessage(v string) *ApplicationBuilder { + b.resource.OperationMessage = v + return b +} + +func (b *ApplicationBuilder) OperationPhase(v string) *ApplicationBuilder { + b.resource.OperationPhase = v + return b +} + +func (b *ApplicationBuilder) ResourceStatus(v string) *ApplicationBuilder { + b.resource.ResourceStatus = v + return b +} + +func (b *ApplicationBuilder) RetryLimit(v int32) *ApplicationBuilder { + b.resource.RetryLimit = v + return b +} + +func (b *ApplicationBuilder) SelfHeal(v bool) *ApplicationBuilder { + b.resource.SelfHeal = v + return b +} + +func (b *ApplicationBuilder) SourcePath(v string) *ApplicationBuilder { + b.resource.SourcePath = v + return b +} + +func (b *ApplicationBuilder) SourceRepoURL(v string) *ApplicationBuilder { + b.resource.SourceRepoURL = v + return b +} + +func (b *ApplicationBuilder) SourceTargetRevision(v string) *ApplicationBuilder { + b.resource.SourceTargetRevision = v + return b +} + +func (b *ApplicationBuilder) SyncOptions(v string) *ApplicationBuilder { + b.resource.SyncOptions = v + return b +} + +func (b *ApplicationBuilder) SyncRevision(v string) *ApplicationBuilder { + b.resource.SyncRevision = v + return b +} + +func (b *ApplicationBuilder) SyncStatus(v string) *ApplicationBuilder { + b.resource.SyncStatus = v + return b +} + +func (b *ApplicationBuilder) Build() (*Application, error) { + if b.resource.DestinationProject == "" { + b.errors = append(b.errors, fmt.Errorf("destination_project is required")) + } + if b.resource.Name == "" { + b.errors = append(b.errors, fmt.Errorf("name is required")) + } + if b.resource.SourcePath == "" { + b.errors = append(b.errors, fmt.Errorf("source_path is required")) + } + if b.resource.SourceRepoURL == "" { + b.errors = append(b.errors, fmt.Errorf("source_repo_url is required")) + } + if len(b.errors) > 0 { + return nil, fmt.Errorf("validation failed: %w", errors.Join(b.errors...)) + } + return &b.resource, nil +} + +type ApplicationPatchBuilder struct { + patch map[string]any +} + +func NewApplicationPatchBuilder() *ApplicationPatchBuilder { + return &ApplicationPatchBuilder{patch: make(map[string]any)} +} + +func (b *ApplicationPatchBuilder) Annotations(v string) *ApplicationPatchBuilder { + b.patch["annotations"] = v + return b +} + +func (b *ApplicationPatchBuilder) AutoPrune(v bool) *ApplicationPatchBuilder { + b.patch["auto_prune"] = v + return b +} + +func (b *ApplicationPatchBuilder) AutoSync(v bool) *ApplicationPatchBuilder { + b.patch["auto_sync"] = v + return b +} + +func (b *ApplicationPatchBuilder) Conditions(v string) *ApplicationPatchBuilder { + b.patch["conditions"] = v + return b +} + +func (b *ApplicationPatchBuilder) CredentialID(v string) *ApplicationPatchBuilder { + b.patch["credential_id"] = v + return b +} + +func (b *ApplicationPatchBuilder) DestinationAmbientURL(v string) *ApplicationPatchBuilder { + b.patch["destination_ambient_url"] = v + return b +} + +func (b *ApplicationPatchBuilder) DestinationProject(v string) *ApplicationPatchBuilder { + b.patch["destination_project"] = v + return b +} + +func (b *ApplicationPatchBuilder) HealthStatus(v string) *ApplicationPatchBuilder { + b.patch["health_status"] = v + return b +} + +func (b *ApplicationPatchBuilder) Labels(v string) *ApplicationPatchBuilder { + b.patch["labels"] = v + return b +} + +func (b *ApplicationPatchBuilder) LastSyncedAt(v *time.Time) *ApplicationPatchBuilder { + b.patch["last_synced_at"] = v + return b +} + +func (b *ApplicationPatchBuilder) Name(v string) *ApplicationPatchBuilder { + b.patch["name"] = v + return b +} + +func (b *ApplicationPatchBuilder) OperationMessage(v string) *ApplicationPatchBuilder { + b.patch["operation_message"] = v + return b +} + +func (b *ApplicationPatchBuilder) OperationPhase(v string) *ApplicationPatchBuilder { + b.patch["operation_phase"] = v + return b +} + +func (b *ApplicationPatchBuilder) ResourceStatus(v string) *ApplicationPatchBuilder { + b.patch["resource_status"] = v + return b +} + +func (b *ApplicationPatchBuilder) RetryLimit(v int32) *ApplicationPatchBuilder { + b.patch["retry_limit"] = v + return b +} + +func (b *ApplicationPatchBuilder) SelfHeal(v bool) *ApplicationPatchBuilder { + b.patch["self_heal"] = v + return b +} + +func (b *ApplicationPatchBuilder) SourcePath(v string) *ApplicationPatchBuilder { + b.patch["source_path"] = v + return b +} + +func (b *ApplicationPatchBuilder) SourceRepoURL(v string) *ApplicationPatchBuilder { + b.patch["source_repo_url"] = v + return b +} + +func (b *ApplicationPatchBuilder) SourceTargetRevision(v string) *ApplicationPatchBuilder { + b.patch["source_target_revision"] = v + return b +} + +func (b *ApplicationPatchBuilder) SyncOptions(v string) *ApplicationPatchBuilder { + b.patch["sync_options"] = v + return b +} + +func (b *ApplicationPatchBuilder) SyncRevision(v string) *ApplicationPatchBuilder { + b.patch["sync_revision"] = v + return b +} + +func (b *ApplicationPatchBuilder) SyncStatus(v string) *ApplicationPatchBuilder { + b.patch["sync_status"] = v + return b +} + +func (b *ApplicationPatchBuilder) Build() map[string]any { + return b.patch +} diff --git a/components/ambient-sdk/go-sdk/types/base.go b/components/ambient-sdk/go-sdk/types/base.go index b8be7d11f..12ad0d028 100644 --- a/components/ambient-sdk/go-sdk/types/base.go +++ b/components/ambient-sdk/go-sdk/types/base.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/credential.go b/components/ambient-sdk/go-sdk/types/credential.go index e12980679..b1abd24ca 100644 --- a/components/ambient-sdk/go-sdk/types/credential.go +++ b/components/ambient-sdk/go-sdk/types/credential.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/inbox_message.go b/components/ambient-sdk/go-sdk/types/inbox_message.go index c15273dfa..34a672979 100644 --- a/components/ambient-sdk/go-sdk/types/inbox_message.go +++ b/components/ambient-sdk/go-sdk/types/inbox_message.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/list_options.go b/components/ambient-sdk/go-sdk/types/list_options.go index 31d21cc3f..e7b6c3fef 100644 --- a/components/ambient-sdk/go-sdk/types/list_options.go +++ b/components/ambient-sdk/go-sdk/types/list_options.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/project.go b/components/ambient-sdk/go-sdk/types/project.go index f94a8d9b9..836630258 100644 --- a/components/ambient-sdk/go-sdk/types/project.go +++ b/components/ambient-sdk/go-sdk/types/project.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/project_settings.go b/components/ambient-sdk/go-sdk/types/project_settings.go index 74b0d9aae..287083b10 100644 --- a/components/ambient-sdk/go-sdk/types/project_settings.go +++ b/components/ambient-sdk/go-sdk/types/project_settings.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/role.go b/components/ambient-sdk/go-sdk/types/role.go index a75fdd7e8..f824c47be 100644 --- a/components/ambient-sdk/go-sdk/types/role.go +++ b/components/ambient-sdk/go-sdk/types/role.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/role_binding.go b/components/ambient-sdk/go-sdk/types/role_binding.go index b2abbe0b5..ea0abab7c 100644 --- a/components/ambient-sdk/go-sdk/types/role_binding.go +++ b/components/ambient-sdk/go-sdk/types/role_binding.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/scheduled_session.go b/components/ambient-sdk/go-sdk/types/scheduled_session.go index c9ea73433..55dfb2f0f 100755 --- a/components/ambient-sdk/go-sdk/types/scheduled_session.go +++ b/components/ambient-sdk/go-sdk/types/scheduled_session.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/session.go b/components/ambient-sdk/go-sdk/types/session.go index 62513e582..9e41a3d93 100644 --- a/components/ambient-sdk/go-sdk/types/session.go +++ b/components/ambient-sdk/go-sdk/types/session.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/session_message.go b/components/ambient-sdk/go-sdk/types/session_message.go index f16abc2b5..20874f9e0 100644 --- a/components/ambient-sdk/go-sdk/types/session_message.go +++ b/components/ambient-sdk/go-sdk/types/session_message.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/go-sdk/types/user.go b/components/ambient-sdk/go-sdk/types/user.go index 2dc6491d1..ffe4d22dd 100644 --- a/components/ambient-sdk/go-sdk/types/user.go +++ b/components/ambient-sdk/go-sdk/types/user.go @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z package types diff --git a/components/ambient-sdk/python-sdk/ambient_platform/__init__.py b/components/ambient-sdk/python-sdk/ambient_platform/__init__.py index 5c271fff8..f74b6818d 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/__init__.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/__init__.py @@ -1,13 +1,14 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z """Ambient Platform SDK for Python.""" from .client import AmbientClient from ._base import APIError, ListOptions from .agent import Agent, AgentPatch +from .application import Application, ApplicationPatch from .credential import Credential, CredentialPatch from .inbox_message import InboxMessage, InboxMessagePatch from .project import Project, ProjectPatch @@ -27,6 +28,8 @@ "ListOptions", "Agent", "AgentPatch", + "Application", + "ApplicationPatch", "Credential", "CredentialPatch", "InboxMessage", diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_agent_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_agent_api.py index a2003aa59..260ad44ae 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_agent_api.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_agent_api.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_application_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_application_api.py new file mode 100644 index 000000000..9346db9f9 --- /dev/null +++ b/components/ambient-sdk/python-sdk/ambient_platform/_application_api.py @@ -0,0 +1,48 @@ +# Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. +# Source: ../../ambient-api-server/openapi/openapi.yaml +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z + +from __future__ import annotations + +from typing import Any, Iterator, Optional, TYPE_CHECKING + +from ._base import ListOptions +from .application import Application, ApplicationList + +if TYPE_CHECKING: + from .client import AmbientClient + + +class ApplicationAPI: + def __init__(self, client: AmbientClient) -> None: + self._client = client + + def create(self, data: dict) -> Application: + resp = self._client._request("POST", "/applications", json=data) + return Application.from_dict(resp) + + def get(self, resource_id: str) -> Application: + resp = self._client._request("GET", f"/applications/{resource_id}") + return Application.from_dict(resp) + + def list(self, opts: Optional[ListOptions] = None) -> ApplicationList: + params = opts.to_params() if opts else None + resp = self._client._request("GET", "/applications", params=params) + return ApplicationList.from_dict(resp) + def update(self, resource_id: str, patch: Any) -> Application: + data = patch.to_dict() if hasattr(patch, "to_dict") else patch + resp = self._client._request("PATCH", f"/applications/{resource_id}", json=data) + return Application.from_dict(resp) + + def delete(self, resource_id: str) -> None: + self._client._request("DELETE", f"/applications/{resource_id}", expect_json=False) + + def list_all(self, size: int = 100, **kwargs: Any) -> Iterator[Application]: + page = 1 + while True: + result = self.list(ListOptions().page(page).size(size)) + yield from result.items + if page * size >= result.total: + break + page += 1 diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_base.py b/components/ambient-sdk/python-sdk/ambient_platform/_base.py index 168726563..b32541871 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_base.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_base.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_credential_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_credential_api.py index ca74fe003..a494d637c 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_credential_api.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_credential_api.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_inbox_message_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_inbox_message_api.py index 2c3c4ff72..419415b81 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_inbox_message_api.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_inbox_message_api.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_iterator.py b/components/ambient-sdk/python-sdk/ambient_platform/_iterator.py index 311e32b71..8cd15e941 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_iterator.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_iterator.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_project_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_project_api.py index 150335e4c..4d2c70b7e 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_project_api.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_project_api.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_project_settings_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_project_settings_api.py index cedc53c08..fc5275348 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_project_settings_api.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_project_settings_api.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_role_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_role_api.py index 870ca6249..ac007a84f 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_role_api.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_role_api.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_role_binding_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_role_binding_api.py index cfd4da94e..4ceaaa8e2 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_role_binding_api.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_role_binding_api.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_scheduled_session_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_scheduled_session_api.py index d27b73073..5e6f6ce4d 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_scheduled_session_api.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_scheduled_session_api.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_session_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_session_api.py index 047454e21..2a9ee68f1 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_session_api.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_session_api.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_session_message_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_session_message_api.py index 9cef32e75..8607c06e8 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_session_message_api.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_session_message_api.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/_user_api.py b/components/ambient-sdk/python-sdk/ambient_platform/_user_api.py index a2b8387fd..192e9367c 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/_user_api.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/_user_api.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/agent.py b/components/ambient-sdk/python-sdk/ambient_platform/agent.py index 6ce32dee4..17452f975 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/agent.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/agent.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/application.py b/components/ambient-sdk/python-sdk/ambient_platform/application.py new file mode 100644 index 000000000..fca583039 --- /dev/null +++ b/components/ambient-sdk/python-sdk/ambient_platform/application.py @@ -0,0 +1,300 @@ +# Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. +# Source: ../../ambient-api-server/openapi/openapi.yaml +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z + +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from typing import Any, Optional + +from ._base import ListMeta, _parse_datetime + + +@dataclass(frozen=True) +class Application: + id: str = "" + kind: str = "" + href: str = "" + created_at: Optional[datetime] = None + updated_at: Optional[datetime] = None + annotations: str = "" + auto_prune: bool = False + auto_sync: bool = False + conditions: str = "" + credential_id: str = "" + destination_ambient_url: str = "" + destination_project: str = "" + health_status: str = "" + labels: str = "" + last_synced_at: Optional[datetime] = None + name: str = "" + operation_message: str = "" + operation_phase: str = "" + resource_status: str = "" + retry_limit: int = 0 + self_heal: bool = False + source_path: str = "" + source_repo_url: str = "" + source_target_revision: str = "" + sync_options: str = "" + sync_revision: str = "" + sync_status: str = "" + + @classmethod + def from_dict(cls, data: dict) -> Application: + return cls( + id=data.get("id", ""), + kind=data.get("kind", ""), + href=data.get("href", ""), + created_at=_parse_datetime(data.get("created_at")), + updated_at=_parse_datetime(data.get("updated_at")), + annotations=data.get("annotations", ""), + auto_prune=data.get("auto_prune", False), + auto_sync=data.get("auto_sync", False), + conditions=data.get("conditions", ""), + credential_id=data.get("credential_id", ""), + destination_ambient_url=data.get("destination_ambient_url", ""), + destination_project=data.get("destination_project", ""), + health_status=data.get("health_status", ""), + labels=data.get("labels", ""), + last_synced_at=_parse_datetime(data.get("last_synced_at")), + name=data.get("name", ""), + operation_message=data.get("operation_message", ""), + operation_phase=data.get("operation_phase", ""), + resource_status=data.get("resource_status", ""), + retry_limit=data.get("retry_limit", 0), + self_heal=data.get("self_heal", False), + source_path=data.get("source_path", ""), + source_repo_url=data.get("source_repo_url", ""), + source_target_revision=data.get("source_target_revision", ""), + sync_options=data.get("sync_options", ""), + sync_revision=data.get("sync_revision", ""), + sync_status=data.get("sync_status", ""), + ) + + @classmethod + def builder(cls) -> ApplicationBuilder: + return ApplicationBuilder() + + +@dataclass(frozen=True) +class ApplicationList: + kind: str = "" + page: int = 0 + size: int = 0 + total: int = 0 + items: list[Application] = () + + @classmethod + def from_dict(cls, data: dict) -> ApplicationList: + return cls( + kind=data.get("kind", ""), + page=data.get("page", 0), + size=data.get("size", 0), + total=data.get("total", 0), + items=[Application.from_dict(item) for item in data.get("items", [])], + ) + + +class ApplicationBuilder: + def __init__(self) -> None: + self._data: dict[str, Any] = {} + + + def annotations(self, value: str) -> ApplicationBuilder: + self._data["annotations"] = value + return self + + def auto_prune(self, value: bool) -> ApplicationBuilder: + self._data["auto_prune"] = value + return self + + def auto_sync(self, value: bool) -> ApplicationBuilder: + self._data["auto_sync"] = value + return self + + def conditions(self, value: str) -> ApplicationBuilder: + self._data["conditions"] = value + return self + + def credential_id(self, value: str) -> ApplicationBuilder: + self._data["credential_id"] = value + return self + + def destination_ambient_url(self, value: str) -> ApplicationBuilder: + self._data["destination_ambient_url"] = value + return self + + def destination_project(self, value: str) -> ApplicationBuilder: + self._data["destination_project"] = value + return self + + def health_status(self, value: str) -> ApplicationBuilder: + self._data["health_status"] = value + return self + + def labels(self, value: str) -> ApplicationBuilder: + self._data["labels"] = value + return self + + def last_synced_at(self, value: Optional[datetime]) -> ApplicationBuilder: + self._data["last_synced_at"] = value + return self + + def name(self, value: str) -> ApplicationBuilder: + self._data["name"] = value + return self + + def operation_message(self, value: str) -> ApplicationBuilder: + self._data["operation_message"] = value + return self + + def operation_phase(self, value: str) -> ApplicationBuilder: + self._data["operation_phase"] = value + return self + + def resource_status(self, value: str) -> ApplicationBuilder: + self._data["resource_status"] = value + return self + + def retry_limit(self, value: int) -> ApplicationBuilder: + self._data["retry_limit"] = value + return self + + def self_heal(self, value: bool) -> ApplicationBuilder: + self._data["self_heal"] = value + return self + + def source_path(self, value: str) -> ApplicationBuilder: + self._data["source_path"] = value + return self + + def source_repo_url(self, value: str) -> ApplicationBuilder: + self._data["source_repo_url"] = value + return self + + def source_target_revision(self, value: str) -> ApplicationBuilder: + self._data["source_target_revision"] = value + return self + + def sync_options(self, value: str) -> ApplicationBuilder: + self._data["sync_options"] = value + return self + + def sync_revision(self, value: str) -> ApplicationBuilder: + self._data["sync_revision"] = value + return self + + def sync_status(self, value: str) -> ApplicationBuilder: + self._data["sync_status"] = value + return self + + def build(self) -> dict: + if "destination_project" not in self._data: + raise ValueError("destination_project is required") + if "name" not in self._data: + raise ValueError("name is required") + if "source_path" not in self._data: + raise ValueError("source_path is required") + if "source_repo_url" not in self._data: + raise ValueError("source_repo_url is required") + return dict(self._data) + + +class ApplicationPatch: + def __init__(self) -> None: + self._data: dict[str, Any] = {} + + + def annotations(self, value: str) -> ApplicationPatch: + self._data["annotations"] = value + return self + + def auto_prune(self, value: bool) -> ApplicationPatch: + self._data["auto_prune"] = value + return self + + def auto_sync(self, value: bool) -> ApplicationPatch: + self._data["auto_sync"] = value + return self + + def conditions(self, value: str) -> ApplicationPatch: + self._data["conditions"] = value + return self + + def credential_id(self, value: str) -> ApplicationPatch: + self._data["credential_id"] = value + return self + + def destination_ambient_url(self, value: str) -> ApplicationPatch: + self._data["destination_ambient_url"] = value + return self + + def destination_project(self, value: str) -> ApplicationPatch: + self._data["destination_project"] = value + return self + + def health_status(self, value: str) -> ApplicationPatch: + self._data["health_status"] = value + return self + + def labels(self, value: str) -> ApplicationPatch: + self._data["labels"] = value + return self + + def last_synced_at(self, value: Optional[datetime]) -> ApplicationPatch: + self._data["last_synced_at"] = value + return self + + def name(self, value: str) -> ApplicationPatch: + self._data["name"] = value + return self + + def operation_message(self, value: str) -> ApplicationPatch: + self._data["operation_message"] = value + return self + + def operation_phase(self, value: str) -> ApplicationPatch: + self._data["operation_phase"] = value + return self + + def resource_status(self, value: str) -> ApplicationPatch: + self._data["resource_status"] = value + return self + + def retry_limit(self, value: int) -> ApplicationPatch: + self._data["retry_limit"] = value + return self + + def self_heal(self, value: bool) -> ApplicationPatch: + self._data["self_heal"] = value + return self + + def source_path(self, value: str) -> ApplicationPatch: + self._data["source_path"] = value + return self + + def source_repo_url(self, value: str) -> ApplicationPatch: + self._data["source_repo_url"] = value + return self + + def source_target_revision(self, value: str) -> ApplicationPatch: + self._data["source_target_revision"] = value + return self + + def sync_options(self, value: str) -> ApplicationPatch: + self._data["sync_options"] = value + return self + + def sync_revision(self, value: str) -> ApplicationPatch: + self._data["sync_revision"] = value + return self + + def sync_status(self, value: str) -> ApplicationPatch: + self._data["sync_status"] = value + return self + + def to_dict(self) -> dict: + return dict(self._data) diff --git a/components/ambient-sdk/python-sdk/ambient_platform/client.py b/components/ambient-sdk/python-sdk/ambient_platform/client.py index 72336e498..a08430914 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/client.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/client.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations @@ -17,6 +17,7 @@ if TYPE_CHECKING: from ._agent_api import AgentAPI + from ._application_api import ApplicationAPI from ._credential_api import CredentialAPI from ._inbox_message_api import InboxMessageAPI from ._project_api import ProjectAPI @@ -61,6 +62,7 @@ def __init__( # Initialize API interfaces self._agent_api: Optional[AgentAPI] = None + self._application_api: Optional[ApplicationAPI] = None self._credential_api: Optional[CredentialAPI] = None self._inbox_message_api: Optional[InboxMessageAPI] = None self._project_api: Optional[ProjectAPI] = None @@ -191,6 +193,13 @@ def agents(self) -> AgentAPI: self._agent_api = AgentAPI(self) return self._agent_api @property + def applications(self) -> ApplicationAPI: + """Get the Application API interface.""" + if self._application_api is None: + from ._application_api import ApplicationAPI + self._application_api = ApplicationAPI(self) + return self._application_api + @property def credentials(self) -> CredentialAPI: """Get the Credential API interface.""" if self._credential_api is None: diff --git a/components/ambient-sdk/python-sdk/ambient_platform/credential.py b/components/ambient-sdk/python-sdk/ambient_platform/credential.py index 460ea5ca8..f706bd81a 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/credential.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/credential.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/inbox_message.py b/components/ambient-sdk/python-sdk/ambient_platform/inbox_message.py index 606f064be..9971e3131 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/inbox_message.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/inbox_message.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/project.py b/components/ambient-sdk/python-sdk/ambient_platform/project.py index ea12fd405..ae653e2fa 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/project.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/project.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/project_settings.py b/components/ambient-sdk/python-sdk/ambient_platform/project_settings.py index b34b1fc9d..246b6d8ba 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/project_settings.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/project_settings.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/role.py b/components/ambient-sdk/python-sdk/ambient_platform/role.py index e71240207..9d2c5c904 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/role.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/role.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/role_binding.py b/components/ambient-sdk/python-sdk/ambient_platform/role_binding.py index 99640195b..ef1de3a22 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/role_binding.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/role_binding.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/scheduled_session.py b/components/ambient-sdk/python-sdk/ambient_platform/scheduled_session.py index c1687eab0..aceec552e 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/scheduled_session.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/scheduled_session.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/session.py b/components/ambient-sdk/python-sdk/ambient_platform/session.py index d280d231d..75f5fdc6b 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/session.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/session.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/session_message.py b/components/ambient-sdk/python-sdk/ambient_platform/session_message.py index aeed8fd23..2190c560e 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/session_message.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/session_message.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/python-sdk/ambient_platform/user.py b/components/ambient-sdk/python-sdk/ambient_platform/user.py index c7e51564b..f821a01d7 100644 --- a/components/ambient-sdk/python-sdk/ambient_platform/user.py +++ b/components/ambient-sdk/python-sdk/ambient_platform/user.py @@ -1,7 +1,7 @@ # Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. # Source: ../../ambient-api-server/openapi/openapi.yaml -# Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -# Generated: 2026-05-13T23:03:22Z +# Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +# Generated: 2026-06-11T02:31:17Z from __future__ import annotations diff --git a/components/ambient-sdk/ts-sdk/src/agent.ts b/components/ambient-sdk/ts-sdk/src/agent.ts index 0fa7bb5c7..4b11dac10 100644 --- a/components/ambient-sdk/ts-sdk/src/agent.ts +++ b/components/ambient-sdk/ts-sdk/src/agent.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { ObjectReference, ListMeta } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/agent_api.ts b/components/ambient-sdk/ts-sdk/src/agent_api.ts index a7286fb1e..a464ccc54 100644 --- a/components/ambient-sdk/ts-sdk/src/agent_api.ts +++ b/components/ambient-sdk/ts-sdk/src/agent_api.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; import { ambientFetch, buildQueryString } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/application.ts b/components/ambient-sdk/ts-sdk/src/application.ts new file mode 100644 index 000000000..bc30c1420 --- /dev/null +++ b/components/ambient-sdk/ts-sdk/src/application.ts @@ -0,0 +1,335 @@ +// Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. +// Source: ../../ambient-api-server/openapi/openapi.yaml +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z + +import type { ObjectReference, ListMeta } from './base'; + +export type Application = ObjectReference & { + annotations: string; + auto_prune: boolean; + auto_sync: boolean; + conditions: string; + credential_id: string; + destination_ambient_url: string; + destination_project: string; + health_status: string; + labels: string; + last_synced_at: string; + name: string; + operation_message: string; + operation_phase: string; + resource_status: string; + retry_limit: number; + self_heal: boolean; + source_path: string; + source_repo_url: string; + source_target_revision: string; + sync_options: string; + sync_revision: string; + sync_status: string; +}; + +export type ApplicationList = ListMeta & { + items: Application[]; +}; + +export type ApplicationCreateRequest = { + annotations?: string; + auto_prune?: boolean; + auto_sync?: boolean; + conditions?: string; + credential_id?: string; + destination_ambient_url?: string; + destination_project: string; + health_status?: string; + labels?: string; + last_synced_at?: string; + name: string; + operation_message?: string; + operation_phase?: string; + resource_status?: string; + retry_limit?: number; + self_heal?: boolean; + source_path: string; + source_repo_url: string; + source_target_revision?: string; + sync_options?: string; + sync_revision?: string; + sync_status?: string; +}; + +export type ApplicationPatchRequest = { + annotations?: string; + auto_prune?: boolean; + auto_sync?: boolean; + conditions?: string; + credential_id?: string; + destination_ambient_url?: string; + destination_project?: string; + health_status?: string; + labels?: string; + last_synced_at?: string; + name?: string; + operation_message?: string; + operation_phase?: string; + resource_status?: string; + retry_limit?: number; + self_heal?: boolean; + source_path?: string; + source_repo_url?: string; + source_target_revision?: string; + sync_options?: string; + sync_revision?: string; + sync_status?: string; +}; + +export class ApplicationBuilder { + private data: Record = {}; + + + annotations(value: string): this { + this.data['annotations'] = value; + return this; + } + + autoPrune(value: boolean): this { + this.data['auto_prune'] = value; + return this; + } + + autoSync(value: boolean): this { + this.data['auto_sync'] = value; + return this; + } + + conditions(value: string): this { + this.data['conditions'] = value; + return this; + } + + credentialId(value: string): this { + this.data['credential_id'] = value; + return this; + } + + destinationAmbientUrl(value: string): this { + this.data['destination_ambient_url'] = value; + return this; + } + + destinationProject(value: string): this { + this.data['destination_project'] = value; + return this; + } + + healthStatus(value: string): this { + this.data['health_status'] = value; + return this; + } + + labels(value: string): this { + this.data['labels'] = value; + return this; + } + + lastSyncedAt(value: string): this { + this.data['last_synced_at'] = value; + return this; + } + + name(value: string): this { + this.data['name'] = value; + return this; + } + + operationMessage(value: string): this { + this.data['operation_message'] = value; + return this; + } + + operationPhase(value: string): this { + this.data['operation_phase'] = value; + return this; + } + + resourceStatus(value: string): this { + this.data['resource_status'] = value; + return this; + } + + retryLimit(value: number): this { + this.data['retry_limit'] = value; + return this; + } + + selfHeal(value: boolean): this { + this.data['self_heal'] = value; + return this; + } + + sourcePath(value: string): this { + this.data['source_path'] = value; + return this; + } + + sourceRepoUrl(value: string): this { + this.data['source_repo_url'] = value; + return this; + } + + sourceTargetRevision(value: string): this { + this.data['source_target_revision'] = value; + return this; + } + + syncOptions(value: string): this { + this.data['sync_options'] = value; + return this; + } + + syncRevision(value: string): this { + this.data['sync_revision'] = value; + return this; + } + + syncStatus(value: string): this { + this.data['sync_status'] = value; + return this; + } + + build(): ApplicationCreateRequest { + if (!this.data['destination_project']) { + throw new Error('destination_project is required'); + } + if (!this.data['name']) { + throw new Error('name is required'); + } + if (!this.data['source_path']) { + throw new Error('source_path is required'); + } + if (!this.data['source_repo_url']) { + throw new Error('source_repo_url is required'); + } + return this.data as ApplicationCreateRequest; + } +} + +export class ApplicationPatchBuilder { + private data: Record = {}; + + + annotations(value: string): this { + this.data['annotations'] = value; + return this; + } + + autoPrune(value: boolean): this { + this.data['auto_prune'] = value; + return this; + } + + autoSync(value: boolean): this { + this.data['auto_sync'] = value; + return this; + } + + conditions(value: string): this { + this.data['conditions'] = value; + return this; + } + + credentialId(value: string): this { + this.data['credential_id'] = value; + return this; + } + + destinationAmbientUrl(value: string): this { + this.data['destination_ambient_url'] = value; + return this; + } + + destinationProject(value: string): this { + this.data['destination_project'] = value; + return this; + } + + healthStatus(value: string): this { + this.data['health_status'] = value; + return this; + } + + labels(value: string): this { + this.data['labels'] = value; + return this; + } + + lastSyncedAt(value: string): this { + this.data['last_synced_at'] = value; + return this; + } + + name(value: string): this { + this.data['name'] = value; + return this; + } + + operationMessage(value: string): this { + this.data['operation_message'] = value; + return this; + } + + operationPhase(value: string): this { + this.data['operation_phase'] = value; + return this; + } + + resourceStatus(value: string): this { + this.data['resource_status'] = value; + return this; + } + + retryLimit(value: number): this { + this.data['retry_limit'] = value; + return this; + } + + selfHeal(value: boolean): this { + this.data['self_heal'] = value; + return this; + } + + sourcePath(value: string): this { + this.data['source_path'] = value; + return this; + } + + sourceRepoUrl(value: string): this { + this.data['source_repo_url'] = value; + return this; + } + + sourceTargetRevision(value: string): this { + this.data['source_target_revision'] = value; + return this; + } + + syncOptions(value: string): this { + this.data['sync_options'] = value; + return this; + } + + syncRevision(value: string): this { + this.data['sync_revision'] = value; + return this; + } + + syncStatus(value: string): this { + this.data['sync_status'] = value; + return this; + } + + build(): ApplicationPatchRequest { + return this.data as ApplicationPatchRequest; + } +} diff --git a/components/ambient-sdk/ts-sdk/src/application_api.ts b/components/ambient-sdk/ts-sdk/src/application_api.ts new file mode 100644 index 000000000..ac77032ff --- /dev/null +++ b/components/ambient-sdk/ts-sdk/src/application_api.ts @@ -0,0 +1,46 @@ +// Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. +// Source: ../../ambient-api-server/openapi/openapi.yaml +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z + +import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; +import { ambientFetch, buildQueryString } from './base'; +import type { Application, ApplicationList, ApplicationCreateRequest, ApplicationPatchRequest } from './application'; + +export class ApplicationAPI { + constructor(private readonly config: AmbientClientConfig) {} + + async create(data: ApplicationCreateRequest, opts?: RequestOptions): Promise { + return ambientFetch(this.config, 'POST', '/applications', data, opts); + } + + async get(id: string, opts?: RequestOptions): Promise { + return ambientFetch(this.config, 'GET', `/applications/${id}`, undefined, opts); + } + + async list(listOpts?: ListOptions, opts?: RequestOptions): Promise { + const qs = buildQueryString(listOpts); + return ambientFetch(this.config, 'GET', `/applications${qs}`, undefined, opts); + } + async update(id: string, patch: ApplicationPatchRequest, opts?: RequestOptions): Promise { + return ambientFetch(this.config, 'PATCH', `/applications/${id}`, patch, opts); + } + + async delete(id: string, opts?: RequestOptions): Promise { + return ambientFetch(this.config, 'DELETE', `/applications/${id}`, undefined, opts); + } + + async *listAll(size: number = 100, opts?: RequestOptions): AsyncGenerator { + let page = 1; + while (true) { + const result = await this.list({ page, size }, opts); + for (const item of result.items) { + yield item; + } + if (page * size >= result.total) { + break; + } + page++; + } + } +} diff --git a/components/ambient-sdk/ts-sdk/src/base.ts b/components/ambient-sdk/ts-sdk/src/base.ts index 33bc57236..a6ea2d16b 100644 --- a/components/ambient-sdk/ts-sdk/src/base.ts +++ b/components/ambient-sdk/ts-sdk/src/base.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z export type ObjectReference = { id: string; diff --git a/components/ambient-sdk/ts-sdk/src/client.ts b/components/ambient-sdk/ts-sdk/src/client.ts index 88519398e..087084099 100644 --- a/components/ambient-sdk/ts-sdk/src/client.ts +++ b/components/ambient-sdk/ts-sdk/src/client.ts @@ -1,10 +1,11 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig } from './base'; import { AgentAPI } from './agent_api'; +import { ApplicationAPI } from './application_api'; import { CredentialAPI } from './credential_api'; import { InboxMessageAPI } from './inbox_message_api'; import { ProjectAPI } from './project_api'; @@ -21,6 +22,7 @@ export class AmbientClient { private readonly config: AmbientClientConfig; readonly agents: AgentAPI; + readonly applications: ApplicationAPI; readonly credentials: CredentialAPI; readonly inboxMessages: InboxMessageAPI; readonly projects: ProjectAPI; @@ -67,6 +69,7 @@ export class AmbientClient { }; this.agents = new AgentAPI(this.config); + this.applications = new ApplicationAPI(this.config); this.credentials = new CredentialAPI(this.config); this.inboxMessages = new InboxMessageAPI(this.config); this.projects = new ProjectAPI(this.config); diff --git a/components/ambient-sdk/ts-sdk/src/credential.ts b/components/ambient-sdk/ts-sdk/src/credential.ts index 328843020..2a3fd9058 100644 --- a/components/ambient-sdk/ts-sdk/src/credential.ts +++ b/components/ambient-sdk/ts-sdk/src/credential.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { ObjectReference, ListMeta } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/credential_api.ts b/components/ambient-sdk/ts-sdk/src/credential_api.ts index 656300a98..f1d691554 100644 --- a/components/ambient-sdk/ts-sdk/src/credential_api.ts +++ b/components/ambient-sdk/ts-sdk/src/credential_api.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; import { ambientFetch, buildQueryString } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/inbox_message.ts b/components/ambient-sdk/ts-sdk/src/inbox_message.ts index fe010cc7c..3547eeb5c 100644 --- a/components/ambient-sdk/ts-sdk/src/inbox_message.ts +++ b/components/ambient-sdk/ts-sdk/src/inbox_message.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { ObjectReference, ListMeta } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/inbox_message_api.ts b/components/ambient-sdk/ts-sdk/src/inbox_message_api.ts index 6b09f7ea4..f61b3584a 100644 --- a/components/ambient-sdk/ts-sdk/src/inbox_message_api.ts +++ b/components/ambient-sdk/ts-sdk/src/inbox_message_api.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; import { ambientFetch, buildQueryString } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/index.ts b/components/ambient-sdk/ts-sdk/src/index.ts index a91aa8c86..88f0b47b9 100644 --- a/components/ambient-sdk/ts-sdk/src/index.ts +++ b/components/ambient-sdk/ts-sdk/src/index.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z export { AmbientClient } from './client'; export type { AmbientClientConfig, ListOptions, RequestOptions, ObjectReference, ListMeta, APIError } from './base'; @@ -11,6 +11,10 @@ export type { Agent, AgentList, AgentCreateRequest, AgentPatchRequest } from './ export { AgentBuilder, AgentPatchBuilder } from './agent'; export { AgentAPI } from './agent_api'; +export type { Application, ApplicationList, ApplicationCreateRequest, ApplicationPatchRequest } from './application'; +export { ApplicationBuilder, ApplicationPatchBuilder } from './application'; +export { ApplicationAPI } from './application_api'; + export type { Credential, CredentialList, CredentialCreateRequest, CredentialPatchRequest } from './credential'; export { CredentialBuilder, CredentialPatchBuilder } from './credential'; export { CredentialAPI } from './credential_api'; diff --git a/components/ambient-sdk/ts-sdk/src/project.ts b/components/ambient-sdk/ts-sdk/src/project.ts index 227884eb8..4e98791d3 100644 --- a/components/ambient-sdk/ts-sdk/src/project.ts +++ b/components/ambient-sdk/ts-sdk/src/project.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { ObjectReference, ListMeta } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/project_api.ts b/components/ambient-sdk/ts-sdk/src/project_api.ts index 49c23dd7e..a32821499 100644 --- a/components/ambient-sdk/ts-sdk/src/project_api.ts +++ b/components/ambient-sdk/ts-sdk/src/project_api.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; import { ambientFetch, buildQueryString } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/project_settings.ts b/components/ambient-sdk/ts-sdk/src/project_settings.ts index 60e9f8c24..210a25dca 100644 --- a/components/ambient-sdk/ts-sdk/src/project_settings.ts +++ b/components/ambient-sdk/ts-sdk/src/project_settings.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { ObjectReference, ListMeta } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/project_settings_api.ts b/components/ambient-sdk/ts-sdk/src/project_settings_api.ts index 1a256da43..aa5e45b8d 100644 --- a/components/ambient-sdk/ts-sdk/src/project_settings_api.ts +++ b/components/ambient-sdk/ts-sdk/src/project_settings_api.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; import { ambientFetch, buildQueryString } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/role.ts b/components/ambient-sdk/ts-sdk/src/role.ts index b79091e24..2ea909219 100644 --- a/components/ambient-sdk/ts-sdk/src/role.ts +++ b/components/ambient-sdk/ts-sdk/src/role.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { ObjectReference, ListMeta } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/role_api.ts b/components/ambient-sdk/ts-sdk/src/role_api.ts index 6eaa07f33..d0079b6c3 100644 --- a/components/ambient-sdk/ts-sdk/src/role_api.ts +++ b/components/ambient-sdk/ts-sdk/src/role_api.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; import { ambientFetch, buildQueryString } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/role_binding.ts b/components/ambient-sdk/ts-sdk/src/role_binding.ts index cce01d16d..614e87806 100644 --- a/components/ambient-sdk/ts-sdk/src/role_binding.ts +++ b/components/ambient-sdk/ts-sdk/src/role_binding.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { ObjectReference, ListMeta } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/role_binding_api.ts b/components/ambient-sdk/ts-sdk/src/role_binding_api.ts index 3f769820d..d40f11843 100644 --- a/components/ambient-sdk/ts-sdk/src/role_binding_api.ts +++ b/components/ambient-sdk/ts-sdk/src/role_binding_api.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; import { ambientFetch, buildQueryString } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/scheduled_session.ts b/components/ambient-sdk/ts-sdk/src/scheduled_session.ts index c8dbaec6f..c2ca2ee08 100644 --- a/components/ambient-sdk/ts-sdk/src/scheduled_session.ts +++ b/components/ambient-sdk/ts-sdk/src/scheduled_session.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { ObjectReference, ListMeta } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/scheduled_session_api.ts b/components/ambient-sdk/ts-sdk/src/scheduled_session_api.ts index 687be3ced..850791cb6 100644 --- a/components/ambient-sdk/ts-sdk/src/scheduled_session_api.ts +++ b/components/ambient-sdk/ts-sdk/src/scheduled_session_api.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; import { ambientFetch, buildQueryString } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/session.ts b/components/ambient-sdk/ts-sdk/src/session.ts index 8665655b9..dbb033d36 100644 --- a/components/ambient-sdk/ts-sdk/src/session.ts +++ b/components/ambient-sdk/ts-sdk/src/session.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { ObjectReference, ListMeta } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/session_api.ts b/components/ambient-sdk/ts-sdk/src/session_api.ts index cf79ff347..96ac0a0ff 100644 --- a/components/ambient-sdk/ts-sdk/src/session_api.ts +++ b/components/ambient-sdk/ts-sdk/src/session_api.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; import { ambientFetch, buildQueryString } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/session_message.ts b/components/ambient-sdk/ts-sdk/src/session_message.ts index 6b426e5ea..4bfe7a4ad 100644 --- a/components/ambient-sdk/ts-sdk/src/session_message.ts +++ b/components/ambient-sdk/ts-sdk/src/session_message.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { ObjectReference, ListMeta } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/session_message_api.ts b/components/ambient-sdk/ts-sdk/src/session_message_api.ts index 677fc7a64..0083bbcdb 100644 --- a/components/ambient-sdk/ts-sdk/src/session_message_api.ts +++ b/components/ambient-sdk/ts-sdk/src/session_message_api.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; import { ambientFetch, buildQueryString } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/user.ts b/components/ambient-sdk/ts-sdk/src/user.ts index bb5660431..c683ab5ee 100644 --- a/components/ambient-sdk/ts-sdk/src/user.ts +++ b/components/ambient-sdk/ts-sdk/src/user.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { ObjectReference, ListMeta } from './base'; diff --git a/components/ambient-sdk/ts-sdk/src/user_api.ts b/components/ambient-sdk/ts-sdk/src/user_api.ts index 3b1f278cf..b7d1d6a14 100644 --- a/components/ambient-sdk/ts-sdk/src/user_api.ts +++ b/components/ambient-sdk/ts-sdk/src/user_api.ts @@ -1,7 +1,7 @@ // Code generated by ambient-sdk-generator from openapi.yaml — DO NOT EDIT. // Source: ../../ambient-api-server/openapi/openapi.yaml -// Spec SHA256: da9fbb26cd926e7df1af31ad78f47d005fd328228df521e9e3411636e5069455 -// Generated: 2026-05-13T23:03:22Z +// Spec SHA256: aa4fadb1f795265128f058fdc5ffa2bd25396c8516537ea97ba3671dc007b8fc +// Generated: 2026-06-11T02:31:17Z import type { AmbientClientConfig, ListOptions, RequestOptions } from './base'; import { ambientFetch, buildQueryString } from './base'; diff --git a/workflows/sessions/ambient-model.workflow.md b/workflows/sessions/ambient-model.workflow.md index 88845ef3d..34126c628 100644 --- a/workflows/sessions/ambient-model.workflow.md +++ b/workflows/sessions/ambient-model.workflow.md @@ -60,7 +60,7 @@ Checklist: - [ ] Read this document top to bottom - [ ] Read the spec (`ambient-model.spec.md`) header to check the Last Updated date - [ ] Confirm you are working on the correct branch and project -- [ ] Verify the kind cluster name: `podman ps | grep kind` (do not assume — cluster name drifts) +- [ ] Verify the target cluster: `kubectl config current-context` and confirm the namespace (kind cluster: `podman ps | grep kind`; UAT/staging: check `kubectl get ns`) ### Step 2 — Read the Spec @@ -133,11 +133,20 @@ Decompose the gap table into per-agent work items, sequenced by pipeline order: **Wave 3 — SDK** (gates BE, CLI, FE) -- Run SDK generator against updated `openapi.yaml` +- Run SDK generator: `cd components/ambient-sdk && make generate-sdk` +- The generator reads `components/ambient-api-server/openapi/openapi.yaml` and produces Go, Python, and TypeScript clients - Commit generated types, builders, client methods - **Verify TS and Python client paths** for any nested resource — the generator uses the first path segment as base path; nested resources require hand-written extension files -- **Implementation detail:** see `.claude/context/sdk-development.md` -- **Acceptance:** `go build ./...` in go-sdk clean; Python SDK `python -m pytest tests/` passes +- For top-level resources (like Application at `/applications`), the generator handles paths correctly — no extension files needed for standard CRUD +- For sub-resource actions (`/sync`, `/refresh`, `/status`), hand-written extension methods are required in `go-sdk/client/_extensions.go` +- **Build commands:** + ```bash + cd components/ambient-sdk + make build-generator # compile generator binary + make generate-sdk # generate all three SDKs + make verify-sdk # generate + verify Go/Python/TS compile + ``` +- **Acceptance:** `make verify-sdk` passes (Go `go build ./...`, Python import check, TS `npm run build`) **Wave 4 — BE + CP** (parallel after Wave 3) @@ -597,3 +606,77 @@ A route existing in openapi.yaml is necessary but not sufficient. Field-level dr **Rule:** Integration tests for a resource must use the route the spec defines, not a route that happens to work in the current implementation. For a global resource (no project scope), the factory and every integration test must call the global path. If the test is written against a nested path for a resource the spec defines as global, the test is wrong — fix the test, not just the implementation. **Corollary:** Factory test `Provider` values must use valid enum values. A factory that passes `"test-provider"` will compile and run even if the API rejects it — use `"github"` or another value from the spec's provider enum table. + +## Lessons Learned (Run Log — 2026-06-11) + +### Generator `--project` Flag Controls API Path Prefix + +The `scripts/generator.go` `--project` flag is used to construct the API path prefix: `/api/{project}/v1/{kind}`. Using `--project ambient-api-server` produces paths like `/api/ambient-api-server/v1/applications` instead of the correct `/api/ambient/v1/applications`. The flag value should match the desired URL path segment, not the component directory name. + +**Rule:** Always use `--project ambient` (not `--project ambient-api-server`) when running the generator. The workflow's Step 5 command already specifies this correctly. + +### Generator Output Requires `make generate` Before Build + +The generator's `--skip-generate` flag (used when the generator itself runs) means the OpenAPI Go client types (`openapi.Application`, `openapi.ApplicationList`, `openapi.ApplicationPatchRequest`) are not created. After running the generator, `make generate` must run before `go build ./...` will succeed. + +**Rule:** After `scripts/generator.go` runs, always run `make generate` in the api-server directory to regenerate `pkg/api/openapi/` from the updated specs. + +### Generator Omits DELETE from OpenAPI Spec + +The generator creates GET, LIST, POST, and PATCH endpoints in the OpenAPI spec but does NOT generate a DELETE endpoint. If the Kind needs delete support, the DELETE endpoint must be manually added to `openapi.{kind}.yaml`. + +**Rule:** After running the generator, check whether the Kind requires DELETE. If so, add the delete section to the `/{id}:` path in the OpenAPI spec following the session/credential pattern. + +### Generator Misses `time` Import for `*time.Time` Fields + +When the model has `*time.Time` fields (e.g., `LastSyncedAt`), the generator adds the field correctly but sometimes omits the `"time"` import in `migration.go` and adds an unused `"time"` import in `presenter.go`. + +**Rule:** After running the generator, check imports in `migration.go` (needs `"time"` if `*time.Time` is used) and `presenter.go` (remove unused `"time"` import). + +### Test `testmain_test.go` Must Import All Plugin Dependencies + +Generated `testmain_test.go` only imports the test helper. If the plugin's migration seeds roles or references tables from other plugins, those plugins must be imported via side-effect imports. Without them, testcontainer initialization crashes with `pq: relation "roles" does not exist`. + +**Rule:** Copy the full side-effect import block from `plugins/credentials/testmain_test.go` into any new plugin's `testmain_test.go`. This ensures all migrations run in the correct order. + +### POST Sub-Resource Handlers Without Body Must Use `HandleGet` + +`handlers.Handle()` expects a request body and will return 400 if the POST has no body. Sub-resource actions like `/sync` and `/refresh` that don't need a request body should use `handlers.HandleGet()` instead. + +**Rule:** For POST handlers that perform an action without request body input, use `handlers.HandleGet(w, r, cfg)`, not `handlers.Handle(w, r, cfg, http.StatusOK)`. The session `Start` and `Stop` handlers follow this pattern. + +### Deployment: Migration Init Container Image Must Be Updated Separately + +`kubectl set image` only updates the main container. The migration init container uses a separate image reference and must be updated via a JSON patch or `kubectl get/apply` roundtrip. + +**Rule:** When deploying a new api-server image, update BOTH the main container (`api-server`) and the migration init container (`migration`). The migration init container runs `ambient-api-server migrate` and must contain the new migration code. + +### RBAC: `pathToAction` Must Map Sub-Resource Verbs + +The RBAC middleware's `pathToAction()` function maps URL path suffixes to permission actions. Without entries for `sync` and `refresh`, POST requests to those sub-resources map to `create` instead of `update`. + +**Rule:** When adding sub-resource endpoints with non-CRUD semantics, add their path suffixes to `pathToAction()` in `pkg/rbac/middleware.go`. + +### RBAC: `isListEndpoint` Must Include New Resource Plural Names + +The RBAC middleware's `isListEndpoint()` function has a hardcoded list of plural resource names used to distinguish list vs singleton GET requests. New resources must be added to this list. + +**Rule:** When adding a new resource, add its plural name to the `isListEndpoint()` switch case in `pkg/rbac/scope.go`. + +### UAT Deployment: `CREDENTIAL_ENCRYPTION_ALLOW_PLAINTEXT` Required + +The current branch includes credential encryption checks that the production v0.2.13 image did not have. When deploying to a cluster without a configured keyring, set `CREDENTIAL_ENCRYPTION_ALLOW_PLAINTEXT=true` as an environment variable on the deployment. + +### Integration Test Method Names Follow API Path Prefix + +The generated integration tests use method names derived from the API path (e.g., `ApiAmbientV1ApplicationsGet`). If the generator was run with the wrong `--project` flag, the test method names will reference non-existent methods. After fixing the OpenAPI paths, regenerate with `make generate` and update the test method names accordingly. + +### CI Runs `golangci-lint` — Must Pass Before PR Merge + +The CI pipeline runs `golangci-lint` (v2.x) on both `ambient-api-server` and `ambient-cli` with `--timeout=5m`. Common issues caught: + +- **`ineffassign`**: Assigning to `err` without checking it. In integration tests where you send a malformed body and only care about the HTTP status code, use `restyResp, _ := resty.R()...` (blank identifier) instead of `restyResp, err := resty.R()...`. +- **`staticcheck` ST1000**: Every Go package must have a package comment. New command packages (e.g., `package application`) need `// Package application implements...` above the `package` declaration. +- **`unused`**: Package-level variables that are declared but never referenced anywhere in the package. Remove them or use blank identifier `_`. + +**Rule:** Run `gofmt -w .` and `golangci-lint run --timeout=5m` in each changed Go component before pushing. The CI checks `gofmt` separately from `golangci-lint` — both must pass. The CI config uses `only-new-issues: false`, so pre-existing lint issues in unchanged files will also block the PR.