From c0396e5be3dcdf444f42c750db9d468125b479d1 Mon Sep 17 00:00:00 2001 From: shivay Date: Wed, 25 Feb 2026 09:43:52 +0530 Subject: [PATCH 1/4] feat: Updated OpenAPI file for cloud gateway-addon. --- openapi.yaml | 529 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 529 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index dd9ed065..f5924907 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8249,8 +8249,107 @@ paths: parameters: - $ref: '#/components/parameters/gatewayId' - $ref: '#/components/parameters/virtualClusterId' + /v2/cloud-gateways/add-ons: + post: + x-unstable: true + x-internal: true + x-speakeasy-entity-operation: + terraform-resource: CloudGatewayAddOn#create + operationId: create-add-on + summary: Create Add-On + description: | + Creates a new add-on. Specific add-on types (e.g., managed cache) + are defined by the sub-kind configuration. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateAddOnRequest' + responses: + '201': + $ref: '#/components/responses/CreateAddOnResponse' + '400': + $ref: '#/components/responses/CloudGatewaysBadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/CloudGatewaysForbidden' + '404': + $ref: '#/components/responses/NotFound' + '409': + $ref: '#/components/responses/CloudGatewaysConflict' + servers: + - url: 'https://global.api.konghq.com/' + tags: + - Add-Ons + x-servers-added: true + x-speakeasy-group: CloudGateways + '/v2/cloud-gateways/add-ons/{addOnId}': + get: + x-unstable: true + x-internal: true + x-speakeasy-entity-operation: + terraform-resource: CloudGatewayAddOn#read + operationId: get-add-on + summary: Get Add-On + description: Retrieves an add-on by ID. + parameters: + - $ref: '#/components/parameters/AddOnId' + responses: + '200': + $ref: '#/components/responses/RetrieveAddOnResponse' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + servers: + - url: 'https://global.api.konghq.com/' + tags: + - Add-Ons + x-servers-added: true + x-speakeasy-group: CloudGateways + delete: + x-unstable: true + x-internal: true + x-speakeasy-entity-operation: + terraform-resource: CloudGatewayAddOn#delete + terraform-datasource: null + operationId: delete-add-on + summary: Delete Add-On + description: | + Deletes an add-on by ID. The request will be rejected if the managed cache partial is still in use by some plugins. + parameters: + - $ref: '#/components/parameters/AddOnId' + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/CloudGatewaysBadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + servers: + - url: 'https://global.api.konghq.com/' + tags: + - Add-Ons + x-servers-added: true + x-speakeasy-group: CloudGateways components: parameters: + AddOnId: + name: addOnId + description: ID of the add-on to operate on. + required: true + in: path + schema: + $ref: '#/components/schemas/AddOnId' + x-speakeasy-match: id ApiId: schema: type: string @@ -28314,6 +28413,405 @@ components: fields: - vault x-sensitive: true + ControlPlaneGeo: + description: Set of control-plane geos supported for deploying cloud-gateways configurations. + type: string + enum: + - us + - eu + - au + - me + - in + - sg + title: Control-Plane Geo + x-speakeasy-unknown-values: allow + ProviderName: + description: Name of cloud provider. + type: string + example: aws + enum: + - aws + - azure + - gcp + title: Provider Name + x-enum-internal: [] + x-speakeasy-unknown-values: allow + AddOnId: + type: string + format: uuid + example: 550e8400-e29b-41d4-a716-446655440000 + readOnly: true + x-speakeasy-param-suppress-computed-diff: true + AddOnConfigResponse: + description: Configuration object for different types of add-ons. + type: object + oneOf: + - $ref: '#/components/schemas/ManagedCacheAddOnConfigResponse' + title: AddOnConfigResponse + ManagedCacheAddOnConfigResponse: + description: Configuration for managed cache add-on. + type: object + properties: + kind: + description: Type of add-on configuration. + type: string + const: managed-cache.v0 + capacity_config: + $ref: '#/components/schemas/ManagedCacheCapacityConfig' + data_plane_groups: + description: List of data-plane groups where the managed cache is deployed. + type: array + items: + $ref: '#/components/schemas/ManagedCacheAddOnDataPlaneGroup' + state_metadata: + description: | + Metadata describing the state of the managed cache add-on. + type: object + additionalProperties: false + properties: + cache_config_id: + description: Reference to cache configuration for this add-on. + type: string + format: uuid + example: edaf40f9-9fb0-4ffe-bb74-4e763a6bd471 + default: null + nullable: true + x-speakeasy-param-computed: false + cache_server_name: + description: Env vault path to cache server name. + type: string + example: '{vault://env/ADDON_MANAGED_CACHE_SERVER_NAME}' + default: null + nullable: true + x-speakeasy-param-computed: false + cache_host: + description: Env vault path to cache hostname. + type: string + example: '{vault://env/ADDON_MANAGED_CACHE_HOST}' + default: null + nullable: true + x-speakeasy-param-computed: false + cache_port: + description: Env vault path to cache port. + type: string + example: '{vault://env/ADDON_MANAGED_CACHE_PORT}' + default: null + nullable: true + x-speakeasy-param-computed: false + cache_username: + description: Env vault path to cache username. + type: string + example: '{vault://env/ADDON_MANAGED_CACHE_USERNAME}' + default: null + nullable: true + x-speakeasy-param-computed: false + cloud_authentication: + description: | + Metadata describing the cloud authentication details for managed cache add-on. + type: object + default: null + additionalProperties: false + nullable: true + properties: + auth_provider: + description: Env vault path to cache auth provider. + type: string + example: '{vault://env/ADDON_MANAGED_CACHE_AUTH_PROVIDER}' + default: null + nullable: true + x-speakeasy-param-computed: false + aws_cache_name: + description: Env vault path to aws cache name. + type: string + example: '{vault://env/ADDON_MANAGED_CACHE_AWS_CACHE_NAME}' + default: null + nullable: true + x-speakeasy-param-computed: false + aws_region: + description: Env vault path to aws region. + type: string + example: '{vault://env/ADDON_MANAGED_CACHE_AWS_REGION}' + default: null + nullable: true + x-speakeasy-param-computed: false + aws_assume_role_arn: + description: Env vault path to aws assume role arn. + type: string + example: '{vault://env/ADDON_MANAGED_CACHE_AWS_ASSUME_ROLE_ARN}' + default: null + nullable: true + x-speakeasy-param-computed: false + azure_tenant_id: + description: Env vault path to azure tenant id. + type: string + example: '{vault://env/ADDON_MANAGED_CACHE_AZURE_TENANT_ID}' + default: null + nullable: true + x-speakeasy-param-computed: false + x-speakeasy-param-computed: false + additionalProperties: false + required: + - kind + - capacity_config + - data_plane_groups + - state_metadata + title: ManagedCacheAddOnConfigResponse + ManagedCacheAddOnDataPlaneGroup: + description: Object that describes a data-plane group where managed cache add-on is deployed. + type: object + properties: + id: + description: ID of the data-plane group. + type: string + format: uuid + example: 1150820b-c69f-4a2a-b9be-bbcdbc5cd618 + cloud_gateway_network_id: + description: Network ID this data-plane group is attached to. + type: string + format: uuid + example: 36ae63d3-efd1-4bec-b246-62aa5d3f5695 + provider: + $ref: '#/components/schemas/ProviderName' + region: + description: Region of cloud provider the data-plane group is deployed to. + type: string + example: us-east-1 + state: + description: | + The current state of the managed cache add-on in the data-plane group. Possible values: + - `initializing` - The add-on is in the process of being initialized/updated and is setting up necessary resources for this data-plane group. + - `ready` - The add-on is fully operational for this data-plane group. + - `error` - The add-on is in an error state, and is not operational for this data-plane group. + - `terminating` - The add-on is in the process of being deleted for this data-plane group. + type: string + enum: + - initializing + - ready + - error + - terminating + readOnly: true + x-speakeasy-param-suppress-computed-diff: true + x-speakeasy-unknown-values: allow + state_metadata: + description: | + Metadata describing the state of the managed cache add-on in the data-plane group. + type: object + additionalProperties: false + properties: + error_reason: + description: | + Reason why the managed cache add-on may be in an error state, reported from backing infrastructure. + type: string + example: | + Failed to create managed cache add-on due to invalid configuration. + default: null + nullable: true + x-speakeasy-param-computed: false + additionalProperties: false + required: + - id + - cloud_gateway_network_id + - provider + - region + - state + - state_metadata + title: ManagedCacheAddOnDataPlaneGroup + AddOnState: + description: | + The current state of the add-on. Possible values: + - `initializing` - The add-on is in the process of being initialized/updated. + - `ready` - The add-on is fully operational. + - `terminating` - The add-on is in the process of being deleted. + type: string + enum: + - initializing + - ready + - terminating + readOnly: true + title: Add-On State + x-speakeasy-param-suppress-computed-diff: true + x-speakeasy-unknown-values: allow + AddOnResponse: + description: Object containing information about an add-on. + type: object + properties: + id: + $ref: '#/components/schemas/AddOnId' + name: + $ref: '#/components/schemas/AddOnName' + owner: + $ref: '#/components/schemas/AddOnOwner' + config: + $ref: '#/components/schemas/AddOnConfigResponse' + entity_version: + description: 'Monotonically-increasing version count of the add-on, to indicate the order of updates to the add-on.' + type: integer + example: 1 + readOnly: true + x-speakeasy-param-suppress-computed-diff: true + state: + $ref: '#/components/schemas/AddOnState' + created_at: + description: RFC-3339 timestamp representation of add-on creation date. + type: string + format: date-time + example: '2025-08-26T06:56:41Z' + readOnly: true + x-speakeasy-param-suppress-computed-diff: true + updated_at: + description: RFC-3339 timestamp representation of add-on update date. + type: string + format: date-time + example: '2025-08-26T06:56:41Z' + readOnly: true + x-speakeasy-param-suppress-computed-diff: true + additionalProperties: false + required: + - id + - name + - owner + - config + - entity_version + - state + - created_at + - updated_at + title: AddOnResponse + CreateAddOnRequest: + description: Request schema for creating an add-on. + type: object + properties: + name: + $ref: '#/components/schemas/AddOnName' + owner: + $ref: '#/components/schemas/AddOnOwner' + config: + $ref: '#/components/schemas/CreateAddOnConfig' + additionalProperties: false + required: + - name + - owner + - config + title: CreateAddOnRequest + AddOnName: + description: Unique human-readable name of the add-on. + type: string + example: my-add-on + maxLength: 70 + minLength: 1 + title: AddOnName + AddOnOwner: + description: Owner for the add-on. + type: object + oneOf: + - $ref: '#/components/schemas/ControlPlaneAddOnOwner' + - $ref: '#/components/schemas/ControlPlaneGroupAddOnOwner' + title: AddOnOwner + ControlPlaneAddOnOwner: + description: Control Plane is the owner for the add-on. + type: object + properties: + kind: + description: Type of owner for the add-on. + type: string + const: control-plane + control_plane_id: + description: ID of the control-plane that owns this add-on. + type: string + format: uuid + example: 123e4567-e89b-12d3-a456-426614174000 + control_plane_geo: + $ref: '#/components/schemas/ControlPlaneGeo' + additionalProperties: false + required: + - kind + - control_plane_id + - control_plane_geo + title: ControlPlaneAddOnOwner + x-speakeasy-name-override: control_plane + ControlPlaneGroupAddOnOwner: + description: Control Plane Group is the owner for the add-on. + type: object + properties: + kind: + description: Type of owner for the add-on. + type: string + const: control-plane-group + control_plane_group_id: + description: ID of the control-plane group that owns this add-on. + type: string + format: uuid + example: 123e4567-e89b-12d3-a456-426614174000 + control_plane_group_geo: + $ref: '#/components/schemas/ControlPlaneGeo' + additionalProperties: false + required: + - kind + - control_plane_group_id + - control_plane_group_geo + title: ControlPlaneGroupAddOnOwner + x-speakeasy-name-override: control_plane_group + CreateAddOnConfig: + description: Configuration for creating different types of add-ons. + type: object + oneOf: + - $ref: '#/components/schemas/CreateManagedCacheAddOnConfig' + title: CreateAddOnConfig + CreateManagedCacheAddOnConfig: + description: Configuration for creating a managed cache add-on. + type: object + properties: + kind: + description: Type of add-on configuration. + type: string + const: managed-cache.v0 + capacity_config: + $ref: '#/components/schemas/ManagedCacheCapacityConfig' + additionalProperties: false + required: + - kind + - capacity_config + title: CreateManagedCacheAddOnConfig + x-speakeasy-name-override: managed_cache + ManagedCacheCapacityConfig: + description: Configuration for managed cache capacity and performance characteristics. + type: object + oneOf: + - $ref: '#/components/schemas/TieredCapacityConfig' + title: ManagedCacheCapacityConfig + TieredCapacityConfig: + description: Capacity tiers with pre-configured size and performance characteristics. + type: object + properties: + kind: + description: Type of capacity configuration. + type: string + const: tiered + tier: + description: | + Capacity tier that determines both cache size and performance characteristics: + - micro: ~0.5 GiB capacity + - small: ~1 GiB capacity + - medium: ~3 GiB capacity + - large: ~6 GiB capacity + - xlarge: ~12 GiB capacity + - 2xlarge: ~25 GiB capacity + - 4xlarge: ~52 GiB capacity + type: string + enum: + - micro + - small + - medium + - large + - xlarge + - 2xlarge + - 4xlarge + x-speakeasy-unknown-values: allow + additionalProperties: false + required: + - kind + - tier + title: TieredCapacityConfig + x-speakeasy-name-override: Tiered CreatePortalCustomDomainSSL: type: object properties: @@ -31760,6 +32258,36 @@ components: application/problem+json: schema: $ref: '#/components/schemas/BaseError' + CloudGatewaysBadRequest: + description: Bad Request + content: + application/problem+json: + schema: + $ref: '#/components/schemas/BadRequestError' + CloudGatewaysForbidden: + description: Forbidden + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ForbiddenError' + CloudGatewaysConflict: + description: Conflict + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ConflictError' + CreateAddOnResponse: + description: Response format for creating an add-on. + content: + application/json: + schema: + $ref: '#/components/schemas/AddOnResponse' + RetrieveAddOnResponse: + description: Response format for retrieving an add-on by ID. + content: + application/json: + schema: + $ref: '#/components/schemas/AddOnResponse' securitySchemes: personalAccessToken: type: http @@ -31863,6 +32391,7 @@ tags: description: | Configure a schema registry that can be used to validate payloads when producing/consuming messages - name: Event Gateway Vaults + - name: Add-Ons security: - personalAccessToken: [] - systemAccountAccessToken: [] From 004ddbf0ba174e25632b86e38e61a3d4792eef55 Mon Sep 17 00:00:00 2001 From: shivay Date: Wed, 25 Feb 2026 09:46:41 +0530 Subject: [PATCH 2/4] feat: added .go files, .speakeasy and docs directory --- .speakeasy/gen.lock | 215 ++++- docs/resources/cloud_gateway_add_on.md | 226 +++++ .../import-by-string-id.tf | 5 + .../konnect_cloud_gateway_add_on/import.sh | 1 + .../konnect_cloud_gateway_add_on/resource.tf | 19 + .../provider/cloudgatewayaddon_resource.go | 627 ++++++++++++ .../cloudgatewayaddon_resource_sdk.go | 184 ++++ internal/provider/meshservice_resource_sdk.go | 4 +- internal/provider/provider.go | 1 + internal/provider/types/add_on_owner.go | 8 + .../provider/types/cloud_authentication.go | 15 + internal/provider/types/control_plane.go | 12 + .../provider/types/control_plane_group.go | 12 + .../provider/types/create_add_on_config.go | 8 + internal/provider/types/managed_cache.go | 7 + .../managed_cache_add_on_config_response.go | 9 + ...e_add_on_config_response_state_metadata.go | 16 + .../managed_cache_add_on_data_plane_group.go | 16 + .../types/managed_cache_capacity_config.go | 7 + internal/provider/types/state_metadata.go | 11 + internal/provider/types/tiered.go | 11 + internal/sdk/cloudgateways.go | 897 ++++++++++++++++++ internal/sdk/konnectbeta.go | 2 + internal/sdk/models/operations/createaddon.go | 96 ++ internal/sdk/models/operations/deleteaddon.go | 90 ++ internal/sdk/models/operations/getaddon.go | 90 ++ .../sdk/models/shared/addonconfigresponse.go | 73 ++ internal/sdk/models/shared/addonowner.go | 99 ++ internal/sdk/models/shared/addonresponse.go | 98 ++ internal/sdk/models/shared/addonstate.go | 41 + internal/sdk/models/shared/controlplane.go | 46 + internal/sdk/models/shared/controlplanegeo.go | 47 + .../sdk/models/shared/controlplanegroup.go | 46 + .../sdk/models/shared/createaddonconfig.go | 73 ++ .../sdk/models/shared/createaddonrequest.go | 34 + internal/sdk/models/shared/managedcache.go | 37 + .../shared/managedcacheaddonconfigresponse.go | 186 ++++ .../shared/managedcacheaddondataplanegroup.go | 146 +++ .../shared/managedcachecapacityconfig.go | 73 ++ internal/sdk/models/shared/meshserviceitem.go | 20 +- internal/sdk/models/shared/providername.go | 38 + internal/sdk/models/shared/tiered.go | 96 ++ 42 files changed, 3718 insertions(+), 24 deletions(-) create mode 100644 docs/resources/cloud_gateway_add_on.md create mode 100644 examples/resources/konnect_cloud_gateway_add_on/import-by-string-id.tf create mode 100644 examples/resources/konnect_cloud_gateway_add_on/import.sh create mode 100644 examples/resources/konnect_cloud_gateway_add_on/resource.tf create mode 100644 internal/provider/cloudgatewayaddon_resource.go create mode 100644 internal/provider/cloudgatewayaddon_resource_sdk.go create mode 100644 internal/provider/types/add_on_owner.go create mode 100644 internal/provider/types/cloud_authentication.go create mode 100644 internal/provider/types/control_plane.go create mode 100644 internal/provider/types/control_plane_group.go create mode 100644 internal/provider/types/create_add_on_config.go create mode 100644 internal/provider/types/managed_cache.go create mode 100644 internal/provider/types/managed_cache_add_on_config_response.go create mode 100644 internal/provider/types/managed_cache_add_on_config_response_state_metadata.go create mode 100644 internal/provider/types/managed_cache_add_on_data_plane_group.go create mode 100644 internal/provider/types/managed_cache_capacity_config.go create mode 100644 internal/provider/types/state_metadata.go create mode 100644 internal/provider/types/tiered.go create mode 100644 internal/sdk/cloudgateways.go create mode 100644 internal/sdk/models/operations/createaddon.go create mode 100644 internal/sdk/models/operations/deleteaddon.go create mode 100644 internal/sdk/models/operations/getaddon.go create mode 100644 internal/sdk/models/shared/addonconfigresponse.go create mode 100644 internal/sdk/models/shared/addonowner.go create mode 100644 internal/sdk/models/shared/addonresponse.go create mode 100644 internal/sdk/models/shared/addonstate.go create mode 100644 internal/sdk/models/shared/controlplane.go create mode 100644 internal/sdk/models/shared/controlplanegeo.go create mode 100644 internal/sdk/models/shared/controlplanegroup.go create mode 100644 internal/sdk/models/shared/createaddonconfig.go create mode 100644 internal/sdk/models/shared/createaddonrequest.go create mode 100644 internal/sdk/models/shared/managedcache.go create mode 100644 internal/sdk/models/shared/managedcacheaddonconfigresponse.go create mode 100644 internal/sdk/models/shared/managedcacheaddondataplanegroup.go create mode 100644 internal/sdk/models/shared/managedcachecapacityconfig.go create mode 100644 internal/sdk/models/shared/providername.go create mode 100644 internal/sdk/models/shared/tiered.go diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 49d1e5b9..5a96d037 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,16 +1,16 @@ lockVersion: 2.0.0 id: e3bbe1e9-fe63-436b-a42c-05e3e3f77633 management: - docChecksum: 68a92442fb3b4efb80c481de5a44487b + docChecksum: 12b70e1e6518da31d43fd4d068e2d67b docVersion: 2.0.0 speakeasyVersion: 1.724.1 generationVersion: 2.836.5 releaseVersion: 0.15.0 configChecksum: bae0d50bb6de966dfc3ba42f26e0eb2b persistentEdits: - generation_id: 8417d1ae-72b4-4dca-b559-45c05b0ed1a8 - pristine_commit_hash: 7b45c0d91708c7ffd252a55d36689d27b9ac49bb - pristine_tree_hash: a385b1eee7775b541a5ee512fe3c80eb001b76f6 + generation_id: 64175109-092d-4f95-9211-d53cba3a39ea + pristine_commit_hash: 7970abcfc5f1f2ffd6b18185c70fba65d3d448bb + pristine_tree_hash: 3612745ba766a6e1c2650b2c1f6e5b6f76d4456e features: terraform: additionalDependencies: 0.1.0 @@ -20,8 +20,10 @@ features: deprecations: 2.82.0 globalSecurity: 2.82.2 globalServerURLs: 2.83.1 + groups: 2.81.3 ignores: 2.82.0 inputOutputModels: 2.83.0 + methodServerURLs: 2.83.0 nameOverrides: 2.81.5 nullables: 0.0.0 pagination: 2.83.5 @@ -170,6 +172,18 @@ trackedFiles: id: a44b127425a7 last_write_checksum: sha1:0216912a2a1e21f309bf0046c68d2cf57151db53 pristine_git_object: ede0f012fc5e697e921f184f0329d11d28661e5e + examples/resources/konnect-beta_cloud_gateway_add_on/import-by-string-id.tf: + id: b1db1450b72e + last_write_checksum: sha1:50ef79a428a2dab81108b26f1774c541367fbf94 + pristine_git_object: f32579141bfa6ea7ad84498a94326d337a08fa0a + examples/resources/konnect-beta_cloud_gateway_add_on/import.sh: + id: "236632041369" + last_write_checksum: sha1:c426b5050159e67ce6f1e46f72053b2dce1d5743 + pristine_git_object: 93c1e9bbd1ad3303f9e97de8b21c8da463503a01 + examples/resources/konnect-beta_cloud_gateway_add_on/resource.tf: + id: 875b3b11d43d + last_write_checksum: sha1:82f0cb403f712967eb16b3debdded98279cbd52f + pristine_git_object: fb9f0695d253402c98901ef63eda1447de82fa98 examples/resources/konnect-beta_dashboard/import-by-string-id.tf: id: f03a90968e12 last_write_checksum: sha1:437720f13856aba7df4cd92cc52ee0b779ffa064 @@ -1138,6 +1152,14 @@ trackedFiles: id: 078a9e050e56 last_write_checksum: sha1:bb7ec07a621b5d9405f299a4b817350ba497f071 pristine_git_object: f1c58b0215df0ac6a5b109ed359cecc3d50f972c + internal/provider/cloudgatewayaddon_resource.go: + id: 35eb5cdbfe40 + last_write_checksum: sha1:5b032eecc7a1042673cf7b770ed9721dfb82e68e + pristine_git_object: 1ca430cbdb64ba7b73f8843471bf71bf08e26ba6 + internal/provider/cloudgatewayaddon_resource_sdk.go: + id: a4f9b8f4cb77 + last_write_checksum: sha1:aca8df4b531251cba2cb7286c94e569df341471f + pristine_git_object: 5b90e28934b5d6918fb2ae5829f953bd24c52f61 internal/provider/dashboard_resource.go: id: ed676b0ddc21 last_write_checksum: sha1:531417f49a0da54ef19fd9fa64b0ff8cc9a2074e @@ -1496,8 +1518,8 @@ trackedFiles: pristine_git_object: d2c6eb96341af41fe8eef36c884c66e2718527e6 internal/provider/meshservice_resource_sdk.go: id: c265886770aa - last_write_checksum: sha1:4a2ef645f5299915d72606de2550e72788ffdba8 - pristine_git_object: 555ef2aa6936c8945a52a77fc969fde57735af71 + last_write_checksum: sha1:7a8f8f33a1e50f36af8814e8143dd9700a6682b2 + pristine_git_object: cf8203ee33809f1217a1313a73486fe8dafd5e8e internal/provider/meshtcproute_resource.go: id: 8c50f06a5b49 last_write_checksum: sha1:335a4e02161eaa04840dc4cc4c952fd9388d3b1a @@ -1652,8 +1674,8 @@ trackedFiles: pristine_git_object: 1c71c80fb5c2453180d6fc79fa5d5fa1d78b9fe0 internal/provider/provider.go: id: 1e7e86841cf3 - last_write_checksum: sha1:ff17d2486577deb9235b32092cf7a45ccdd8d8e8 - pristine_git_object: 78121d319b3f4fd6c461a1f004b2f9522b17a959 + last_write_checksum: sha1:579b844344bd2b2356eab1ed56867bfbd9e53e0d + pristine_git_object: e1340ab08ea9d9ca205ee0e509b9d5917dc84dfc internal/provider/reflect/diags.go: id: 35b6b44972e2 last_write_checksum: sha1:ace8bc53054bb1d8ee8689acf3e4323de75a6297 @@ -1766,6 +1788,10 @@ trackedFiles: id: 9756c197c181 last_write_checksum: sha1:b4cca7d362075e874d069680723e2fb5902385bd pristine_git_object: 9662e7e8e82d9f67ea70dc281f8d99565ccbf1e6 + internal/provider/types/add_on_owner.go: + id: 244580eacbc2 + last_write_checksum: sha1:10caa305920565bdb6a31b5c2b8f4c0c9ee037c3 + pristine_git_object: 9f236a3ba0dff65dc1cdb507f7309cfc493832af internal/provider/types/addresses.go: id: a88057fbd7fa last_write_checksum: sha1:c7ca65cb8da8312a6b138d5a129d9e587b742943 @@ -1950,6 +1976,10 @@ trackedFiles: id: 9dcdb4de45c4 last_write_checksum: sha1:a731062fa52a67d54c9bc504514030e8ad603391 pristine_git_object: bf52dd5a46ad44f1cab1165bd30b155a7f3b27ab + internal/provider/types/cloud_authentication.go: + id: 5225007dd97b + last_write_checksum: sha1:209931e25bf2ff491b2c5306a227600db677d0a1 + pristine_git_object: e51ccdeeda08243233a26bfcd9ffdb551d6b97ba internal/provider/types/cluster.go: id: 5b0b3ef72631 last_write_checksum: sha1:b20f36c3974dd24168b43a326b7e52d41090053b @@ -1978,6 +2008,14 @@ trackedFiles: id: b3703adc8327 last_write_checksum: sha1:451016e0e419266d8821aa56d6c0e7bfa390309b pristine_git_object: dc0cc6ba9ff451f7b84aaa12133f6405d54b95c5 + internal/provider/types/control_plane.go: + id: d969127f6dbc + last_write_checksum: sha1:ef459fb5dc22220ff666764fbc212dc732568a87 + pristine_git_object: 2044cb89a1065680879dead7d154103860fe1296 + internal/provider/types/control_plane_group.go: + id: 71c8a84322d4 + last_write_checksum: sha1:6de3df93c75d4543c80bef85eea28ede0749f421 + pristine_git_object: 9a9bdf51a55a20c2544c44857ddd14f70e1f217c internal/provider/types/control_plane_reference.go: id: d8f23088557b last_write_checksum: sha1:2c94e68c42d004aa409d23e61d216201d7a975ea @@ -1986,6 +2024,10 @@ trackedFiles: id: 1436cee260be last_write_checksum: sha1:9db5bf38539483d7b6dbff8c4c1dfaedbd9fa7ac pristine_git_object: 04f91dfcbf4487f4b1d3e14a4dbaf77674055896 + internal/provider/types/create_add_on_config.go: + id: 0956c96260c2 + last_write_checksum: sha1:149026c6b8e8177c05dedb770273ce59c3ed38e8 + pristine_git_object: 70f5a490f1c66b10c1d5a752d83d58a053d660b4 internal/provider/types/create_api_version_request_spec.go: id: c133e5763764 last_write_checksum: sha1:7f46f6c7bdb126c7da49ad185c137a1c0843f6f2 @@ -2298,6 +2340,26 @@ trackedFiles: id: 8828ea00f74f last_write_checksum: sha1:5d52c32afec3a6f25998e803ae97c278d730999f pristine_git_object: 593e78c989d1914ecefb160768bcb8d180ad0d34 + internal/provider/types/managed_cache.go: + id: a6f396600eb5 + last_write_checksum: sha1:66ccb3f488b535601d110daafb6b50022c4f1fe1 + pristine_git_object: a03170a5be0f2d9345443d2a548af1525b6e5087 + internal/provider/types/managed_cache_add_on_config_response.go: + id: b24ceab0be9f + last_write_checksum: sha1:7c0ee67e6ca99a9c5390271d999172ebadd3a217 + pristine_git_object: 0b931ce4d1d68cb03909e18933c21a5ae62f0cdd + internal/provider/types/managed_cache_add_on_config_response_state_metadata.go: + id: c622cfbcdc54 + last_write_checksum: sha1:482d63ac3c5c488c53ebdbab7b6c2846c8c2cd78 + pristine_git_object: 5716532dd38683be62d2d62954c5f2847691b719 + internal/provider/types/managed_cache_add_on_data_plane_group.go: + id: 453cc1fbed03 + last_write_checksum: sha1:114719d91f056e3fe3aa1949eff4692218a6dcbb + pristine_git_object: e70af38d7ec5250450ce0c6d10ecfce224b5c882 + internal/provider/types/managed_cache_capacity_config.go: + id: a6e75a849f6f + last_write_checksum: sha1:2a31f80652daa4355692786ff1f8d5b32a2d69ab + pristine_git_object: 5a499b7a58472edb04f196fb7e4d336cad47f420 internal/provider/types/match.go: id: 683334e1c79c last_write_checksum: sha1:578c4f37d0a26e8b241ea95b33239210e6c62191 @@ -3006,6 +3068,10 @@ trackedFiles: id: 3e579aaf6f65 last_write_checksum: sha1:9b448258bc5cea96117af31bd145f0eeb2a0eed6 pristine_git_object: 7b2a02e0884d65f06ae1f5e4c84e7134c3775d9b + internal/provider/types/state_metadata.go: + id: 35bf24b26a11 + last_write_checksum: sha1:ae38b34125e5b27b619ab659941c0f3a32ab7755 + pristine_git_object: a9b2d62967c3b07190cec01f164522d7762ad98c internal/provider/types/status.go: id: f7605ef7c692 last_write_checksum: sha1:c5588ab408e2333471bd28cc5d7db01eef62f950 @@ -3042,6 +3108,10 @@ trackedFiles: id: 4795f1f940b0 last_write_checksum: sha1:7694a7bb12d906d04cbc97dc8a044dafd4f17778 pristine_git_object: e102cfa34fa19f3d95e5d8dce08719e3fc78bee9 + internal/provider/types/tiered.go: + id: e2f864426e0f + last_write_checksum: sha1:94d1eb62b62247b48242c03e0e5197f3d7a19782 + pristine_git_object: 6db6615a5dcb38093beb749c61f938063fa95f6f internal/provider/types/tile.go: id: 418c7dafe589 last_write_checksum: sha1:5cfd17b13e62fdd959d0b9a92799ac850acc2f7d @@ -3266,6 +3336,10 @@ trackedFiles: id: ce7fc0b97fe5 last_write_checksum: sha1:9a83830618c21a7b58a2360627b2bf54693b842a pristine_git_object: a7dfad4eb0165984e6fdb6bb9a1e46c069b76938 + internal/sdk/cloudgateways.go: + id: 40b5a9f732b4 + last_write_checksum: sha1:257224ee14fe7224a5a4aa4042cb99baba7a0c58 + pristine_git_object: fc920873f991e98bfab770e12ebfbe0e734c8912 internal/sdk/dashboards.go: id: 067fe5157d4e last_write_checksum: sha1:df409dd9b2f5682fe95b61a4831194c1807e1a79 @@ -3392,8 +3466,8 @@ trackedFiles: pristine_git_object: 4f35c6b5ed8d47d0ac4a904f540a24b524cf2312 internal/sdk/konnectbeta.go: id: 34b8a82d72ce - last_write_checksum: sha1:29cc8a676372c410350c75450f3a26d678a831fd - pristine_git_object: 66fb987af9ceab82008ca007672e51ea3382a135 + last_write_checksum: sha1:bbcce2cf4000c390adc4f3c6241b37bc5ee07638 + pristine_git_object: 94178b0bc10d3a788c1ae1a81d4879faee7acadf internal/sdk/mesh.go: id: c3f36614baba last_write_checksum: sha1:d4d252274c8fdb4b44e64853e989ff6f90d1c306 @@ -3498,6 +3572,10 @@ trackedFiles: id: 19b5a8d3586b last_write_checksum: sha1:5d65fce5049df7c5113e11c9ccb1e4c46b91901c pristine_git_object: c633d568d96b5297c7d2edfc9d22fc717428edf1 + internal/sdk/models/operations/createaddon.go: + id: c72a244c1276 + last_write_checksum: sha1:4abc4c7b2d2bb9372a1b6cbe3960dcadbff38671 + pristine_git_object: a454cce15bbee7a1a00db61fc86fcadeb7d744e0 internal/sdk/models/operations/createapi.go: id: 86fb3550322c last_write_checksum: sha1:c700b90069b7b8c286b4cd53474053221e518bca @@ -3658,6 +3736,10 @@ trackedFiles: id: 20c3d23a7c26 last_write_checksum: sha1:9cf4a6b942946c2a53958ac868e807544ee19710 pristine_git_object: b23a22d9ac5dff0842505a12123eeb72971d8d1c + internal/sdk/models/operations/deleteaddon.go: + id: af0fda17f11c + last_write_checksum: sha1:d62fc1568123b4de1ab52b4f3cac91505165639c + pristine_git_object: 5d27212ee56d1b62e0931a8b3327e181e5fd3947 internal/sdk/models/operations/deleteapi.go: id: 452cbeb96903 last_write_checksum: sha1:768b616aa02b981e88cd172463dc4d3b59bbf94c @@ -3962,6 +4044,10 @@ trackedFiles: id: f6cb5b064588 last_write_checksum: sha1:183d7f4bb7b5cd7da2a71b0ff366e1aebc072bc6 pristine_git_object: 3002d10d6515dc695ba08c938dad2dde9daa34b3 + internal/sdk/models/operations/getaddon.go: + id: 443a3b973812 + last_write_checksum: sha1:9b8bb407948875219c833641c96a60860db6d55a + pristine_git_object: f23b3ef58120597d3320832f65eddaf2f112e304 internal/sdk/models/operations/getauthserver.go: id: 400b28b11c53 last_write_checksum: sha1:7cb7108b1e89e7c61fc494acd9a7b0bc360eb73c @@ -4666,6 +4752,22 @@ trackedFiles: id: da62ec1b3f49 last_write_checksum: sha1:393bef5c8d91c3efa1828b928be8452421c20cac pristine_git_object: 54572d20fa850f6810eb90dab3d044029078b261 + internal/sdk/models/shared/addonconfigresponse.go: + id: 0560eb7f8344 + last_write_checksum: sha1:551d838ffad063b06b086eb73f12efe2f98d8bbb + pristine_git_object: d26dbdc888fcc5aff0a6256bf02efc452215fd20 + internal/sdk/models/shared/addonowner.go: + id: b991f1b4a8d1 + last_write_checksum: sha1:0f7eba96fc75efa72a33d5781cbbdce27171844e + pristine_git_object: cc10378fa07f8fb94ad5d68017b7ce45a630e17d + internal/sdk/models/shared/addonresponse.go: + id: 6e37b239a1d8 + last_write_checksum: sha1:34ad85082666ebe3226af1c41ce1647e647b1521 + pristine_git_object: 0101efcfb7cefcb3c2712ea439bffce59ac9b069 + internal/sdk/models/shared/addonstate.go: + id: 9a1d6813ae10 + last_write_checksum: sha1:d26805fb19f6cb91a710b014d91020e092003d4f + pristine_git_object: 709a78766671214fa6cc2a56a20137c3679804ac internal/sdk/models/shared/advancedfilters.go: id: 8c3134ce6035 last_write_checksum: sha1:6bcba9ffc2f52681c56ab6765801c21c9caa05e5 @@ -4858,10 +4960,30 @@ trackedFiles: id: 3c6b183e36d1 last_write_checksum: sha1:e5ce6a9b7401ecb810e616ddfdf97bf24bce3460 pristine_git_object: a0e75796ce95ecdc27259201d5f282eeda3f82da + internal/sdk/models/shared/controlplane.go: + id: 08ebd7f2bc84 + last_write_checksum: sha1:2b348dcbb0b784217d1a44bb11b037519e23172b + pristine_git_object: e817e8cd59d045fe44cf63c7d84b0594f228d5e7 + internal/sdk/models/shared/controlplanegeo.go: + id: 20624856b343 + last_write_checksum: sha1:45e5e67b474bca6dd392b61ba9d60ccbf3059d94 + pristine_git_object: 4a915bcb788fb543ad51535da2ff1fe3aaa6f2bf + internal/sdk/models/shared/controlplanegroup.go: + id: b9de52ab2746 + last_write_checksum: sha1:67fd7ac559fc0d18e6ba86759da672567850b7b4 + pristine_git_object: 13305011c2006d2a7aa63990f9f751b7ea38c69e internal/sdk/models/shared/controlplanereference.go: id: 9ed677886294 last_write_checksum: sha1:2a3c8fd64e4c3b00db1d07a837da0c3bcf5933a4 pristine_git_object: 35d1508a08617299cfeb041e381444390fde117c + internal/sdk/models/shared/createaddonconfig.go: + id: 9aabf9160e9a + last_write_checksum: sha1:08c9e8bfc71c5e905bf932fc4008949dd531a8ba + pristine_git_object: 7ce2e655f049cfb3283106a5d60949ab3d8824e4 + internal/sdk/models/shared/createaddonrequest.go: + id: e3d22fbbc8e2 + last_write_checksum: sha1:7537f83eeaec9902b04bdf10910df7ff4831d47d + pristine_git_object: 71176eda1fc03b876833cbd26fba736f346901bf internal/sdk/models/shared/createapidocumentrequest.go: id: f153af110c47 last_write_checksum: sha1:907e0affff08cfee5640a90e80a92efa244acdea @@ -5234,6 +5356,22 @@ trackedFiles: id: 3c441bd3ba28 last_write_checksum: sha1:3d21dcb2c67fecf8c690a9aae8f8836cf33d276f pristine_git_object: c48d1dcd639823ea1e7507d0c4f5e20478492c0d + internal/sdk/models/shared/managedcache.go: + id: c101ffe5e176 + last_write_checksum: sha1:5d903595196003e20bdfb8369f9adbc1fad6c2b7 + pristine_git_object: 917076f19b54083a771c1c043baf0a9eb56f540f + internal/sdk/models/shared/managedcacheaddonconfigresponse.go: + id: 3f0809dc920e + last_write_checksum: sha1:747a8e1220c8610d6612ec6a18865055f6ba01e2 + pristine_git_object: 50316d1d4959e721dd476b8849e20324c242b95b + internal/sdk/models/shared/managedcacheaddondataplanegroup.go: + id: 09d36b2de0e0 + last_write_checksum: sha1:9122033c1bad6d11ef645490694ea6e307ed4104 + pristine_git_object: 24a1bf9963a5a192a62c9c2214c7dedb3098b93a + internal/sdk/models/shared/managedcachecapacityconfig.go: + id: cb979a4fee29 + last_write_checksum: sha1:495ff1d394afcdd3b59430ea633dbc429e6adab3 + pristine_git_object: 8ccc8cb2949f7b7e3540a4e1b5a9b9bb4b57bd72 internal/sdk/models/shared/meshaccesslogcreateorupdatesuccessresponse.go: id: a477d95b4444 last_write_checksum: sha1:7d644c08334362a3852beb862b78eb690754052b @@ -5548,8 +5686,8 @@ trackedFiles: pristine_git_object: 658d1ed463e8780cf409fb388b1e0c02fa7bbf0b internal/sdk/models/shared/meshserviceitem.go: id: 1be93bf94673 - last_write_checksum: sha1:dcc33ea9f6811cfda909ee5d83e0d180fd8d021b - pristine_git_object: f243bb8e61da975286931edf1fe671f62497b598 + last_write_checksum: sha1:f9dac9739842646d3d45669b8e5d34339cf99535 + pristine_git_object: 717aafea0b418045bd612291b2801fd640ee8f82 internal/sdk/models/shared/meshservicelist.go: id: fe3ec79ec681 last_write_checksum: sha1:54338d8daebcbd76bf0dbf9b30e421bb1ae32faa @@ -5762,6 +5900,10 @@ trackedFiles: id: e0ba07894c9d last_write_checksum: sha1:cf46dd291cd0fd86452bd99bb62bd4b65c6d0efc pristine_git_object: 7363dfde8526c6800198c4e670ed646db87a91c9 + internal/sdk/models/shared/providername.go: + id: a46a24e9a977 + last_write_checksum: sha1:4fb094d894f4c0b0c9857e4ca459d8ea81273f66 + pristine_git_object: 086626e78822c28d8457362c0548f289332e70b5 internal/sdk/models/shared/publishedstatus.go: id: 27bcee5f5492 last_write_checksum: sha1:0657bc7f739827d0e05d3b0236500052045a51bb @@ -5874,6 +6016,10 @@ trackedFiles: id: db684bad12fe last_write_checksum: sha1:570cae8984128ebcff2de68acf18da66c542d0ad pristine_git_object: 8aa7564682d562e5b68551b1dc039e903f32c8b7 + internal/sdk/models/shared/tiered.go: + id: 3ffc5b171939 + last_write_checksum: sha1:fe908cfcf6c1f1a302b96cd88485569b663b9aeb + pristine_git_object: 67ae9eec5f0302fc2e4f25ebadc548776632ce12 internal/sdk/models/shared/tile.go: id: 0243a3b4091d last_write_checksum: sha1:c7a2561d9b65f1d273f925cac79109c5b2fe2a18 @@ -12459,6 +12605,51 @@ examples: responses: "200": application/json: {} + create-add-on: + speakeasy-default-create-add-on: + requestBody: + application/json: {"name": "my-add-on", "owner": {"kind": "control-plane-group", "control_plane_group_id": "123e4567-e89b-12d3-a456-426614174000", "control_plane_group_geo": "sg"}, "config": {"kind": "managed-cache.v0", "capacity_config": {"kind": "tiered", "tier": "small"}}} + responses: + "201": + application/json: {"id": "550e8400-e29b-41d4-a716-446655440000", "name": "my-add-on", "owner": {"kind": "control-plane", "control_plane_id": "123e4567-e89b-12d3-a456-426614174000", "control_plane_geo": "me"}, "config": {"kind": "managed-cache.v0", "capacity_config": {"kind": "tiered", "tier": "small"}, "data_plane_groups": [], "state_metadata": {"cache_config_id": "edaf40f9-9fb0-4ffe-bb74-4e763a6bd471", "cache_server_name": "{vault://env/ADDON_MANAGED_CACHE_SERVER_NAME}", "cache_host": "{vault://env/ADDON_MANAGED_CACHE_HOST}", "cache_port": "{vault://env/ADDON_MANAGED_CACHE_PORT}", "cache_username": "{vault://env/ADDON_MANAGED_CACHE_USERNAME}", "cloud_authentication": null}}, "entity_version": 1, "state": "ready", "created_at": "2025-08-26T06:56:41Z", "updated_at": "2025-08-26T06:56:41Z"} + "400": + application/problem+json: {"status": 529641, "title": "", "instance": "", "detail": "", "invalid_parameters": [{"field": "name", "rule": "min_lowercase", "minimum": 8, "source": "body", "reason": "must have at least 8 characters"}]} + "401": + application/problem+json: {"status": 401, "title": "Unauthorized", "type": "https://httpstatuses.com/401", "instance": "kong:trace:1234567890", "detail": "Invalid credentials"} + "403": + application/problem+json: {"status": 403, "title": "Forbidden", "type": "https://httpstatuses.com/403", "instance": "kong:trace:1234567890", "detail": "Forbidden"} + "404": + application/problem+json: {"status": 404, "title": "Not Found", "type": "https://httpstatuses.com/404", "instance": "kong:trace:1234567890", "detail": "Not found"} + "409": + application/problem+json: {"status": 409, "title": "Conflict", "type": "https://httpstatuses.com/409", "instance": "kong:trace:1234567890", "detail": "Conflict"} + get-add-on: + speakeasy-default-get-add-on: + parameters: + path: + addOnId: "550e8400-e29b-41d4-a716-446655440000" + responses: + "200": + application/json: {"id": "550e8400-e29b-41d4-a716-446655440000", "name": "my-add-on", "owner": {"kind": "control-plane", "control_plane_id": "123e4567-e89b-12d3-a456-426614174000", "control_plane_geo": "eu"}, "config": {"kind": "managed-cache.v0", "capacity_config": {"kind": "tiered", "tier": "4xlarge"}, "data_plane_groups": [{"id": "1150820b-c69f-4a2a-b9be-bbcdbc5cd618", "cloud_gateway_network_id": "36ae63d3-efd1-4bec-b246-62aa5d3f5695", "provider": "aws", "region": "us-east-1", "state": "terminating", "state_metadata": {"error_reason": "Failed to create managed cache add-on due to invalid configuration.\n"}}], "state_metadata": {"cache_config_id": "edaf40f9-9fb0-4ffe-bb74-4e763a6bd471", "cache_server_name": "{vault://env/ADDON_MANAGED_CACHE_SERVER_NAME}", "cache_host": "{vault://env/ADDON_MANAGED_CACHE_HOST}", "cache_port": "{vault://env/ADDON_MANAGED_CACHE_PORT}", "cache_username": "{vault://env/ADDON_MANAGED_CACHE_USERNAME}", "cloud_authentication": null}}, "entity_version": 1, "state": "terminating", "created_at": "2025-08-26T06:56:41Z", "updated_at": "2025-08-26T06:56:41Z"} + "401": + application/problem+json: {"status": 401, "title": "Unauthorized", "type": "https://httpstatuses.com/401", "instance": "kong:trace:1234567890", "detail": "Invalid credentials"} + "403": + application/problem+json: {"status": 403, "title": "Forbidden", "type": "https://httpstatuses.com/403", "instance": "kong:trace:1234567890", "detail": "Forbidden"} + "404": + application/problem+json: {"status": 404, "title": "Not Found", "type": "https://httpstatuses.com/404", "instance": "kong:trace:1234567890", "detail": "Not found"} + delete-add-on: + speakeasy-default-delete-add-on: + parameters: + path: + addOnId: "550e8400-e29b-41d4-a716-446655440000" + responses: + "400": + application/problem+json: {"status": 799729, "title": "", "instance": "", "detail": "", "invalid_parameters": []} + "401": + application/problem+json: {"status": 401, "title": "Unauthorized", "type": "https://httpstatuses.com/401", "instance": "kong:trace:1234567890", "detail": "Invalid credentials"} + "403": + application/problem+json: {"status": 403, "title": "Forbidden", "type": "https://httpstatuses.com/403", "instance": "kong:trace:1234567890", "detail": "Forbidden"} + "404": + application/problem+json: {"status": 404, "title": "Not Found", "type": "https://httpstatuses.com/404", "instance": "kong:trace:1234567890", "detail": "Not found"} examplesVersion: 1.0.2 generatedTests: {} generatedFiles: diff --git a/docs/resources/cloud_gateway_add_on.md b/docs/resources/cloud_gateway_add_on.md new file mode 100644 index 00000000..3d5a7dc1 --- /dev/null +++ b/docs/resources/cloud_gateway_add_on.md @@ -0,0 +1,226 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "konnect_cloud_gateway_add_on Resource - terraform-provider-konnect-beta" +subcategory: "" +description: |- + CloudGatewayAddOn Resource +--- + +# konnect_cloud_gateway_add_on (Resource) + +CloudGatewayAddOn Resource + +## Example Usage + +```terraform +resource "konnect_cloud_gateway_add_on" "my_cloudgatewayaddon" { + provider = konnect-beta + config = { + managed_cache = { + capacity_config = { + tiered = { + tier = "micro" + } + } + } + } + name = "my-add-on" + owner = { + control_plane_group = { + control_plane_group_geo = "sg" + control_plane_group_id = "123e4567-e89b-12d3-a456-426614174000" + } + } +} +``` + + +## Schema + +### Required + +- `config` (Attributes) Configuration for creating different types of add-ons. Requires replacement if changed. (see [below for nested schema](#nestedatt--config)) +- `name` (String) Unique human-readable name of the add-on. Requires replacement if changed. +- `owner` (Attributes) Owner for the add-on. Requires replacement if changed. (see [below for nested schema](#nestedatt--owner)) + +### Read-Only + +- `created_at` (String) RFC-3339 timestamp representation of add-on creation date. +- `entity_version` (Number) Monotonically-increasing version count of the add-on, to indicate the order of updates to the add-on. +- `id` (String) The ID of this resource. +- `state` (String) The current state of the add-on. Possible values: +- `initializing` - The add-on is in the process of being initialized/updated. +- `ready` - The add-on is fully operational. +- `terminating` - The add-on is in the process of being deleted. +- `updated_at` (String) RFC-3339 timestamp representation of add-on update date. + + +### Nested Schema for `config` + +Optional: + +- `managed_cache` (Attributes) Configuration for creating a managed cache add-on. Requires replacement if changed. (see [below for nested schema](#nestedatt--config--managed_cache)) + +Read-Only: + +- `managed_cache_add_on_config_response` (Attributes) Configuration for managed cache add-on. (see [below for nested schema](#nestedatt--config--managed_cache_add_on_config_response)) + + +### Nested Schema for `config.managed_cache` + +Required: + +- `capacity_config` (Attributes) Configuration for managed cache capacity and performance characteristics. Requires replacement if changed. (see [below for nested schema](#nestedatt--config--managed_cache--capacity_config)) + + +### Nested Schema for `config.managed_cache.capacity_config` + +Optional: + +- `tiered` (Attributes) Capacity tiers with pre-configured size and performance characteristics. Requires replacement if changed. (see [below for nested schema](#nestedatt--config--managed_cache--capacity_config--tiered)) + + +### Nested Schema for `config.managed_cache.capacity_config.tiered` + +Required: + +- `tier` (String) Capacity tier that determines both cache size and performance characteristics: +- micro: ~0.5 GiB capacity +- small: ~1 GiB capacity +- medium: ~3 GiB capacity +- large: ~6 GiB capacity +- xlarge: ~12 GiB capacity +- 2xlarge: ~25 GiB capacity +- 4xlarge: ~52 GiB capacity +must be one of ["micro", "small", "medium", "large", "xlarge", "2xlarge", "4xlarge"]; Requires replacement if changed. + + + + + +### Nested Schema for `config.managed_cache_add_on_config_response` + +Read-Only: + +- `capacity_config` (Attributes) Configuration for managed cache capacity and performance characteristics. (see [below for nested schema](#nestedatt--config--managed_cache_add_on_config_response--capacity_config)) +- `data_plane_groups` (Attributes List) List of data-plane groups where the managed cache is deployed. (see [below for nested schema](#nestedatt--config--managed_cache_add_on_config_response--data_plane_groups)) +- `state_metadata` (Attributes) Metadata describing the state of the managed cache add-on. (see [below for nested schema](#nestedatt--config--managed_cache_add_on_config_response--state_metadata)) + + +### Nested Schema for `config.managed_cache_add_on_config_response.capacity_config` + +Read-Only: + +- `tiered` (Attributes) Capacity tiers with pre-configured size and performance characteristics. (see [below for nested schema](#nestedatt--config--managed_cache_add_on_config_response--capacity_config--tiered)) + + +### Nested Schema for `config.managed_cache_add_on_config_response.capacity_config.tiered` + +Read-Only: + +- `tier` (String) Capacity tier that determines both cache size and performance characteristics: +- micro: ~0.5 GiB capacity +- small: ~1 GiB capacity +- medium: ~3 GiB capacity +- large: ~6 GiB capacity +- xlarge: ~12 GiB capacity +- 2xlarge: ~25 GiB capacity +- 4xlarge: ~52 GiB capacity + + + + +### Nested Schema for `config.managed_cache_add_on_config_response.data_plane_groups` + +Read-Only: + +- `cloud_gateway_network_id` (String) Network ID this data-plane group is attached to. +- `id` (String) ID of the data-plane group. +- `provider` (String) Name of cloud provider. +- `region` (String) Region of cloud provider the data-plane group is deployed to. +- `state` (String) The current state of the managed cache add-on in the data-plane group. Possible values: +- `initializing` - The add-on is in the process of being initialized/updated and is setting up necessary resources for this data-plane group. +- `ready` - The add-on is fully operational for this data-plane group. +- `error` - The add-on is in an error state, and is not operational for this data-plane group. +- `terminating` - The add-on is in the process of being deleted for this data-plane group. +- `state_metadata` (Attributes) Metadata describing the state of the managed cache add-on in the data-plane group. (see [below for nested schema](#nestedatt--config--managed_cache_add_on_config_response--data_plane_groups--state_metadata)) + + +### Nested Schema for `config.managed_cache_add_on_config_response.data_plane_groups.state_metadata` + +Read-Only: + +- `error_reason` (String) Reason why the managed cache add-on may be in an error state, reported from backing infrastructure. + + + + +### Nested Schema for `config.managed_cache_add_on_config_response.state_metadata` + +Read-Only: + +- `cache_config_id` (String) Reference to cache configuration for this add-on. +- `cache_host` (String) Env vault path to cache hostname. +- `cache_port` (String) Env vault path to cache port. +- `cache_server_name` (String) Env vault path to cache server name. +- `cache_username` (String) Env vault path to cache username. +- `cloud_authentication` (Attributes) Metadata describing the cloud authentication details for managed cache add-on. (see [below for nested schema](#nestedatt--config--managed_cache_add_on_config_response--state_metadata--cloud_authentication)) + + +### Nested Schema for `config.managed_cache_add_on_config_response.state_metadata.cloud_authentication` + +Read-Only: + +- `auth_provider` (String) Env vault path to cache auth provider. +- `aws_assume_role_arn` (String) Env vault path to aws assume role arn. +- `aws_cache_name` (String) Env vault path to aws cache name. +- `aws_region` (String) Env vault path to aws region. +- `azure_tenant_id` (String) Env vault path to azure tenant id. + + + + + + +### Nested Schema for `owner` + +Optional: + +- `control_plane` (Attributes) Control Plane is the owner for the add-on. Requires replacement if changed. (see [below for nested schema](#nestedatt--owner--control_plane)) +- `control_plane_group` (Attributes) Control Plane Group is the owner for the add-on. Requires replacement if changed. (see [below for nested schema](#nestedatt--owner--control_plane_group)) + + +### Nested Schema for `owner.control_plane` + +Optional: + +- `control_plane_geo` (String) Set of control-plane geos supported for deploying cloud-gateways configurations. Not Null; must be one of ["us", "eu", "au", "me", "in", "sg"]; Requires replacement if changed. +- `control_plane_id` (String) ID of the control-plane that owns this add-on. Not Null; Requires replacement if changed. + + + +### Nested Schema for `owner.control_plane_group` + +Optional: + +- `control_plane_group_geo` (String) Set of control-plane geos supported for deploying cloud-gateways configurations. Not Null; must be one of ["us", "eu", "au", "me", "in", "sg"]; Requires replacement if changed. +- `control_plane_group_id` (String) ID of the control-plane group that owns this add-on. Not Null; Requires replacement if changed. + +## Import + +Import is supported using the following syntax: + +In Terraform v1.5.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `id` attribute, for example: + +```terraform +import { + to = konnect_cloud_gateway_add_on.my_konnect_cloud_gateway_add_on + id = "550e8400-e29b-41d4-a716-446655440000" +} +``` + +The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: + +```shell +terraform import konnect_cloud_gateway_add_on.my_konnect_cloud_gateway_add_on "550e8400-e29b-41d4-a716-446655440000" +``` diff --git a/examples/resources/konnect_cloud_gateway_add_on/import-by-string-id.tf b/examples/resources/konnect_cloud_gateway_add_on/import-by-string-id.tf new file mode 100644 index 00000000..ef0f82ed --- /dev/null +++ b/examples/resources/konnect_cloud_gateway_add_on/import-by-string-id.tf @@ -0,0 +1,5 @@ +import { + provider = konnect-beta + to = konnect_cloud_gateway_add_on.my_konnect-beta_cloud_gateway_add_on + id = "550e8400-e29b-41d4-a716-446655440000" +} diff --git a/examples/resources/konnect_cloud_gateway_add_on/import.sh b/examples/resources/konnect_cloud_gateway_add_on/import.sh new file mode 100644 index 00000000..b3484346 --- /dev/null +++ b/examples/resources/konnect_cloud_gateway_add_on/import.sh @@ -0,0 +1 @@ +terraform import konnect_cloud_gateway_add_on.my_konnect_cloud_gateway_add_on "550e8400-e29b-41d4-a716-446655440000" diff --git a/examples/resources/konnect_cloud_gateway_add_on/resource.tf b/examples/resources/konnect_cloud_gateway_add_on/resource.tf new file mode 100644 index 00000000..6cd3d2e4 --- /dev/null +++ b/examples/resources/konnect_cloud_gateway_add_on/resource.tf @@ -0,0 +1,19 @@ +resource "konnect_cloud_gateway_add_on" "my_cloudgatewayaddon" { + provider = konnect-beta + config = { + managed_cache = { + capacity_config = { + tiered = { + tier = "micro" + } + } + } + } + name = "my-add-on" + owner = { + control_plane_group = { + control_plane_group_geo = "sg" + control_plane_group_id = "123e4567-e89b-12d3-a456-426614174000" + } + } +} \ No newline at end of file diff --git a/internal/provider/cloudgatewayaddon_resource.go b/internal/provider/cloudgatewayaddon_resource.go new file mode 100644 index 00000000..776e236e --- /dev/null +++ b/internal/provider/cloudgatewayaddon_resource.go @@ -0,0 +1,627 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package provider + +import ( + "context" + "fmt" + "github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + speakeasy_int64planmodifier "github.com/kong/terraform-provider-konnect-beta/internal/planmodifiers/int64planmodifier" + speakeasy_objectplanmodifier "github.com/kong/terraform-provider-konnect-beta/internal/planmodifiers/objectplanmodifier" + speakeasy_stringplanmodifier "github.com/kong/terraform-provider-konnect-beta/internal/planmodifiers/stringplanmodifier" + tfTypes "github.com/kong/terraform-provider-konnect-beta/internal/provider/types" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk" + speakeasy_stringvalidators "github.com/kong/terraform-provider-konnect-beta/internal/validators/stringvalidators" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &CloudGatewayAddOnResource{} +var _ resource.ResourceWithImportState = &CloudGatewayAddOnResource{} + +func NewCloudGatewayAddOnResource() resource.Resource { + return &CloudGatewayAddOnResource{} +} + +// CloudGatewayAddOnResource defines the resource implementation. +type CloudGatewayAddOnResource struct { + // Provider configured SDK client. + client *sdk.KonnectBeta +} + +// CloudGatewayAddOnResourceModel describes the resource data model. +type CloudGatewayAddOnResourceModel struct { + Config *tfTypes.CreateAddOnConfig `tfsdk:"config"` + CreatedAt types.String `tfsdk:"created_at"` + EntityVersion types.Int64 `tfsdk:"entity_version"` + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + Owner *tfTypes.AddOnOwner `tfsdk:"owner"` + State types.String `tfsdk:"state"` + UpdatedAt types.String `tfsdk:"updated_at"` +} + +func (r *CloudGatewayAddOnResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = "konnect_cloud_gateway_add_on" +} + +func (r *CloudGatewayAddOnResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: "CloudGatewayAddOn Resource", + Attributes: map[string]schema.Attribute{ + "config": schema.SingleNestedAttribute{ + Required: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), + }, + Attributes: map[string]schema.Attribute{ + "managed_cache": schema.SingleNestedAttribute{ + Optional: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.RequiresReplaceIfConfigured(), + }, + Attributes: map[string]schema.Attribute{ + "capacity_config": schema.SingleNestedAttribute{ + Required: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.RequiresReplaceIfConfigured(), + }, + Attributes: map[string]schema.Attribute{ + "tiered": schema.SingleNestedAttribute{ + Optional: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.RequiresReplaceIfConfigured(), + }, + Attributes: map[string]schema.Attribute{ + "tier": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + }, + MarkdownDescription: `Capacity tier that determines both cache size and performance characteristics:` + "\n" + + `- micro: ~0.5 GiB capacity` + "\n" + + `- small: ~1 GiB capacity` + "\n" + + `- medium: ~3 GiB capacity` + "\n" + + `- large: ~6 GiB capacity` + "\n" + + `- xlarge: ~12 GiB capacity` + "\n" + + `- 2xlarge: ~25 GiB capacity` + "\n" + + `- 4xlarge: ~52 GiB capacity` + "\n" + + `must be one of ["micro", "small", "medium", "large", "xlarge", "2xlarge", "4xlarge"]; Requires replacement if changed.`, + Validators: []validator.String{ + stringvalidator.OneOf( + "micro", + "small", + "medium", + "large", + "xlarge", + "2xlarge", + "4xlarge", + ), + }, + }, + }, + Description: `Capacity tiers with pre-configured size and performance characteristics. Requires replacement if changed.`, + }, + }, + Description: `Configuration for managed cache capacity and performance characteristics. Requires replacement if changed.`, + }, + }, + Description: `Configuration for creating a managed cache add-on. Requires replacement if changed.`, + Validators: []validator.Object{ + objectvalidator.ConflictsWith(path.Expressions{ + path.MatchRelative().AtParent().AtName("managed_cache_add_on_config_response"), + }...), + }, + }, + "managed_cache_add_on_config_response": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "capacity_config": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "tiered": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "tier": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Capacity tier that determines both cache size and performance characteristics:` + "\n" + + `- micro: ~0.5 GiB capacity` + "\n" + + `- small: ~1 GiB capacity` + "\n" + + `- medium: ~3 GiB capacity` + "\n" + + `- large: ~6 GiB capacity` + "\n" + + `- xlarge: ~12 GiB capacity` + "\n" + + `- 2xlarge: ~25 GiB capacity` + "\n" + + `- 4xlarge: ~52 GiB capacity`, + }, + }, + Description: `Capacity tiers with pre-configured size and performance characteristics.`, + }, + }, + Description: `Configuration for managed cache capacity and performance characteristics.`, + }, + "data_plane_groups": schema.ListNestedAttribute{ + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "cloud_gateway_network_id": schema.StringAttribute{ + Computed: true, + Description: `Network ID this data-plane group is attached to.`, + }, + "id": schema.StringAttribute{ + Computed: true, + Description: `ID of the data-plane group.`, + }, + "provider": schema.StringAttribute{ + Computed: true, + Description: `Name of cloud provider.`, + }, + "region": schema.StringAttribute{ + Computed: true, + Description: `Region of cloud provider the data-plane group is deployed to.`, + }, + "state": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + MarkdownDescription: `The current state of the managed cache add-on in the data-plane group. Possible values:` + "\n" + + `- ` + "`" + `initializing` + "`" + ` - The add-on is in the process of being initialized/updated and is setting up necessary resources for this data-plane group.` + "\n" + + `- ` + "`" + `ready` + "`" + ` - The add-on is fully operational for this data-plane group.` + "\n" + + `- ` + "`" + `error` + "`" + ` - The add-on is in an error state, and is not operational for this data-plane group.` + "\n" + + `- ` + "`" + `terminating` + "`" + ` - The add-on is in the process of being deleted for this data-plane group.`, + }, + "state_metadata": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "error_reason": schema.StringAttribute{ + Computed: true, + Description: `Reason why the managed cache add-on may be in an error state, reported from backing infrastructure.`, + }, + }, + Description: `Metadata describing the state of the managed cache add-on in the data-plane group.`, + }, + }, + }, + Description: `List of data-plane groups where the managed cache is deployed.`, + }, + "state_metadata": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "cache_config_id": schema.StringAttribute{ + Computed: true, + Description: `Reference to cache configuration for this add-on.`, + }, + "cache_host": schema.StringAttribute{ + Computed: true, + Description: `Env vault path to cache hostname.`, + }, + "cache_port": schema.StringAttribute{ + Computed: true, + Description: `Env vault path to cache port.`, + }, + "cache_server_name": schema.StringAttribute{ + Computed: true, + Description: `Env vault path to cache server name.`, + }, + "cache_username": schema.StringAttribute{ + Computed: true, + Description: `Env vault path to cache username.`, + }, + "cloud_authentication": schema.SingleNestedAttribute{ + Computed: true, + Default: objectdefault.StaticValue(types.ObjectNull(map[string]attr.Type{ + "auth_provider": types.StringType, + "aws_assume_role_arn": types.StringType, + "aws_cache_name": types.StringType, + "aws_region": types.StringType, + "azure_tenant_id": types.StringType, + })), + Attributes: map[string]schema.Attribute{ + "auth_provider": schema.StringAttribute{ + Computed: true, + Description: `Env vault path to cache auth provider.`, + }, + "aws_assume_role_arn": schema.StringAttribute{ + Computed: true, + Description: `Env vault path to aws assume role arn.`, + }, + "aws_cache_name": schema.StringAttribute{ + Computed: true, + Description: `Env vault path to aws cache name.`, + }, + "aws_region": schema.StringAttribute{ + Computed: true, + Description: `Env vault path to aws region.`, + }, + "azure_tenant_id": schema.StringAttribute{ + Computed: true, + Description: `Env vault path to azure tenant id.`, + }, + }, + Description: `Metadata describing the cloud authentication details for managed cache add-on.`, + }, + }, + Description: `Metadata describing the state of the managed cache add-on.`, + }, + }, + Description: `Configuration for managed cache add-on.`, + }, + }, + Description: `Configuration for creating different types of add-ons. Requires replacement if changed.`, + }, + "created_at": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + Description: `RFC-3339 timestamp representation of add-on creation date.`, + }, + "entity_version": schema.Int64Attribute{ + Computed: true, + PlanModifiers: []planmodifier.Int64{ + speakeasy_int64planmodifier.SuppressDiff(speakeasy_int64planmodifier.ExplicitSuppress), + }, + Description: `Monotonically-increasing version count of the add-on, to indicate the order of updates to the add-on.`, + }, + "id": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + Description: `Unique human-readable name of the add-on. Requires replacement if changed.`, + Validators: []validator.String{ + stringvalidator.UTF8LengthBetween(1, 70), + }, + }, + "owner": schema.SingleNestedAttribute{ + Required: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), + }, + Attributes: map[string]schema.Attribute{ + "control_plane": schema.SingleNestedAttribute{ + Optional: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.RequiresReplaceIfConfigured(), + }, + Attributes: map[string]schema.Attribute{ + "control_plane_geo": schema.StringAttribute{ + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + }, + Description: `Set of control-plane geos supported for deploying cloud-gateways configurations. Not Null; must be one of ["us", "eu", "au", "me", "in", "sg"]; Requires replacement if changed.`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + stringvalidator.OneOf( + "us", + "eu", + "au", + "me", + "in", + "sg", + ), + }, + }, + "control_plane_id": schema.StringAttribute{ + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + }, + Description: `ID of the control-plane that owns this add-on. Not Null; Requires replacement if changed.`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, + }, + }, + Description: `Control Plane is the owner for the add-on. Requires replacement if changed.`, + Validators: []validator.Object{ + objectvalidator.ConflictsWith(path.Expressions{ + path.MatchRelative().AtParent().AtName("control_plane_group"), + }...), + }, + }, + "control_plane_group": schema.SingleNestedAttribute{ + Optional: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.RequiresReplaceIfConfigured(), + }, + Attributes: map[string]schema.Attribute{ + "control_plane_group_geo": schema.StringAttribute{ + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + }, + Description: `Set of control-plane geos supported for deploying cloud-gateways configurations. Not Null; must be one of ["us", "eu", "au", "me", "in", "sg"]; Requires replacement if changed.`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + stringvalidator.OneOf( + "us", + "eu", + "au", + "me", + "in", + "sg", + ), + }, + }, + "control_plane_group_id": schema.StringAttribute{ + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + }, + Description: `ID of the control-plane group that owns this add-on. Not Null; Requires replacement if changed.`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, + }, + }, + Description: `Control Plane Group is the owner for the add-on. Requires replacement if changed.`, + Validators: []validator.Object{ + objectvalidator.ConflictsWith(path.Expressions{ + path.MatchRelative().AtParent().AtName("control_plane"), + }...), + }, + }, + }, + Description: `Owner for the add-on. Requires replacement if changed.`, + }, + "state": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + MarkdownDescription: `The current state of the add-on. Possible values:` + "\n" + + `- ` + "`" + `initializing` + "`" + ` - The add-on is in the process of being initialized/updated.` + "\n" + + `- ` + "`" + `ready` + "`" + ` - The add-on is fully operational.` + "\n" + + `- ` + "`" + `terminating` + "`" + ` - The add-on is in the process of being deleted.`, + }, + "updated_at": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + Description: `RFC-3339 timestamp representation of add-on update date.`, + }, + }, + } +} + +func (r *CloudGatewayAddOnResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*sdk.KonnectBeta) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected *sdk.KonnectBeta, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client +} + +func (r *CloudGatewayAddOnResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var data *CloudGatewayAddOnResourceModel + var plan types.Object + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + })...) + + if resp.Diagnostics.HasError() { + return + } + + request, requestDiags := data.ToSharedCreateAddOnRequest(ctx) + resp.Diagnostics.Append(requestDiags...) + + if resp.Diagnostics.HasError() { + return + } + res, err := r.client.CloudGateways.CreateAddOn(ctx, *request) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } + return + } + if res == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) + return + } + if res.StatusCode == 409 { + resp.Diagnostics.AddError( + "Resource Already Exists", + "When creating this resource, the API indicated that this resource already exists. You can bring the existing resource under management using Terraform import functionality or retry with a unique configuration.", + ) + return + } + if res.StatusCode != 201 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) + return + } + if !(res.AddOnResponse != nil) { + resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) + return + } + resp.Diagnostics.Append(data.RefreshFromSharedAddOnResponse(ctx, res.AddOnResponse)...) + + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + // Save updated data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (r *CloudGatewayAddOnResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var data *CloudGatewayAddOnResourceModel + var item types.Object + + resp.Diagnostics.Append(req.State.Get(ctx, &item)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + })...) + + if resp.Diagnostics.HasError() { + return + } + + request, requestDiags := data.ToOperationsGetAddOnRequest(ctx) + resp.Diagnostics.Append(requestDiags...) + + if resp.Diagnostics.HasError() { + return + } + res, err := r.client.CloudGateways.GetAddOn(ctx, *request) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } + return + } + if res == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) + return + } + if res.StatusCode == 404 { + resp.State.RemoveResource(ctx) + return + } + if res.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) + return + } + if !(res.AddOnResponse != nil) { + resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) + return + } + resp.Diagnostics.Append(data.RefreshFromSharedAddOnResponse(ctx, res.AddOnResponse)...) + + if resp.Diagnostics.HasError() { + return + } + + // Save updated data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (r *CloudGatewayAddOnResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var data *CloudGatewayAddOnResourceModel + var plan types.Object + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + merge(ctx, req, resp, &data) + if resp.Diagnostics.HasError() { + return + } + + // Not Implemented; all attributes marked as RequiresReplace + + // Save updated data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (r *CloudGatewayAddOnResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var data *CloudGatewayAddOnResourceModel + var item types.Object + + resp.Diagnostics.Append(req.State.Get(ctx, &item)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + })...) + + if resp.Diagnostics.HasError() { + return + } + + request, requestDiags := data.ToOperationsDeleteAddOnRequest(ctx) + resp.Diagnostics.Append(requestDiags...) + + if resp.Diagnostics.HasError() { + return + } + res, err := r.client.CloudGateways.DeleteAddOn(ctx, *request) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } + return + } + if res == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) + return + } + switch res.StatusCode { + case 204, 404: + break + default: + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) + return + } + +} + +func (r *CloudGatewayAddOnResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), req.ID)...) +} diff --git a/internal/provider/cloudgatewayaddon_resource_sdk.go b/internal/provider/cloudgatewayaddon_resource_sdk.go new file mode 100644 index 00000000..5b90e289 --- /dev/null +++ b/internal/provider/cloudgatewayaddon_resource_sdk.go @@ -0,0 +1,184 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package provider + +import ( + "context" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/kong/terraform-provider-konnect-beta/internal/provider/typeconvert" + tfTypes "github.com/kong/terraform-provider-konnect-beta/internal/provider/types" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/models/operations" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/models/shared" +) + +func (r *CloudGatewayAddOnResourceModel) RefreshFromSharedAddOnResponse(ctx context.Context, resp *shared.AddOnResponse) diag.Diagnostics { + var diags diag.Diagnostics + + if resp != nil { + if r.Config == nil { + r.Config = &tfTypes.CreateAddOnConfig{} + } + if resp.Config.ManagedCacheAddOnConfigResponse != nil { + r.Config.ManagedCacheAddOnConfigResponse = &tfTypes.ManagedCacheAddOnConfigResponse{} + if r.Config.ManagedCacheAddOnConfigResponse.CapacityConfig == nil { + r.Config.ManagedCacheAddOnConfigResponse.CapacityConfig = &tfTypes.ManagedCacheCapacityConfig{} + } + if resp.Config.ManagedCacheAddOnConfigResponse.CapacityConfig.Tiered != nil { + r.Config.ManagedCacheAddOnConfigResponse.CapacityConfig.Tiered = &tfTypes.Tiered{} + r.Config.ManagedCacheAddOnConfigResponse.CapacityConfig.Tiered.Tier = types.StringValue(string(resp.Config.ManagedCacheAddOnConfigResponse.CapacityConfig.Tiered.Tier)) + } + r.Config.ManagedCacheAddOnConfigResponse.DataPlaneGroups = []tfTypes.ManagedCacheAddOnDataPlaneGroup{} + + for _, dataPlaneGroupsItem := range resp.Config.ManagedCacheAddOnConfigResponse.DataPlaneGroups { + var dataPlaneGroups tfTypes.ManagedCacheAddOnDataPlaneGroup + + dataPlaneGroups.CloudGatewayNetworkID = types.StringValue(dataPlaneGroupsItem.CloudGatewayNetworkID) + dataPlaneGroups.ID = types.StringValue(dataPlaneGroupsItem.ID) + dataPlaneGroups.Provider = types.StringValue(string(dataPlaneGroupsItem.Provider)) + dataPlaneGroups.Region = types.StringValue(dataPlaneGroupsItem.Region) + dataPlaneGroups.State = types.StringValue(string(dataPlaneGroupsItem.State)) + dataPlaneGroups.StateMetadata = &tfTypes.StateMetadata{} + dataPlaneGroups.StateMetadata.ErrorReason = types.StringPointerValue(dataPlaneGroupsItem.StateMetadata.ErrorReason) + + r.Config.ManagedCacheAddOnConfigResponse.DataPlaneGroups = append(r.Config.ManagedCacheAddOnConfigResponse.DataPlaneGroups, dataPlaneGroups) + } + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata = &tfTypes.ManagedCacheAddOnConfigResponseStateMetadata{} + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CacheConfigID = types.StringPointerValue(resp.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CacheConfigID) + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CacheHost = types.StringPointerValue(resp.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CacheHost) + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CachePort = types.StringPointerValue(resp.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CachePort) + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CacheServerName = types.StringPointerValue(resp.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CacheServerName) + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CacheUsername = types.StringPointerValue(resp.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CacheUsername) + if resp.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication == nil { + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication = nil + } else { + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication = &tfTypes.CloudAuthentication{} + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication.AuthProvider = types.StringPointerValue(resp.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication.AuthProvider) + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication.AwsAssumeRoleArn = types.StringPointerValue(resp.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication.AwsAssumeRoleArn) + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication.AwsCacheName = types.StringPointerValue(resp.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication.AwsCacheName) + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication.AwsRegion = types.StringPointerValue(resp.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication.AwsRegion) + r.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication.AzureTenantID = types.StringPointerValue(resp.Config.ManagedCacheAddOnConfigResponse.StateMetadata.CloudAuthentication.AzureTenantID) + } + } + r.CreatedAt = types.StringValue(typeconvert.TimeToString(resp.CreatedAt)) + r.EntityVersion = types.Int64Value(resp.EntityVersion) + r.ID = types.StringValue(resp.ID) + r.Name = types.StringValue(resp.Name) + if r.Owner == nil { + r.Owner = &tfTypes.AddOnOwner{} + } + if resp.Owner.ControlPlane != nil { + r.Owner.ControlPlane = &tfTypes.ControlPlane{} + r.Owner.ControlPlane.ControlPlaneGeo = types.StringValue(string(resp.Owner.ControlPlane.ControlPlaneGeo)) + r.Owner.ControlPlane.ControlPlaneID = types.StringValue(resp.Owner.ControlPlane.ControlPlaneID) + } + if resp.Owner.ControlPlaneGroup != nil { + r.Owner.ControlPlaneGroup = &tfTypes.ControlPlaneGroup{} + r.Owner.ControlPlaneGroup.ControlPlaneGroupGeo = types.StringValue(string(resp.Owner.ControlPlaneGroup.ControlPlaneGroupGeo)) + r.Owner.ControlPlaneGroup.ControlPlaneGroupID = types.StringValue(resp.Owner.ControlPlaneGroup.ControlPlaneGroupID) + } + r.State = types.StringValue(string(resp.State)) + r.UpdatedAt = types.StringValue(typeconvert.TimeToString(resp.UpdatedAt)) + } + + return diags +} + +func (r *CloudGatewayAddOnResourceModel) ToOperationsDeleteAddOnRequest(ctx context.Context) (*operations.DeleteAddOnRequest, diag.Diagnostics) { + var diags diag.Diagnostics + + var addOnID string + addOnID = r.ID.ValueString() + + out := operations.DeleteAddOnRequest{ + AddOnID: addOnID, + } + + return &out, diags +} + +func (r *CloudGatewayAddOnResourceModel) ToOperationsGetAddOnRequest(ctx context.Context) (*operations.GetAddOnRequest, diag.Diagnostics) { + var diags diag.Diagnostics + + var addOnID string + addOnID = r.ID.ValueString() + + out := operations.GetAddOnRequest{ + AddOnID: addOnID, + } + + return &out, diags +} + +func (r *CloudGatewayAddOnResourceModel) ToSharedCreateAddOnRequest(ctx context.Context) (*shared.CreateAddOnRequest, diag.Diagnostics) { + var diags diag.Diagnostics + + var name string + name = r.Name.ValueString() + + var owner shared.AddOnOwner + var controlPlane *shared.ControlPlane + if r.Owner.ControlPlane != nil { + var controlPlaneID string + controlPlaneID = r.Owner.ControlPlane.ControlPlaneID.ValueString() + + controlPlaneGeo := shared.ControlPlaneGeo(r.Owner.ControlPlane.ControlPlaneGeo.ValueString()) + controlPlane = &shared.ControlPlane{ + ControlPlaneID: controlPlaneID, + ControlPlaneGeo: controlPlaneGeo, + } + } + if controlPlane != nil { + owner = shared.AddOnOwner{ + ControlPlane: controlPlane, + } + } + var controlPlaneGroup *shared.ControlPlaneGroup + if r.Owner.ControlPlaneGroup != nil { + var controlPlaneGroupID string + controlPlaneGroupID = r.Owner.ControlPlaneGroup.ControlPlaneGroupID.ValueString() + + controlPlaneGroupGeo := shared.ControlPlaneGeo(r.Owner.ControlPlaneGroup.ControlPlaneGroupGeo.ValueString()) + controlPlaneGroup = &shared.ControlPlaneGroup{ + ControlPlaneGroupID: controlPlaneGroupID, + ControlPlaneGroupGeo: controlPlaneGroupGeo, + } + } + if controlPlaneGroup != nil { + owner = shared.AddOnOwner{ + ControlPlaneGroup: controlPlaneGroup, + } + } + var config shared.CreateAddOnConfig + var managedCache *shared.ManagedCache + if r.Config.ManagedCache != nil { + var capacityConfig shared.ManagedCacheCapacityConfig + var tiered *shared.Tiered + if r.Config.ManagedCache.CapacityConfig.Tiered != nil { + tier := shared.Tier(r.Config.ManagedCache.CapacityConfig.Tiered.Tier.ValueString()) + tiered = &shared.Tiered{ + Tier: tier, + } + } + if tiered != nil { + capacityConfig = shared.ManagedCacheCapacityConfig{ + Tiered: tiered, + } + } + managedCache = &shared.ManagedCache{ + CapacityConfig: capacityConfig, + } + } + if managedCache != nil { + config = shared.CreateAddOnConfig{ + ManagedCache: managedCache, + } + } + out := shared.CreateAddOnRequest{ + Name: name, + Owner: owner, + Config: config, + } + + return &out, diags +} diff --git a/internal/provider/meshservice_resource_sdk.go b/internal/provider/meshservice_resource_sdk.go index 555ef2aa..cf8203ee 100644 --- a/internal/provider/meshservice_resource_sdk.go +++ b/internal/provider/meshservice_resource_sdk.go @@ -368,9 +368,9 @@ func (r *MeshServiceResourceModel) ToSharedMeshServiceItemInput(ctx context.Cont DataplaneTags: dataplaneTags, } } - state := new(shared.State) + state := new(shared.MeshServiceItemState) if !r.Spec.State.IsUnknown() && !r.Spec.State.IsNull() { - *state = shared.State(r.Spec.State.ValueString()) + *state = shared.MeshServiceItemState(r.Spec.State.ValueString()) } else { state = nil } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 78121d31..e1340ab0 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -163,6 +163,7 @@ func (p *KonnectBetaProvider) Resources(ctx context.Context) []func() resource.R NewAuthServerClaimsResource, NewAuthServerClientsResource, NewAuthServerScopesResource, + NewCloudGatewayAddOnResource, NewDashboardResource, NewEventGatewayResource, NewEventGatewayBackendClusterResource, diff --git a/internal/provider/types/add_on_owner.go b/internal/provider/types/add_on_owner.go new file mode 100644 index 00000000..9f236a3b --- /dev/null +++ b/internal/provider/types/add_on_owner.go @@ -0,0 +1,8 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +type AddOnOwner struct { + ControlPlane *ControlPlane `queryParam:"inline" tfsdk:"control_plane"` + ControlPlaneGroup *ControlPlaneGroup `queryParam:"inline" tfsdk:"control_plane_group"` +} diff --git a/internal/provider/types/cloud_authentication.go b/internal/provider/types/cloud_authentication.go new file mode 100644 index 00000000..e51ccdee --- /dev/null +++ b/internal/provider/types/cloud_authentication.go @@ -0,0 +1,15 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "github.com/hashicorp/terraform-plugin-framework/types" +) + +type CloudAuthentication struct { + AuthProvider types.String `tfsdk:"auth_provider"` + AwsAssumeRoleArn types.String `tfsdk:"aws_assume_role_arn"` + AwsCacheName types.String `tfsdk:"aws_cache_name"` + AwsRegion types.String `tfsdk:"aws_region"` + AzureTenantID types.String `tfsdk:"azure_tenant_id"` +} diff --git a/internal/provider/types/control_plane.go b/internal/provider/types/control_plane.go new file mode 100644 index 00000000..2044cb89 --- /dev/null +++ b/internal/provider/types/control_plane.go @@ -0,0 +1,12 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "github.com/hashicorp/terraform-plugin-framework/types" +) + +type ControlPlane struct { + ControlPlaneGeo types.String `tfsdk:"control_plane_geo"` + ControlPlaneID types.String `tfsdk:"control_plane_id"` +} diff --git a/internal/provider/types/control_plane_group.go b/internal/provider/types/control_plane_group.go new file mode 100644 index 00000000..9a9bdf51 --- /dev/null +++ b/internal/provider/types/control_plane_group.go @@ -0,0 +1,12 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "github.com/hashicorp/terraform-plugin-framework/types" +) + +type ControlPlaneGroup struct { + ControlPlaneGroupGeo types.String `tfsdk:"control_plane_group_geo"` + ControlPlaneGroupID types.String `tfsdk:"control_plane_group_id"` +} diff --git a/internal/provider/types/create_add_on_config.go b/internal/provider/types/create_add_on_config.go new file mode 100644 index 00000000..70f5a490 --- /dev/null +++ b/internal/provider/types/create_add_on_config.go @@ -0,0 +1,8 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +type CreateAddOnConfig struct { + ManagedCache *ManagedCache `queryParam:"inline" tfsdk:"managed_cache"` + ManagedCacheAddOnConfigResponse *ManagedCacheAddOnConfigResponse `queryParam:"inline" tfsdk:"managed_cache_add_on_config_response"` +} diff --git a/internal/provider/types/managed_cache.go b/internal/provider/types/managed_cache.go new file mode 100644 index 00000000..a03170a5 --- /dev/null +++ b/internal/provider/types/managed_cache.go @@ -0,0 +1,7 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +type ManagedCache struct { + CapacityConfig *ManagedCacheCapacityConfig `tfsdk:"capacity_config"` +} diff --git a/internal/provider/types/managed_cache_add_on_config_response.go b/internal/provider/types/managed_cache_add_on_config_response.go new file mode 100644 index 00000000..0b931ce4 --- /dev/null +++ b/internal/provider/types/managed_cache_add_on_config_response.go @@ -0,0 +1,9 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +type ManagedCacheAddOnConfigResponse struct { + CapacityConfig *ManagedCacheCapacityConfig `tfsdk:"capacity_config"` + DataPlaneGroups []ManagedCacheAddOnDataPlaneGroup `tfsdk:"data_plane_groups"` + StateMetadata *ManagedCacheAddOnConfigResponseStateMetadata `tfsdk:"state_metadata"` +} diff --git a/internal/provider/types/managed_cache_add_on_config_response_state_metadata.go b/internal/provider/types/managed_cache_add_on_config_response_state_metadata.go new file mode 100644 index 00000000..5716532d --- /dev/null +++ b/internal/provider/types/managed_cache_add_on_config_response_state_metadata.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "github.com/hashicorp/terraform-plugin-framework/types" +) + +type ManagedCacheAddOnConfigResponseStateMetadata struct { + CacheConfigID types.String `tfsdk:"cache_config_id"` + CacheHost types.String `tfsdk:"cache_host"` + CachePort types.String `tfsdk:"cache_port"` + CacheServerName types.String `tfsdk:"cache_server_name"` + CacheUsername types.String `tfsdk:"cache_username"` + CloudAuthentication *CloudAuthentication `tfsdk:"cloud_authentication"` +} diff --git a/internal/provider/types/managed_cache_add_on_data_plane_group.go b/internal/provider/types/managed_cache_add_on_data_plane_group.go new file mode 100644 index 00000000..e70af38d --- /dev/null +++ b/internal/provider/types/managed_cache_add_on_data_plane_group.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "github.com/hashicorp/terraform-plugin-framework/types" +) + +type ManagedCacheAddOnDataPlaneGroup struct { + CloudGatewayNetworkID types.String `tfsdk:"cloud_gateway_network_id"` + ID types.String `tfsdk:"id"` + Provider types.String `tfsdk:"provider"` + Region types.String `tfsdk:"region"` + State types.String `tfsdk:"state"` + StateMetadata *StateMetadata `tfsdk:"state_metadata"` +} diff --git a/internal/provider/types/managed_cache_capacity_config.go b/internal/provider/types/managed_cache_capacity_config.go new file mode 100644 index 00000000..5a499b7a --- /dev/null +++ b/internal/provider/types/managed_cache_capacity_config.go @@ -0,0 +1,7 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +type ManagedCacheCapacityConfig struct { + Tiered *Tiered `queryParam:"inline" tfsdk:"tiered"` +} diff --git a/internal/provider/types/state_metadata.go b/internal/provider/types/state_metadata.go new file mode 100644 index 00000000..a9b2d629 --- /dev/null +++ b/internal/provider/types/state_metadata.go @@ -0,0 +1,11 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "github.com/hashicorp/terraform-plugin-framework/types" +) + +type StateMetadata struct { + ErrorReason types.String `tfsdk:"error_reason"` +} diff --git a/internal/provider/types/tiered.go b/internal/provider/types/tiered.go new file mode 100644 index 00000000..6db6615a --- /dev/null +++ b/internal/provider/types/tiered.go @@ -0,0 +1,11 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "github.com/hashicorp/terraform-plugin-framework/types" +) + +type Tiered struct { + Tier types.String `tfsdk:"tier"` +} diff --git a/internal/sdk/cloudgateways.go b/internal/sdk/cloudgateways.go new file mode 100644 index 00000000..fc920873 --- /dev/null +++ b/internal/sdk/cloudgateways.go @@ -0,0 +1,897 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package sdk + +import ( + "bytes" + "context" + "fmt" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/config" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/hooks" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/models/errors" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/models/operations" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/models/shared" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/retry" + "net/http" + "net/url" +) + +type CloudGateways struct { + rootSDK *KonnectBeta + sdkConfiguration config.SDKConfiguration + hooks *hooks.Hooks +} + +func newCloudGateways(rootSDK *KonnectBeta, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *CloudGateways { + return &CloudGateways{ + rootSDK: rootSDK, + sdkConfiguration: sdkConfig, + hooks: hooks, + } +} + +// CreateAddOn - Create Add-On +// Creates a new add-on. Specific add-on types (e.g., managed cache) +// are defined by the sub-kind configuration. +func (s *CloudGateways) CreateAddOn(ctx context.Context, request shared.CreateAddOnRequest, opts ...operations.Option) (*operations.CreateAddOnResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + operations.SupportedOptionAcceptHeaderOverride, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(operations.CreateAddOnServerList[0], map[string]string{}) + if o.ServerURL != nil { + baseURL = *o.ServerURL + } + + opURL, err := url.JoinPath(baseURL, "/v2/cloud-gateways/add-ons") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "create-add-on", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + if o.AcceptHeaderOverride != nil { + req.Header.Set("Accept", string(*o.AcceptHeaderOverride)) + } else { + req.Header.Set("Accept", "application/json;q=1, application/problem+json;q=0") + } + + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 100, + MaxInterval: 500, + Exponent: 1.5, + MaxElapsedTime: 500, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "404", + "408", + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateAddOnResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.AddOnResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.AddOnResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.BadRequestError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.BadRequestError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.UnauthorizedError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.UnauthorizedError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 403: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.ForbiddenError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ForbiddenError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 404: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.NotFoundError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.NotFoundError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 409: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.ConflictError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ConflictError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// GetAddOn - Get Add-On +// Retrieves an add-on by ID. +func (s *CloudGateways) GetAddOn(ctx context.Context, request operations.GetAddOnRequest, opts ...operations.Option) (*operations.GetAddOnResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + operations.SupportedOptionAcceptHeaderOverride, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(operations.GetAddOnServerList[0], map[string]string{}) + if o.ServerURL != nil { + baseURL = *o.ServerURL + } + + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/cloud-gateways/add-ons/{addOnId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "get-add-on", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + if o.AcceptHeaderOverride != nil { + req.Header.Set("Accept", string(*o.AcceptHeaderOverride)) + } else { + req.Header.Set("Accept", "application/json;q=1, application/problem+json;q=0") + } + + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 100, + MaxInterval: 500, + Exponent: 1.5, + MaxElapsedTime: 500, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "404", + "408", + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetAddOnResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.AddOnResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.AddOnResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.UnauthorizedError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.UnauthorizedError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 403: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.ForbiddenError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ForbiddenError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 404: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.NotFoundError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.NotFoundError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// DeleteAddOn - Delete Add-On +// Deletes an add-on by ID. The request will be rejected if the managed cache partial is still in use by some plugins. +func (s *CloudGateways) DeleteAddOn(ctx context.Context, request operations.DeleteAddOnRequest, opts ...operations.Option) (*operations.DeleteAddOnResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(operations.DeleteAddOnServerList[0], map[string]string{}) + if o.ServerURL != nil { + baseURL = *o.ServerURL + } + + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/cloud-gateways/add-ons/{addOnId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "delete-add-on", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/problem+json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 100, + MaxInterval: 500, + Exponent: 1.5, + MaxElapsedTime: 500, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "404", + "408", + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteAddOnResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 204: + utils.DrainBody(httpRes) + case httpRes.StatusCode == 400: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.BadRequestError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.BadRequestError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.UnauthorizedError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.UnauthorizedError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 403: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.ForbiddenError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ForbiddenError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 404: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/problem+json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.NotFoundError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.NotFoundError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/internal/sdk/konnectbeta.go b/internal/sdk/konnectbeta.go index 66fb987a..94178b0b 100644 --- a/internal/sdk/konnectbeta.go +++ b/internal/sdk/konnectbeta.go @@ -165,6 +165,7 @@ type KonnectBeta struct { // Cluster policies are transformation and validation policies that can be applied to Kafka messages. // EventGatewayVirtualClusterPolicies *EventGatewayVirtualClusterPolicies + CloudGateways *CloudGateways sdkConfiguration config.SDKConfiguration hooks *hooks.Hooks @@ -327,6 +328,7 @@ func New(opts ...SDKOption) *KonnectBeta { sdk.EventGatewayVirtualClusterConsumePolicies = newEventGatewayVirtualClusterConsumePolicies(sdk, sdk.sdkConfiguration, sdk.hooks) sdk.EventGatewayVirtualClusterProducePolicies = newEventGatewayVirtualClusterProducePolicies(sdk, sdk.sdkConfiguration, sdk.hooks) sdk.EventGatewayVirtualClusterPolicies = newEventGatewayVirtualClusterPolicies(sdk, sdk.sdkConfiguration, sdk.hooks) + sdk.CloudGateways = newCloudGateways(sdk, sdk.sdkConfiguration, sdk.hooks) return sdk } diff --git a/internal/sdk/models/operations/createaddon.go b/internal/sdk/models/operations/createaddon.go new file mode 100644 index 00000000..a454cce1 --- /dev/null +++ b/internal/sdk/models/operations/createaddon.go @@ -0,0 +1,96 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/models/shared" + "net/http" +) + +var CreateAddOnServerList = []string{ + "https://global.api.konghq.com/", +} + +type CreateAddOnResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response + // Response format for creating an add-on. + AddOnResponse *shared.AddOnResponse + // Bad Request + BadRequestError *shared.BadRequestError + // Unauthorized + UnauthorizedError *shared.UnauthorizedError + // Forbidden + ForbiddenError *shared.ForbiddenError + // Not Found + NotFoundError *shared.NotFoundError + // Conflict + ConflictError *shared.ConflictError +} + +func (c *CreateAddOnResponse) GetContentType() string { + if c == nil { + return "" + } + return c.ContentType +} + +func (c *CreateAddOnResponse) GetStatusCode() int { + if c == nil { + return 0 + } + return c.StatusCode +} + +func (c *CreateAddOnResponse) GetRawResponse() *http.Response { + if c == nil { + return nil + } + return c.RawResponse +} + +func (c *CreateAddOnResponse) GetAddOnResponse() *shared.AddOnResponse { + if c == nil { + return nil + } + return c.AddOnResponse +} + +func (c *CreateAddOnResponse) GetBadRequestError() *shared.BadRequestError { + if c == nil { + return nil + } + return c.BadRequestError +} + +func (c *CreateAddOnResponse) GetUnauthorizedError() *shared.UnauthorizedError { + if c == nil { + return nil + } + return c.UnauthorizedError +} + +func (c *CreateAddOnResponse) GetForbiddenError() *shared.ForbiddenError { + if c == nil { + return nil + } + return c.ForbiddenError +} + +func (c *CreateAddOnResponse) GetNotFoundError() *shared.NotFoundError { + if c == nil { + return nil + } + return c.NotFoundError +} + +func (c *CreateAddOnResponse) GetConflictError() *shared.ConflictError { + if c == nil { + return nil + } + return c.ConflictError +} diff --git a/internal/sdk/models/operations/deleteaddon.go b/internal/sdk/models/operations/deleteaddon.go new file mode 100644 index 00000000..5d27212e --- /dev/null +++ b/internal/sdk/models/operations/deleteaddon.go @@ -0,0 +1,90 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/models/shared" + "net/http" +) + +var DeleteAddOnServerList = []string{ + "https://global.api.konghq.com/", +} + +type DeleteAddOnRequest struct { + // ID of the add-on to operate on. + AddOnID string `pathParam:"style=simple,explode=false,name=addOnId"` +} + +func (d *DeleteAddOnRequest) GetAddOnID() string { + if d == nil { + return "" + } + return d.AddOnID +} + +type DeleteAddOnResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response + // Bad Request + BadRequestError *shared.BadRequestError + // Unauthorized + UnauthorizedError *shared.UnauthorizedError + // Forbidden + ForbiddenError *shared.ForbiddenError + // Not Found + NotFoundError *shared.NotFoundError +} + +func (d *DeleteAddOnResponse) GetContentType() string { + if d == nil { + return "" + } + return d.ContentType +} + +func (d *DeleteAddOnResponse) GetStatusCode() int { + if d == nil { + return 0 + } + return d.StatusCode +} + +func (d *DeleteAddOnResponse) GetRawResponse() *http.Response { + if d == nil { + return nil + } + return d.RawResponse +} + +func (d *DeleteAddOnResponse) GetBadRequestError() *shared.BadRequestError { + if d == nil { + return nil + } + return d.BadRequestError +} + +func (d *DeleteAddOnResponse) GetUnauthorizedError() *shared.UnauthorizedError { + if d == nil { + return nil + } + return d.UnauthorizedError +} + +func (d *DeleteAddOnResponse) GetForbiddenError() *shared.ForbiddenError { + if d == nil { + return nil + } + return d.ForbiddenError +} + +func (d *DeleteAddOnResponse) GetNotFoundError() *shared.NotFoundError { + if d == nil { + return nil + } + return d.NotFoundError +} diff --git a/internal/sdk/models/operations/getaddon.go b/internal/sdk/models/operations/getaddon.go new file mode 100644 index 00000000..f23b3ef5 --- /dev/null +++ b/internal/sdk/models/operations/getaddon.go @@ -0,0 +1,90 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/models/shared" + "net/http" +) + +var GetAddOnServerList = []string{ + "https://global.api.konghq.com/", +} + +type GetAddOnRequest struct { + // ID of the add-on to operate on. + AddOnID string `pathParam:"style=simple,explode=false,name=addOnId"` +} + +func (g *GetAddOnRequest) GetAddOnID() string { + if g == nil { + return "" + } + return g.AddOnID +} + +type GetAddOnResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response + // Response format for retrieving an add-on by ID. + AddOnResponse *shared.AddOnResponse + // Unauthorized + UnauthorizedError *shared.UnauthorizedError + // Forbidden + ForbiddenError *shared.ForbiddenError + // Not Found + NotFoundError *shared.NotFoundError +} + +func (g *GetAddOnResponse) GetContentType() string { + if g == nil { + return "" + } + return g.ContentType +} + +func (g *GetAddOnResponse) GetStatusCode() int { + if g == nil { + return 0 + } + return g.StatusCode +} + +func (g *GetAddOnResponse) GetRawResponse() *http.Response { + if g == nil { + return nil + } + return g.RawResponse +} + +func (g *GetAddOnResponse) GetAddOnResponse() *shared.AddOnResponse { + if g == nil { + return nil + } + return g.AddOnResponse +} + +func (g *GetAddOnResponse) GetUnauthorizedError() *shared.UnauthorizedError { + if g == nil { + return nil + } + return g.UnauthorizedError +} + +func (g *GetAddOnResponse) GetForbiddenError() *shared.ForbiddenError { + if g == nil { + return nil + } + return g.ForbiddenError +} + +func (g *GetAddOnResponse) GetNotFoundError() *shared.NotFoundError { + if g == nil { + return nil + } + return g.NotFoundError +} diff --git a/internal/sdk/models/shared/addonconfigresponse.go b/internal/sdk/models/shared/addonconfigresponse.go new file mode 100644 index 00000000..d26dbdc8 --- /dev/null +++ b/internal/sdk/models/shared/addonconfigresponse.go @@ -0,0 +1,73 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "errors" + "fmt" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" +) + +type AddOnConfigResponseType string + +const ( + AddOnConfigResponseTypeManagedCacheAddOnConfigResponse AddOnConfigResponseType = "ManagedCacheAddOnConfigResponse" +) + +// AddOnConfigResponse - Configuration object for different types of add-ons. +type AddOnConfigResponse struct { + ManagedCacheAddOnConfigResponse *ManagedCacheAddOnConfigResponse `queryParam:"inline" union:"member"` + + Type AddOnConfigResponseType +} + +func CreateAddOnConfigResponseManagedCacheAddOnConfigResponse(managedCacheAddOnConfigResponse ManagedCacheAddOnConfigResponse) AddOnConfigResponse { + typ := AddOnConfigResponseTypeManagedCacheAddOnConfigResponse + + return AddOnConfigResponse{ + ManagedCacheAddOnConfigResponse: &managedCacheAddOnConfigResponse, + Type: typ, + } +} + +func (u *AddOnConfigResponse) UnmarshalJSON(data []byte) error { + + var candidates []utils.UnionCandidate + + // Collect all valid candidates + var managedCacheAddOnConfigResponse ManagedCacheAddOnConfigResponse = ManagedCacheAddOnConfigResponse{} + if err := utils.UnmarshalJSON(data, &managedCacheAddOnConfigResponse, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: AddOnConfigResponseTypeManagedCacheAddOnConfigResponse, + Value: &managedCacheAddOnConfigResponse, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for AddOnConfigResponse", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestUnionCandidate(candidates, data) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for AddOnConfigResponse", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(AddOnConfigResponseType) + switch best.Type { + case AddOnConfigResponseTypeManagedCacheAddOnConfigResponse: + u.ManagedCacheAddOnConfigResponse = best.Value.(*ManagedCacheAddOnConfigResponse) + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for AddOnConfigResponse", string(data)) +} + +func (u AddOnConfigResponse) MarshalJSON() ([]byte, error) { + if u.ManagedCacheAddOnConfigResponse != nil { + return utils.MarshalJSON(u.ManagedCacheAddOnConfigResponse, "", true) + } + + return nil, errors.New("could not marshal union type AddOnConfigResponse: all fields are null") +} diff --git a/internal/sdk/models/shared/addonowner.go b/internal/sdk/models/shared/addonowner.go new file mode 100644 index 00000000..cc10378f --- /dev/null +++ b/internal/sdk/models/shared/addonowner.go @@ -0,0 +1,99 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "errors" + "fmt" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" +) + +type AddOnOwnerType string + +const ( + AddOnOwnerTypeControlPlane AddOnOwnerType = "control_plane" + AddOnOwnerTypeControlPlaneGroup AddOnOwnerType = "control_plane_group" +) + +// AddOnOwner - Owner for the add-on. +type AddOnOwner struct { + ControlPlane *ControlPlane `queryParam:"inline" union:"member"` + ControlPlaneGroup *ControlPlaneGroup `queryParam:"inline" union:"member"` + + Type AddOnOwnerType +} + +func CreateAddOnOwnerControlPlane(controlPlane ControlPlane) AddOnOwner { + typ := AddOnOwnerTypeControlPlane + + return AddOnOwner{ + ControlPlane: &controlPlane, + Type: typ, + } +} + +func CreateAddOnOwnerControlPlaneGroup(controlPlaneGroup ControlPlaneGroup) AddOnOwner { + typ := AddOnOwnerTypeControlPlaneGroup + + return AddOnOwner{ + ControlPlaneGroup: &controlPlaneGroup, + Type: typ, + } +} + +func (u *AddOnOwner) UnmarshalJSON(data []byte) error { + + var candidates []utils.UnionCandidate + + // Collect all valid candidates + var controlPlane ControlPlane = ControlPlane{} + if err := utils.UnmarshalJSON(data, &controlPlane, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: AddOnOwnerTypeControlPlane, + Value: &controlPlane, + }) + } + + var controlPlaneGroup ControlPlaneGroup = ControlPlaneGroup{} + if err := utils.UnmarshalJSON(data, &controlPlaneGroup, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: AddOnOwnerTypeControlPlaneGroup, + Value: &controlPlaneGroup, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for AddOnOwner", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestUnionCandidate(candidates, data) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for AddOnOwner", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(AddOnOwnerType) + switch best.Type { + case AddOnOwnerTypeControlPlane: + u.ControlPlane = best.Value.(*ControlPlane) + return nil + case AddOnOwnerTypeControlPlaneGroup: + u.ControlPlaneGroup = best.Value.(*ControlPlaneGroup) + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for AddOnOwner", string(data)) +} + +func (u AddOnOwner) MarshalJSON() ([]byte, error) { + if u.ControlPlane != nil { + return utils.MarshalJSON(u.ControlPlane, "", true) + } + + if u.ControlPlaneGroup != nil { + return utils.MarshalJSON(u.ControlPlaneGroup, "", true) + } + + return nil, errors.New("could not marshal union type AddOnOwner: all fields are null") +} diff --git a/internal/sdk/models/shared/addonresponse.go b/internal/sdk/models/shared/addonresponse.go new file mode 100644 index 00000000..0101efcf --- /dev/null +++ b/internal/sdk/models/shared/addonresponse.go @@ -0,0 +1,98 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" + "time" +) + +// AddOnResponse - Object containing information about an add-on. +type AddOnResponse struct { + ID string `json:"id"` + // Unique human-readable name of the add-on. + Name string `json:"name"` + // Owner for the add-on. + Owner AddOnOwner `json:"owner"` + // Configuration object for different types of add-ons. + Config AddOnConfigResponse `json:"config"` + // Monotonically-increasing version count of the add-on, to indicate the order of updates to the add-on. + EntityVersion int64 `json:"entity_version"` + // The current state of the add-on. Possible values: + // - `initializing` - The add-on is in the process of being initialized/updated. + // - `ready` - The add-on is fully operational. + // - `terminating` - The add-on is in the process of being deleted. + // + State AddOnState `json:"state"` + // RFC-3339 timestamp representation of add-on creation date. + CreatedAt time.Time `json:"created_at"` + // RFC-3339 timestamp representation of add-on update date. + UpdatedAt time.Time `json:"updated_at"` +} + +func (a AddOnResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AddOnResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, nil); err != nil { + return err + } + return nil +} + +func (a *AddOnResponse) GetID() string { + if a == nil { + return "" + } + return a.ID +} + +func (a *AddOnResponse) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *AddOnResponse) GetOwner() AddOnOwner { + if a == nil { + return AddOnOwner{} + } + return a.Owner +} + +func (a *AddOnResponse) GetConfig() AddOnConfigResponse { + if a == nil { + return AddOnConfigResponse{} + } + return a.Config +} + +func (a *AddOnResponse) GetEntityVersion() int64 { + if a == nil { + return 0 + } + return a.EntityVersion +} + +func (a *AddOnResponse) GetState() AddOnState { + if a == nil { + return AddOnState("") + } + return a.State +} + +func (a *AddOnResponse) GetCreatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.CreatedAt +} + +func (a *AddOnResponse) GetUpdatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.UpdatedAt +} diff --git a/internal/sdk/models/shared/addonstate.go b/internal/sdk/models/shared/addonstate.go new file mode 100644 index 00000000..709a7876 --- /dev/null +++ b/internal/sdk/models/shared/addonstate.go @@ -0,0 +1,41 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// AddOnState - The current state of the add-on. Possible values: +// - `initializing` - The add-on is in the process of being initialized/updated. +// - `ready` - The add-on is fully operational. +// - `terminating` - The add-on is in the process of being deleted. +type AddOnState string + +const ( + AddOnStateInitializing AddOnState = "initializing" + AddOnStateReady AddOnState = "ready" + AddOnStateTerminating AddOnState = "terminating" +) + +func (e AddOnState) ToPointer() *AddOnState { + return &e +} +func (e *AddOnState) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "initializing": + fallthrough + case "ready": + fallthrough + case "terminating": + *e = AddOnState(v) + return nil + default: + return fmt.Errorf("invalid value for AddOnState: %v", v) + } +} diff --git a/internal/sdk/models/shared/controlplane.go b/internal/sdk/models/shared/controlplane.go new file mode 100644 index 00000000..e817e8cd --- /dev/null +++ b/internal/sdk/models/shared/controlplane.go @@ -0,0 +1,46 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" +) + +// ControlPlane - Control Plane is the owner for the add-on. +type ControlPlane struct { + // Type of owner for the add-on. + kind string `const:"control-plane" json:"kind"` + // ID of the control-plane that owns this add-on. + ControlPlaneID string `json:"control_plane_id"` + // Set of control-plane geos supported for deploying cloud-gateways configurations. + ControlPlaneGeo ControlPlaneGeo `json:"control_plane_geo"` +} + +func (c ControlPlane) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *ControlPlane) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { + return err + } + return nil +} + +func (c *ControlPlane) GetKind() string { + return "control-plane" +} + +func (c *ControlPlane) GetControlPlaneID() string { + if c == nil { + return "" + } + return c.ControlPlaneID +} + +func (c *ControlPlane) GetControlPlaneGeo() ControlPlaneGeo { + if c == nil { + return ControlPlaneGeo("") + } + return c.ControlPlaneGeo +} diff --git a/internal/sdk/models/shared/controlplanegeo.go b/internal/sdk/models/shared/controlplanegeo.go new file mode 100644 index 00000000..4a915bcb --- /dev/null +++ b/internal/sdk/models/shared/controlplanegeo.go @@ -0,0 +1,47 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// ControlPlaneGeo - Set of control-plane geos supported for deploying cloud-gateways configurations. +type ControlPlaneGeo string + +const ( + ControlPlaneGeoUs ControlPlaneGeo = "us" + ControlPlaneGeoEu ControlPlaneGeo = "eu" + ControlPlaneGeoAu ControlPlaneGeo = "au" + ControlPlaneGeoMe ControlPlaneGeo = "me" + ControlPlaneGeoIn ControlPlaneGeo = "in" + ControlPlaneGeoSg ControlPlaneGeo = "sg" +) + +func (e ControlPlaneGeo) ToPointer() *ControlPlaneGeo { + return &e +} +func (e *ControlPlaneGeo) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "us": + fallthrough + case "eu": + fallthrough + case "au": + fallthrough + case "me": + fallthrough + case "in": + fallthrough + case "sg": + *e = ControlPlaneGeo(v) + return nil + default: + return fmt.Errorf("invalid value for ControlPlaneGeo: %v", v) + } +} diff --git a/internal/sdk/models/shared/controlplanegroup.go b/internal/sdk/models/shared/controlplanegroup.go new file mode 100644 index 00000000..13305011 --- /dev/null +++ b/internal/sdk/models/shared/controlplanegroup.go @@ -0,0 +1,46 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" +) + +// ControlPlaneGroup - Control Plane Group is the owner for the add-on. +type ControlPlaneGroup struct { + // Type of owner for the add-on. + kind string `const:"control-plane-group" json:"kind"` + // ID of the control-plane group that owns this add-on. + ControlPlaneGroupID string `json:"control_plane_group_id"` + // Set of control-plane geos supported for deploying cloud-gateways configurations. + ControlPlaneGroupGeo ControlPlaneGeo `json:"control_plane_group_geo"` +} + +func (c ControlPlaneGroup) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *ControlPlaneGroup) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { + return err + } + return nil +} + +func (c *ControlPlaneGroup) GetKind() string { + return "control-plane-group" +} + +func (c *ControlPlaneGroup) GetControlPlaneGroupID() string { + if c == nil { + return "" + } + return c.ControlPlaneGroupID +} + +func (c *ControlPlaneGroup) GetControlPlaneGroupGeo() ControlPlaneGeo { + if c == nil { + return ControlPlaneGeo("") + } + return c.ControlPlaneGroupGeo +} diff --git a/internal/sdk/models/shared/createaddonconfig.go b/internal/sdk/models/shared/createaddonconfig.go new file mode 100644 index 00000000..7ce2e655 --- /dev/null +++ b/internal/sdk/models/shared/createaddonconfig.go @@ -0,0 +1,73 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "errors" + "fmt" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" +) + +type CreateAddOnConfigType string + +const ( + CreateAddOnConfigTypeManagedCache CreateAddOnConfigType = "managed_cache" +) + +// CreateAddOnConfig - Configuration for creating different types of add-ons. +type CreateAddOnConfig struct { + ManagedCache *ManagedCache `queryParam:"inline" union:"member"` + + Type CreateAddOnConfigType +} + +func CreateCreateAddOnConfigManagedCache(managedCache ManagedCache) CreateAddOnConfig { + typ := CreateAddOnConfigTypeManagedCache + + return CreateAddOnConfig{ + ManagedCache: &managedCache, + Type: typ, + } +} + +func (u *CreateAddOnConfig) UnmarshalJSON(data []byte) error { + + var candidates []utils.UnionCandidate + + // Collect all valid candidates + var managedCache ManagedCache = ManagedCache{} + if err := utils.UnmarshalJSON(data, &managedCache, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: CreateAddOnConfigTypeManagedCache, + Value: &managedCache, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for CreateAddOnConfig", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestUnionCandidate(candidates, data) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for CreateAddOnConfig", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(CreateAddOnConfigType) + switch best.Type { + case CreateAddOnConfigTypeManagedCache: + u.ManagedCache = best.Value.(*ManagedCache) + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for CreateAddOnConfig", string(data)) +} + +func (u CreateAddOnConfig) MarshalJSON() ([]byte, error) { + if u.ManagedCache != nil { + return utils.MarshalJSON(u.ManagedCache, "", true) + } + + return nil, errors.New("could not marshal union type CreateAddOnConfig: all fields are null") +} diff --git a/internal/sdk/models/shared/createaddonrequest.go b/internal/sdk/models/shared/createaddonrequest.go new file mode 100644 index 00000000..71176eda --- /dev/null +++ b/internal/sdk/models/shared/createaddonrequest.go @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// CreateAddOnRequest - Request schema for creating an add-on. +type CreateAddOnRequest struct { + // Unique human-readable name of the add-on. + Name string `json:"name"` + // Owner for the add-on. + Owner AddOnOwner `json:"owner"` + // Configuration for creating different types of add-ons. + Config CreateAddOnConfig `json:"config"` +} + +func (c *CreateAddOnRequest) GetName() string { + if c == nil { + return "" + } + return c.Name +} + +func (c *CreateAddOnRequest) GetOwner() AddOnOwner { + if c == nil { + return AddOnOwner{} + } + return c.Owner +} + +func (c *CreateAddOnRequest) GetConfig() CreateAddOnConfig { + if c == nil { + return CreateAddOnConfig{} + } + return c.Config +} diff --git a/internal/sdk/models/shared/managedcache.go b/internal/sdk/models/shared/managedcache.go new file mode 100644 index 00000000..917076f1 --- /dev/null +++ b/internal/sdk/models/shared/managedcache.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" +) + +// ManagedCache - Configuration for creating a managed cache add-on. +type ManagedCache struct { + // Type of add-on configuration. + kind string `const:"managed-cache.v0" json:"kind"` + // Configuration for managed cache capacity and performance characteristics. + CapacityConfig ManagedCacheCapacityConfig `json:"capacity_config"` +} + +func (m ManagedCache) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(m, "", false) +} + +func (m *ManagedCache) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &m, "", false, nil); err != nil { + return err + } + return nil +} + +func (m *ManagedCache) GetKind() string { + return "managed-cache.v0" +} + +func (m *ManagedCache) GetCapacityConfig() ManagedCacheCapacityConfig { + if m == nil { + return ManagedCacheCapacityConfig{} + } + return m.CapacityConfig +} diff --git a/internal/sdk/models/shared/managedcacheaddonconfigresponse.go b/internal/sdk/models/shared/managedcacheaddonconfigresponse.go new file mode 100644 index 00000000..50316d1d --- /dev/null +++ b/internal/sdk/models/shared/managedcacheaddonconfigresponse.go @@ -0,0 +1,186 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" +) + +// CloudAuthentication - Metadata describing the cloud authentication details for managed cache add-on. +type CloudAuthentication struct { + // Env vault path to cache auth provider. + AuthProvider *string `default:"null" json:"auth_provider"` + // Env vault path to aws cache name. + AwsCacheName *string `default:"null" json:"aws_cache_name"` + // Env vault path to aws region. + AwsRegion *string `default:"null" json:"aws_region"` + // Env vault path to aws assume role arn. + AwsAssumeRoleArn *string `default:"null" json:"aws_assume_role_arn"` + // Env vault path to azure tenant id. + AzureTenantID *string `default:"null" json:"azure_tenant_id"` +} + +func (c CloudAuthentication) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CloudAuthentication) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { + return err + } + return nil +} + +func (c *CloudAuthentication) GetAuthProvider() *string { + if c == nil { + return nil + } + return c.AuthProvider +} + +func (c *CloudAuthentication) GetAwsCacheName() *string { + if c == nil { + return nil + } + return c.AwsCacheName +} + +func (c *CloudAuthentication) GetAwsRegion() *string { + if c == nil { + return nil + } + return c.AwsRegion +} + +func (c *CloudAuthentication) GetAwsAssumeRoleArn() *string { + if c == nil { + return nil + } + return c.AwsAssumeRoleArn +} + +func (c *CloudAuthentication) GetAzureTenantID() *string { + if c == nil { + return nil + } + return c.AzureTenantID +} + +// ManagedCacheAddOnConfigResponseStateMetadata - Metadata describing the state of the managed cache add-on. +type ManagedCacheAddOnConfigResponseStateMetadata struct { + // Reference to cache configuration for this add-on. + CacheConfigID *string `default:"null" json:"cache_config_id"` + // Env vault path to cache server name. + CacheServerName *string `default:"null" json:"cache_server_name"` + // Env vault path to cache hostname. + CacheHost *string `default:"null" json:"cache_host"` + // Env vault path to cache port. + CachePort *string `default:"null" json:"cache_port"` + // Env vault path to cache username. + CacheUsername *string `default:"null" json:"cache_username"` + // Metadata describing the cloud authentication details for managed cache add-on. + // + CloudAuthentication *CloudAuthentication `json:"cloud_authentication"` +} + +func (m ManagedCacheAddOnConfigResponseStateMetadata) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(m, "", false) +} + +func (m *ManagedCacheAddOnConfigResponseStateMetadata) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &m, "", false, nil); err != nil { + return err + } + return nil +} + +func (m *ManagedCacheAddOnConfigResponseStateMetadata) GetCacheConfigID() *string { + if m == nil { + return nil + } + return m.CacheConfigID +} + +func (m *ManagedCacheAddOnConfigResponseStateMetadata) GetCacheServerName() *string { + if m == nil { + return nil + } + return m.CacheServerName +} + +func (m *ManagedCacheAddOnConfigResponseStateMetadata) GetCacheHost() *string { + if m == nil { + return nil + } + return m.CacheHost +} + +func (m *ManagedCacheAddOnConfigResponseStateMetadata) GetCachePort() *string { + if m == nil { + return nil + } + return m.CachePort +} + +func (m *ManagedCacheAddOnConfigResponseStateMetadata) GetCacheUsername() *string { + if m == nil { + return nil + } + return m.CacheUsername +} + +func (m *ManagedCacheAddOnConfigResponseStateMetadata) GetCloudAuthentication() *CloudAuthentication { + if m == nil { + return nil + } + return m.CloudAuthentication +} + +// ManagedCacheAddOnConfigResponse - Configuration for managed cache add-on. +type ManagedCacheAddOnConfigResponse struct { + // Type of add-on configuration. + kind string `const:"managed-cache.v0" json:"kind"` + // Configuration for managed cache capacity and performance characteristics. + CapacityConfig ManagedCacheCapacityConfig `json:"capacity_config"` + // List of data-plane groups where the managed cache is deployed. + DataPlaneGroups []ManagedCacheAddOnDataPlaneGroup `json:"data_plane_groups"` + // Metadata describing the state of the managed cache add-on. + // + StateMetadata ManagedCacheAddOnConfigResponseStateMetadata `json:"state_metadata"` +} + +func (m ManagedCacheAddOnConfigResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(m, "", false) +} + +func (m *ManagedCacheAddOnConfigResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &m, "", false, nil); err != nil { + return err + } + return nil +} + +func (m *ManagedCacheAddOnConfigResponse) GetKind() string { + return "managed-cache.v0" +} + +func (m *ManagedCacheAddOnConfigResponse) GetCapacityConfig() ManagedCacheCapacityConfig { + if m == nil { + return ManagedCacheCapacityConfig{} + } + return m.CapacityConfig +} + +func (m *ManagedCacheAddOnConfigResponse) GetDataPlaneGroups() []ManagedCacheAddOnDataPlaneGroup { + if m == nil { + return []ManagedCacheAddOnDataPlaneGroup{} + } + return m.DataPlaneGroups +} + +func (m *ManagedCacheAddOnConfigResponse) GetStateMetadata() ManagedCacheAddOnConfigResponseStateMetadata { + if m == nil { + return ManagedCacheAddOnConfigResponseStateMetadata{} + } + return m.StateMetadata +} diff --git a/internal/sdk/models/shared/managedcacheaddondataplanegroup.go b/internal/sdk/models/shared/managedcacheaddondataplanegroup.go new file mode 100644 index 00000000..24a1bf99 --- /dev/null +++ b/internal/sdk/models/shared/managedcacheaddondataplanegroup.go @@ -0,0 +1,146 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" +) + +// State - The current state of the managed cache add-on in the data-plane group. Possible values: +// - `initializing` - The add-on is in the process of being initialized/updated and is setting up necessary resources for this data-plane group. +// - `ready` - The add-on is fully operational for this data-plane group. +// - `error` - The add-on is in an error state, and is not operational for this data-plane group. +// - `terminating` - The add-on is in the process of being deleted for this data-plane group. +type State string + +const ( + StateInitializing State = "initializing" + StateReady State = "ready" + StateError State = "error" + StateTerminating State = "terminating" +) + +func (e State) ToPointer() *State { + return &e +} +func (e *State) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "initializing": + fallthrough + case "ready": + fallthrough + case "error": + fallthrough + case "terminating": + *e = State(v) + return nil + default: + return fmt.Errorf("invalid value for State: %v", v) + } +} + +// StateMetadata - Metadata describing the state of the managed cache add-on in the data-plane group. +type StateMetadata struct { + // Reason why the managed cache add-on may be in an error state, reported from backing infrastructure. + // + ErrorReason *string `default:"null" json:"error_reason"` +} + +func (s StateMetadata) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *StateMetadata) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { + return err + } + return nil +} + +func (s *StateMetadata) GetErrorReason() *string { + if s == nil { + return nil + } + return s.ErrorReason +} + +// ManagedCacheAddOnDataPlaneGroup - Object that describes a data-plane group where managed cache add-on is deployed. +type ManagedCacheAddOnDataPlaneGroup struct { + // ID of the data-plane group. + ID string `json:"id"` + // Network ID this data-plane group is attached to. + CloudGatewayNetworkID string `json:"cloud_gateway_network_id"` + // Name of cloud provider. + Provider ProviderName `json:"provider"` + // Region of cloud provider the data-plane group is deployed to. + Region string `json:"region"` + // The current state of the managed cache add-on in the data-plane group. Possible values: + // - `initializing` - The add-on is in the process of being initialized/updated and is setting up necessary resources for this data-plane group. + // - `ready` - The add-on is fully operational for this data-plane group. + // - `error` - The add-on is in an error state, and is not operational for this data-plane group. + // - `terminating` - The add-on is in the process of being deleted for this data-plane group. + // + State State `json:"state"` + // Metadata describing the state of the managed cache add-on in the data-plane group. + // + StateMetadata StateMetadata `json:"state_metadata"` +} + +func (m ManagedCacheAddOnDataPlaneGroup) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(m, "", false) +} + +func (m *ManagedCacheAddOnDataPlaneGroup) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &m, "", false, nil); err != nil { + return err + } + return nil +} + +func (m *ManagedCacheAddOnDataPlaneGroup) GetID() string { + if m == nil { + return "" + } + return m.ID +} + +func (m *ManagedCacheAddOnDataPlaneGroup) GetCloudGatewayNetworkID() string { + if m == nil { + return "" + } + return m.CloudGatewayNetworkID +} + +func (m *ManagedCacheAddOnDataPlaneGroup) GetProvider() ProviderName { + if m == nil { + return ProviderName("") + } + return m.Provider +} + +func (m *ManagedCacheAddOnDataPlaneGroup) GetRegion() string { + if m == nil { + return "" + } + return m.Region +} + +func (m *ManagedCacheAddOnDataPlaneGroup) GetState() State { + if m == nil { + return State("") + } + return m.State +} + +func (m *ManagedCacheAddOnDataPlaneGroup) GetStateMetadata() StateMetadata { + if m == nil { + return StateMetadata{} + } + return m.StateMetadata +} diff --git a/internal/sdk/models/shared/managedcachecapacityconfig.go b/internal/sdk/models/shared/managedcachecapacityconfig.go new file mode 100644 index 00000000..8ccc8cb2 --- /dev/null +++ b/internal/sdk/models/shared/managedcachecapacityconfig.go @@ -0,0 +1,73 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "errors" + "fmt" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" +) + +type ManagedCacheCapacityConfigType string + +const ( + ManagedCacheCapacityConfigTypeTiered ManagedCacheCapacityConfigType = "Tiered" +) + +// ManagedCacheCapacityConfig - Configuration for managed cache capacity and performance characteristics. +type ManagedCacheCapacityConfig struct { + Tiered *Tiered `queryParam:"inline" union:"member"` + + Type ManagedCacheCapacityConfigType +} + +func CreateManagedCacheCapacityConfigTiered(tiered Tiered) ManagedCacheCapacityConfig { + typ := ManagedCacheCapacityConfigTypeTiered + + return ManagedCacheCapacityConfig{ + Tiered: &tiered, + Type: typ, + } +} + +func (u *ManagedCacheCapacityConfig) UnmarshalJSON(data []byte) error { + + var candidates []utils.UnionCandidate + + // Collect all valid candidates + var tiered Tiered = Tiered{} + if err := utils.UnmarshalJSON(data, &tiered, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: ManagedCacheCapacityConfigTypeTiered, + Value: &tiered, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for ManagedCacheCapacityConfig", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestUnionCandidate(candidates, data) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for ManagedCacheCapacityConfig", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(ManagedCacheCapacityConfigType) + switch best.Type { + case ManagedCacheCapacityConfigTypeTiered: + u.Tiered = best.Value.(*Tiered) + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for ManagedCacheCapacityConfig", string(data)) +} + +func (u ManagedCacheCapacityConfig) MarshalJSON() ([]byte, error) { + if u.Tiered != nil { + return utils.MarshalJSON(u.Tiered, "", true) + } + + return nil, errors.New("could not marshal union type ManagedCacheCapacityConfig: all fields are null") +} diff --git a/internal/sdk/models/shared/meshserviceitem.go b/internal/sdk/models/shared/meshserviceitem.go index f243bb8e..717aafea 100644 --- a/internal/sdk/models/shared/meshserviceitem.go +++ b/internal/sdk/models/shared/meshserviceitem.go @@ -264,19 +264,19 @@ func (m *MeshServiceItemSelector) GetDataplaneTags() map[string]string { return m.DataplaneTags } -// State of MeshService. Available if there is at least one healthy endpoint. Otherwise, Unavailable. +// MeshServiceItemState - State of MeshService. Available if there is at least one healthy endpoint. Otherwise, Unavailable. // It's used for cross zone communication to check if we should send traffic to it, when MeshService is aggregated into MeshMultiZoneService. -type State string +type MeshServiceItemState string const ( - StateAvailable State = "Available" - StateUnavailable State = "Unavailable" + MeshServiceItemStateAvailable MeshServiceItemState = "Available" + MeshServiceItemStateUnavailable MeshServiceItemState = "Unavailable" ) -func (e State) ToPointer() *State { +func (e MeshServiceItemState) ToPointer() *MeshServiceItemState { return &e } -func (e *State) UnmarshalJSON(data []byte) error { +func (e *MeshServiceItemState) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { return err @@ -285,10 +285,10 @@ func (e *State) UnmarshalJSON(data []byte) error { case "Available": fallthrough case "Unavailable": - *e = State(v) + *e = MeshServiceItemState(v) return nil default: - return fmt.Errorf("invalid value for State: %v", v) + return fmt.Errorf("invalid value for MeshServiceItemState: %v", v) } } @@ -299,7 +299,7 @@ type MeshServiceItemSpec struct { Selector *MeshServiceItemSelector `json:"selector,omitempty"` // State of MeshService. Available if there is at least one healthy endpoint. Otherwise, Unavailable. // It's used for cross zone communication to check if we should send traffic to it, when MeshService is aggregated into MeshMultiZoneService. - State *State `default:"Unavailable" json:"state"` + State *MeshServiceItemState `default:"Unavailable" json:"state"` } func (m MeshServiceItemSpec) MarshalJSON() ([]byte, error) { @@ -334,7 +334,7 @@ func (m *MeshServiceItemSpec) GetSelector() *MeshServiceItemSelector { return m.Selector } -func (m *MeshServiceItemSpec) GetState() *State { +func (m *MeshServiceItemSpec) GetState() *MeshServiceItemState { if m == nil { return nil } diff --git a/internal/sdk/models/shared/providername.go b/internal/sdk/models/shared/providername.go new file mode 100644 index 00000000..086626e7 --- /dev/null +++ b/internal/sdk/models/shared/providername.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// ProviderName - Name of cloud provider. +type ProviderName string + +const ( + ProviderNameAws ProviderName = "aws" + ProviderNameAzure ProviderName = "azure" + ProviderNameGcp ProviderName = "gcp" +) + +func (e ProviderName) ToPointer() *ProviderName { + return &e +} +func (e *ProviderName) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "aws": + fallthrough + case "azure": + fallthrough + case "gcp": + *e = ProviderName(v) + return nil + default: + return fmt.Errorf("invalid value for ProviderName: %v", v) + } +} diff --git a/internal/sdk/models/shared/tiered.go b/internal/sdk/models/shared/tiered.go new file mode 100644 index 00000000..67ae9eec --- /dev/null +++ b/internal/sdk/models/shared/tiered.go @@ -0,0 +1,96 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/kong/terraform-provider-konnect-beta/internal/sdk/internal/utils" +) + +// Tier - Capacity tier that determines both cache size and performance characteristics: +// - micro: ~0.5 GiB capacity +// - small: ~1 GiB capacity +// - medium: ~3 GiB capacity +// - large: ~6 GiB capacity +// - xlarge: ~12 GiB capacity +// - 2xlarge: ~25 GiB capacity +// - 4xlarge: ~52 GiB capacity +type Tier string + +const ( + TierMicro Tier = "micro" + TierSmall Tier = "small" + TierMedium Tier = "medium" + TierLarge Tier = "large" + TierXlarge Tier = "xlarge" + TierTwoxlarge Tier = "2xlarge" + TierFourxlarge Tier = "4xlarge" +) + +func (e Tier) ToPointer() *Tier { + return &e +} +func (e *Tier) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "micro": + fallthrough + case "small": + fallthrough + case "medium": + fallthrough + case "large": + fallthrough + case "xlarge": + fallthrough + case "2xlarge": + fallthrough + case "4xlarge": + *e = Tier(v) + return nil + default: + return fmt.Errorf("invalid value for Tier: %v", v) + } +} + +// Tiered - Capacity tiers with pre-configured size and performance characteristics. +type Tiered struct { + // Type of capacity configuration. + kind string `const:"tiered" json:"kind"` + // Capacity tier that determines both cache size and performance characteristics: + // - micro: ~0.5 GiB capacity + // - small: ~1 GiB capacity + // - medium: ~3 GiB capacity + // - large: ~6 GiB capacity + // - xlarge: ~12 GiB capacity + // - 2xlarge: ~25 GiB capacity + // - 4xlarge: ~52 GiB capacity + // + Tier Tier `json:"tier"` +} + +func (t Tiered) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(t, "", false) +} + +func (t *Tiered) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &t, "", false, nil); err != nil { + return err + } + return nil +} + +func (t *Tiered) GetKind() string { + return "tiered" +} + +func (t *Tiered) GetTier() Tier { + if t == nil { + return Tier("") + } + return t.Tier +} From ae9e910314901341a7b82fbac504a337a18ea88e Mon Sep 17 00:00:00 2001 From: shivay Date: Wed, 25 Feb 2026 09:47:26 +0530 Subject: [PATCH 3/4] feat: added test for cloud gateway add-on --- tests/resources/cloud_gateway_test.go | 92 +++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 tests/resources/cloud_gateway_test.go diff --git a/tests/resources/cloud_gateway_test.go b/tests/resources/cloud_gateway_test.go new file mode 100644 index 00000000..fd8e5001 --- /dev/null +++ b/tests/resources/cloud_gateway_test.go @@ -0,0 +1,92 @@ +package tests + +import ( + "testing" + + "github.com/Kong/shared-speakeasy/hclbuilder" + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/kong/terraform-provider-konnect-beta/internal/provider" + "github.com/stretchr/testify/require" +) + +var ( + providerFactoryBeta = map[string]func() (tfprotov6.ProviderServer, error){ + "konnect-beta": providerserver.NewProtocol6WithError(provider.New("")()), + } +) + +func TestCloudGatewayAddOn(t *testing.T) { + t.Run("Cloud Gateways AddOns", func(t *testing.T) { + builder := hclbuilder.New() + cp, err := hclbuilder.FromString(` + resource "konnect_gateway_control_plane" "test_cp" { + name = "tf-test-cp-us-external" + cloud_gateway = true + } + `) + require.NoError(t, err) + addon, err := hclbuilder.FromString(` + resource "konnect_cloud_gateway_add_on" "my_addon" { + provider = konnect-beta + name = "tf-test-add-on" + + config = { + managed_cache = { + kind = "managed-cache.v0" + + capacity_config = { + tiered = { + kind = "tiered" + tier = "small" + } + } + } + } + owner = { + control_plane = { + kind = "control-plane" + control_plane_geo = "us" + control_plane_id = konnect_gateway_control_plane.test_cp.id + } + } + } + `) + require.NoError(t, err) + + fullConfig := builder. + Upsert(cp). + Upsert(addon). + Build() + + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: providerFactoryBeta, + ExternalProviders: map[string]resource.ExternalProvider{ + "konnect": {Source: "kong/konnect"}, + }, + Steps: []resource.TestStep{ + { + Config: fullConfig, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction( + "konnect_cloud_gateway_add_on.my_addon", + plancheck.ResourceActionCreate, + ), + }, + }, + }, + { + Config: fullConfig, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectEmptyPlan(), + }, + }, + }, + }, + }) + }) +} From 9da8479ccd6eeb4a2c526ea906733687542d1695 Mon Sep 17 00:00:00 2001 From: shivay Date: Wed, 25 Feb 2026 13:44:52 +0530 Subject: [PATCH 4/4] fix: resolved review comments on test --- tests/resources/cloud_gateway_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/resources/cloud_gateway_test.go b/tests/resources/cloud_gateway_test.go index fd8e5001..894b5091 100644 --- a/tests/resources/cloud_gateway_test.go +++ b/tests/resources/cloud_gateway_test.go @@ -35,11 +35,8 @@ func TestCloudGatewayAddOn(t *testing.T) { config = { managed_cache = { - kind = "managed-cache.v0" - capacity_config = { tiered = { - kind = "tiered" tier = "small" } } @@ -77,6 +74,9 @@ func TestCloudGatewayAddOn(t *testing.T) { ), }, }, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("konnect_cloud_gateway_add_on.my_addon", "name", "tf-test-add-on"), + ), }, { Config: fullConfig,