diff --git a/.copywrite.hcl b/.copywrite.hcl
deleted file mode 100644
index b26d46f2..00000000
--- a/.copywrite.hcl
+++ /dev/null
@@ -1,24 +0,0 @@
-# NOTE: This file is for HashiCorp specific licensing automation and can be deleted after creating a new repo with this template.
-schema_version = 1
-
-project {
- license = "Apache-2.0"
- copyright_year = 2025
-
- header_ignore = [
- # internal catalog metadata (prose)
- "META.d/**/*.yaml",
-
- # examples used within documentation (prose)
- "examples/**",
-
- # GitHub issue template configuration
- ".github/ISSUE_TEMPLATE/*.yml",
-
- # golangci-lint tooling configuration
- ".golangci.yml",
-
- # GoReleaser tooling configuration
- ".goreleaser.yml",
- ]
-}
diff --git a/.github/actions/acc_test/README.md b/.github/actions/acc_test/README.md
new file mode 100644
index 00000000..c3484cf2
--- /dev/null
+++ b/.github/actions/acc_test/README.md
@@ -0,0 +1 @@
+# acceptance test action
diff --git a/.github/actions/acc_test/action.yaml b/.github/actions/acc_test/action.yaml
new file mode 100644
index 00000000..828e1011
--- /dev/null
+++ b/.github/actions/acc_test/action.yaml
@@ -0,0 +1,114 @@
+name: Acceptance Testing
+description: "Acceptance Testing pipeline"
+
+inputs:
+ go-version:
+ description: "go version to install"
+ default: '1.25'
+ required: true
+
+ project_id:
+ description: "STACKIT project ID for tests"
+ required: true
+
+ region:
+ description: "STACKIT region for tests"
+ default: 'eu01'
+ required: true
+
+ service_account_json:
+ description: "STACKIT service account JSON file contents"
+ required: true
+
+ test_file:
+ description: "testfile to run"
+ default: ''
+
+outputs:
+ random-number:
+ description: "Random number"
+ value: ${{ steps.random-number-generator.outputs.random-number }}
+
+runs:
+ using: "composite"
+ steps:
+ - name: Random Number Generator
+ id: random-number-generator
+ run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
+ shell: bash
+
+ - name: Install needed tools
+ shell: bash
+ run: |
+ set -e
+ apt-get -y -qq update
+ apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget
+
+ - name: Setup JAVA
+ uses: actions/setup-java@v5
+ with:
+ distribution: 'temurin' # See 'Supported distributions' for available options
+ java-version: '21'
+
+ - name: Install Go ${{ inputs.go-version }}
+ uses: actions/setup-go@v6
+ with:
+ go-version: ${{ inputs.go-version }}
+ check-latest: true
+ go-version-file: 'go.mod'
+
+ - name: Install go tools
+ shell: bash
+ run: |
+ set -e
+ go mod download
+ go install golang.org/x/tools/cmd/goimports@latest
+ go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2
+ go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.24.0
+
+ - name: Prepare pkg_gen directory
+ shell: bash
+ run: |
+ go run cmd/main.go build -p
+
+ - name: Run acceptance test file
+ if: ${{ inputs.test_file != '' }}
+ shell: bash
+ run: |
+ echo "Running acceptance tests for the terraform provider"
+ echo "${STACKIT_SERVICE_ACCOUNT_JSON}" > ~/.service_account.json
+ cd stackit
+ TF_ACC=1 \
+ TF_ACC_PROJECT_ID=${TF_ACC_PROJECT_ID} \
+ TF_ACC_REGION=${TF_ACC_REGION} \
+ go test ${{ inputs.test_file }} -count=1 -timeout=30m
+ env:
+ STACKIT_SERVICE_ACCOUNT_JSON: ${{ inputs.service_account_json }}
+ TF_PROJECT_ID: ${{ inputs.project_id }}
+ TF_ACC_REGION: ${{ inputs.region }}
+ # TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL: ${{ secrets.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL }}
+ # TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN }}
+ # TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID: ${{ secrets.TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID }}
+ # TF_ACC_TEST_PROJECT_PARENT_UUID: ${{ secrets.TF_ACC_TEST_PROJECT_PARENT_UUID }}
+ # TF_ACC_TEST_PROJECT_USER_EMAIL: ${{ secrets.TF_ACC_TEST_PROJECT_USER_EMAIL }}
+
+ - name: Run acceptance tests
+ if: ${{ inputs.test_file == '' }}
+ shell: bash
+ run: |
+ echo "Running acceptance tests for the terraform provider"
+ echo "${STACKIT_SERVICE_ACCOUNT_JSON}" > ~/.service_account.json
+ cd stackit
+ TF_ACC=1 \
+ TF_ACC_PROJECT_ID=${TF_ACC_PROJECT_ID} \
+ TF_ACC_REGION=${TF_ACC_REGION} \
+ go test ./... -count=1 -timeout=30m
+ env:
+ STACKIT_SERVICE_ACCOUNT_JSON: ${{ inputs.service_account_json }}
+ TF_PROJECT_ID: ${{ inputs.project_id }}
+ TF_ACC_REGION: ${{ inputs.region }}
+ # TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL: ${{ secrets.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL }}
+ # TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN }}
+ # TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID: ${{ secrets.TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID }}
+ # TF_ACC_TEST_PROJECT_PARENT_UUID: ${{ secrets.TF_ACC_TEST_PROJECT_PARENT_UUID }}
+ # TF_ACC_TEST_PROJECT_USER_EMAIL: ${{ secrets.TF_ACC_TEST_PROJECT_USER_EMAIL }}
diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml
index c5e5becd..1fa83ee1 100644
--- a/.github/actions/build/action.yaml
+++ b/.github/actions/build/action.yaml
@@ -1,18 +1,63 @@
-# Copyright (c) STACKIT
-
name: Build
description: "Build pipeline"
inputs:
go-version:
description: "Go version to install"
+ default: '1.25'
required: true
+ java-distribution:
+ description: "JAVA distribution to use (default: temurin)"
+ default: 'temurin'
+ java-version:
+ description: "JAVA version to use (default: 21)"
+ default: '21'
+
runs:
using: "composite"
steps:
+ - name: Install needed tools
+ shell: bash
+ run: |
+ set -e
+ apt-get -y -qq update
+ apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget
+
+
- name: Install Go ${{ inputs.go-version }}
- uses: actions/setup-go@v5
+ uses: actions/setup-go@v6
with:
go-version: ${{ inputs.go-version }}
- - name: Install project tools and dependencies
+ check-latest: true
+ go-version-file: 'go.mod'
+
+ - name: Install go tools
shell: bash
- run: make project-tools
\ No newline at end of file
+ run: |
+ set -e
+ go install golang.org/x/tools/cmd/goimports@latest
+ go install github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework@latest
+ go install github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi@latest
+ go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.24.0
+
+
+ - name: Setup JAVA ${{ inputs.java-distribution }} ${{ inputs.go-version }}
+ uses: actions/setup-java@v5
+ with:
+ distribution: ${{ inputs.java-distribution }} # See 'Supported distributions' for available options
+ java-version: ${{ inputs.java-version }}
+
+ - name: Checkout
+ uses: actions/checkout@v6
+
+ - name: Run build pkg directory
+ shell: bash
+ run: |
+ set -e
+ go run cmd/main.go build
+
+
+ - name: Run make to build app
+ shell: bash
+ run: |
+ set -e
+ make build
diff --git a/.github/actions/setup-cache-go/action.yaml b/.github/actions/setup-cache-go/action.yaml
new file mode 100644
index 00000000..81f0d17d
--- /dev/null
+++ b/.github/actions/setup-cache-go/action.yaml
@@ -0,0 +1,71 @@
+name: 'Setup Go and cache dependencies'
+author: 'Forgejo authors, Marcel S. Henselin'
+description: |
+ Wrap the setup-go with improved dependency caching.
+
+inputs:
+ username:
+ description: 'User for which to manage the dependency cache'
+ default: root
+
+ go-version:
+ description: "go version to install"
+ default: '1.25'
+ required: true
+
+runs:
+ using: "composite"
+ steps:
+ - name: "Install zstd for faster caching"
+ shell: bash
+ run: |
+ apt-get update -qq
+ apt-get -q install -qq -y zstd
+
+ - name: "Set up Go using setup-go"
+ uses: https://code.forgejo.org/actions/setup-go@v6
+ id: go-version
+ with:
+ go-version: ${{ inputs.go-version }}
+ check-latest: true # Always check for the latest patch release
+ # go-version-file: "go.mod"
+ # do not cache dependencies, we do this manually
+ cache: false
+
+ - name: "Get go environment information"
+ shell: bash
+ id: go-environment
+ run: |
+ chmod 755 $HOME # ensure ${RUN_AS_USER} has permission when go is located in $HOME
+ export GOROOT="$(go env GOROOT)"
+ echo "modcache=$(su ${RUN_AS_USER} -c '${GOROOT}/bin/go env GOMODCACHE')" >> "$GITHUB_OUTPUT"
+ echo "cache=$(su ${RUN_AS_USER} -c '${GOROOT}/bin/go env GOCACHE')" >> "$GITHUB_OUTPUT"
+ env:
+ RUN_AS_USER: ${{ inputs.username }}
+ GO_VERSION: ${{ steps.go-version.outputs.go-version }}
+
+ - name: "Create cache folders with correct permissions (for non-root users)"
+ shell: bash
+ if: inputs.username != 'root'
+ # when the cache is restored, only the permissions of the last part are restored
+ # so assuming that /home/user exists and we are restoring /home/user/go/pkg/mod,
+ # both folders will have the correct permissions, but
+ # /home/user/go and /home/user/go/pkg might be owned by root
+ run: |
+ su ${RUN_AS_USER} -c 'mkdir -p "${MODCACHE_DIR}" "${CACHE_DIR}"'
+ env:
+ RUN_AS_USER: ${{ inputs.username }}
+ MODCACHE_DIR: ${{ steps.go-environment.outputs.modcache }}
+ CACHE_DIR: ${{ steps.go-environment.outputs.cache }}
+
+ - name: "Restore Go dependencies from cache or mark for later caching"
+ id: cache-deps
+ uses: https://code.forgejo.org/actions/cache@v5
+ with:
+ key: setup-cache-go-deps-${{ runner.os }}-${{ inputs.username }}-${{ steps.go-version.outputs.go_version }}-${{ hashFiles('go.sum', 'go.mod') }}
+ restore-keys: |
+ setup-cache-go-deps-${{ runner.os }}-${{ inputs.username }}-${{ steps.go-version.outputs.go_version }}-
+ setup-cache-go-deps-${{ runner.os }}-${{ inputs.username }}-
+ path: |
+ ${{ steps.go-environment.outputs.modcache }}
+ ${{ steps.go-environment.outputs.cache }}
diff --git a/.github/docs/contribution-guide/resource.go b/.github/docs/contribution-guide/resource.go
index 7dedfa12..a2934137 100644
--- a/.github/docs/contribution-guide/resource.go
+++ b/.github/docs/contribution-guide/resource.go
@@ -14,10 +14,10 @@ import (
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- fooUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/foo/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ fooUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/foo/utils"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
"github.com/stackitcloud/stackit-sdk-go/services/foo" // Import service "foo" from the STACKIT SDK for Go
"github.com/stackitcloud/stackit-sdk-go/services/foo/wait" // Import service "foo" waiters from the STACKIT SDK for Go (in case the service API has asynchronous endpoints)
diff --git a/.github/docs/contribution-guide/utils/util.go b/.github/docs/contribution-guide/utils/util.go
index 61ee7257..8912f228 100644
--- a/.github/docs/contribution-guide/utils/util.go
+++ b/.github/docs/contribution-guide/utils/util.go
@@ -9,8 +9,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/stackitcloud/stackit-sdk-go/core/config"
"github.com/stackitcloud/stackit-sdk-go/services/foo"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
)
func ConfigureClient(ctx context.Context, providerData *core.ProviderData, diags *diag.Diagnostics) *foo.APIClient {
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index bbd69400..e747e730 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -2,10 +2,19 @@ name: CI Workflow
on:
pull_request:
+ branches:
+ - alpha
+ - main
workflow_dispatch:
+ schedule:
+ # every sunday at 00:00
+ # - cron: '0 0 * * 0'
+ # every day at 00:00
+ - cron: '0 0 * * *'
push:
branches:
- - main
+ - '!main'
+ - '!alpha'
env:
GO_VERSION: "1.25"
@@ -13,12 +22,187 @@ env:
CODE_COVERAGE_ARTIFACT_NAME: "code-coverage"
jobs:
- main:
- name: CI
+ runner_test:
+ name: "Test STACKIT runner"
+ runs-on: stackit-docker
+ steps:
+ - name: Install needed tools
+ run: |
+ apt-get -y -qq update
+ apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget
+
+ - name: Setup Go
+ uses: actions/setup-go@v6
+ with:
+ go-version: ${{ env.GO_VERSION }}
+
+ - name: Install go tools
+ run: |
+ go install golang.org/x/tools/cmd/goimports@latest
+ go install github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework@latest
+ go install github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi@latest
+
+ - name: Setup JAVA
+ uses: actions/setup-java@v5
+ with:
+ distribution: 'temurin' # See 'Supported distributions' for available options
+ java-version: '21'
+
+ - name: Checkout
+ uses: actions/checkout@v6
+
+ - name: Run build pkg directory
+ run: |
+ go run cmd/main.go build
+
+ publish_test:
+ name: "Test readiness for publishing provider"
+ needs: config
runs-on: ubuntu-latest
+ permissions:
+ actions: read # Required to identify workflow run.
+ checks: write # Required to add status summary.
+ contents: read # Required to checkout repository.
+ pull-requests: write # Required to add PR comment.
+ steps:
+ - name: Install needed tools
+ run: |
+ apt-get -y -qq update
+ apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget
+
+ - name: Setup Go
+ uses: actions/setup-go@v6
+ with:
+ go-version: ${{ env.GO_VERSION }}
+
+ - name: Install go tools
+ run: |
+ go install golang.org/x/tools/cmd/goimports@latest
+ go install github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework@latest
+ go install github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi@latest
+
+ - name: Setup JAVA
+ uses: actions/setup-java@v5
+ with:
+ distribution: 'temurin' # See 'Supported distributions' for available options
+ java-version: '21'
+
+ - name: Checkout
+ uses: actions/checkout@v6
+
+ - name: Run build pkg directory
+ run: |
+ go run cmd/main.go build
+
+ - name: Set up s3cfg
+ run: |
+ cat <<'EOF' >> ~/.s3cfg
+ [default]
+ host_base = https://object.storage.eu01.onstackit.cloud
+ host_bucket = https://%(bucket).object.storage.eu01.onstackit.cloud
+ check_ssl_certificate = False
+ access_key = ${{ secrets.S3_ACCESS_KEY }}
+ secret_key = ${{ secrets.S3_SECRET_KEY }}
+ EOF
+
+ - name: Import GPG key
+ run: |
+ echo "${{ secrets.PRIVATE_KEY_PEM }}" > ~/private.key.pem
+ gpg --import ~/private.key.pem
+ rm ~/private.key.pem
+
+ - name: Run GoReleaser with SNAPSHOT
+ id: goreleaser
+ env:
+ GITHUB_TOKEN: ${{ env.FORGEJO_TOKEN }}
+ GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
+ uses: goreleaser/goreleaser-action@v6
+ with:
+ args: release --skip publish --clean --snapshot
+
+ - name: Prepare key file
+ run: |
+ echo "${{ secrets.PUBLIC_KEY_PEM }}" >public_key.pem
+
+ - name: Prepare provider directory structure
+ run: |
+ VERSION=$(jq -r .version < dist/metadata.json)
+ go run cmd/main.go \
+ publish \
+ --namespace=mhenselin \
+ --providerName=stackitprivatepreview \
+ --repoName=terraform-provider-stackitprivatepreview \
+ --domain=tfregistry.sysops.stackit.rocks \
+ --gpgFingerprint="${{ secrets.GPG_FINGERPRINT }}" \
+ --gpgPubKeyFile=public_key.pem \
+ --version=${VERSION}
+
+ testing:
+ name: CI run tests
+ runs-on: ubuntu-latest
+ needs: config
+ env:
+ TF_ACC_PROJECT_ID: ${{ vars.TF_ACC_PROJECT_ID }}
+ TF_ACC_REGION: ${{ vars.TF_ACC_REGION }}
+ TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL: ${{ vars.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL }}
+ TF_ACC_SERVICE_ACCOUNT_FILE: "~/service_account.json"
steps:
- name: Checkout
- uses: actions/checkout@v4
+ uses: actions/checkout@v6
+
+ - name: Build
+ uses: ./.github/actions/build
+ with:
+ go-version: ${{ env.GO_VERSION }}
+
+ - name: Setup Terraform
+ uses: hashicorp/setup-terraform@v2
+ with:
+ terraform_wrapper: false
+
+ - name: Create service account json file
+ if: ${{ github.event_name == 'pull_request' }}
+ run: |
+ echo "${{ secrets.TF_ACC_SERVICE_ACCOUNT_JSON }}" >~/service_account.json
+
+ - name: Run go mod tidy
+ if: ${{ github.event_name == 'pull_request' }}
+ run: go mod tidy
+
+ - name: Testing
+ run: make test
+
+ - name: Acceptance Testing
+ env:
+ TF_ACC: "1"
+ if: ${{ github.event_name == 'pull_request' }}
+ run: make test-acceptance-tf
+
+ - name: Check coverage threshold
+ shell: bash
+ run: |
+ make coverage
+ COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
+ echo "Coverage: $COVERAGE%"
+ if (( $(echo "$COVERAGE < 80" | bc -l) )); then
+ echo "Coverage is below 80%"
+ # exit 1
+ fi
+
+ - name: Archive code coverage results
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{ env.CODE_COVERAGE_ARTIFACT_NAME }}
+ path: "stackit/${{ env.CODE_COVERAGE_FILE_NAME }}"
+
+ main:
+ if: ${{ github.event_name != 'schedule' }}
+ name: CI run build and linting
+ runs-on: ubuntu-latest
+ needs: config
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v6
- name: Build
uses: ./.github/actions/build
@@ -42,29 +226,45 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
- version: v2.7
+ version: v2.9
args: --config=golang-ci.yaml --allow-parallel-runners --timeout=5m
+ continue-on-error: true
- - name: Lint
+ - name: Linting
run: make lint
+ continue-on-error: true
- - name: Test
- run: make test
-
- - name: Archive code coverage results
- uses: actions/upload-artifact@v4
- with:
- name: ${{ env.CODE_COVERAGE_ARTIFACT_NAME }}
- path: "stackit/${{ env.CODE_COVERAGE_FILE_NAME }}"
+# - name: Testing
+# run: make test
+#
+# - name: Acceptance Testing
+# if: ${{ github.event_name == 'pull_request' }}
+# run: make test-acceptance-tf
+#
+# - name: Check coverage threshold
+# shell: bash
+# run: |
+# make coverage
+# COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
+# echo "Coverage: $COVERAGE%"
+# if (( $(echo "$COVERAGE < 80" | bc -l) )); then
+# echo "Coverage is below 80%"
+# # exit 1
+# fi
+# - name: Archive code coverage results
+# uses: actions/upload-artifact@v4
+# with:
+# name: ${{ env.CODE_COVERAGE_ARTIFACT_NAME }}
+# path: "stackit/${{ env.CODE_COVERAGE_FILE_NAME }}"
config:
+ if: ${{ github.event_name != 'schedule' }}
name: Check GoReleaser config
- if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v4
+ uses: actions/checkout@v6
- name: Check GoReleaser
uses: goreleaser/goreleaser-action@v6
diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml
index 53ab6dff..b86dba35 100644
--- a/.github/workflows/publish.yaml
+++ b/.github/workflows/publish.yaml
@@ -1,5 +1,7 @@
name: Publish
+run-name: Publish by @${{ github.actor }}
+
on:
workflow_dispatch:
push:
@@ -14,7 +16,7 @@ env:
jobs:
config:
name: Check GoReleaser config
- if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
+ if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -27,7 +29,7 @@ jobs:
publish:
name: "Publish provider"
- if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
+ if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: config
runs-on: ubuntu-latest
permissions:
@@ -41,10 +43,7 @@ jobs:
apt-get -y -qq update
apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget
- - name: Checkout
- uses: actions/checkout@v6
-
- - name: Install Go ${{ env.GO_VERSION }}
+ - name: Setup Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
@@ -55,13 +54,20 @@ jobs:
go install github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework@latest
go install github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi@latest
- - uses: actions/setup-java@v5
+ - name: Setup JAVA
+ uses: actions/setup-java@v5
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21'
+ - name: Checkout
+ uses: actions/checkout@v6
+
- name: Run build pkg directory
run: |
+ set -e
+ mkdir -p generated/services
+ mkdir -p generated/internal/services
go run cmd/main.go build
- name: Set up s3cfg
@@ -77,13 +83,15 @@ jobs:
- name: Import GPG key
run: |
- gpg --import private.key
+ echo "${{ secrets.PRIVATE_KEY_PEM }}" > ~/private.key.pem
+ gpg --import ~/private.key.pem
+ rm ~/private.key.pem
- - name: Run GoReleaser
+ - name: Run GoReleaser with SNAPSHOT
if: github.event_name == 'workflow_dispatch'
id: goreleaser
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_TOKEN: ${{ env.FORGEJO_TOKEN }}
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
uses: goreleaser/goreleaser-action@v6
with:
@@ -93,7 +101,7 @@ jobs:
if: github.event_name != 'workflow_dispatch'
id: goreleaser
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_TOKEN: ${{ env.FORGEJO_TOKEN }}
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
uses: goreleaser/goreleaser-action@v6
with:
@@ -101,7 +109,7 @@ jobs:
- name: Prepare key file
run: |
- echo $(echo ${{ secrets.KEY_FILE_B64 }} | base64 -d) >public_key.pem
+ echo "${{ secrets.PUBLIC_KEY_PEM }}" >public_key.pem
- name: Prepare provider directory structure
run: |
@@ -112,7 +120,7 @@ jobs:
--providerName=stackitprivatepreview \
--repoName=terraform-provider-stackitprivatepreview \
--domain=tfregistry.sysops.stackit.rocks \
- --gpgFingerprint=${{ secrets.GPG_FINGERPRINT }} \
+ --gpgFingerprint="${{ secrets.GPG_FINGERPRINT }}" \
--gpgPubKeyFile=public_key.pem \
--version=${VERSION}
@@ -122,3 +130,16 @@ jobs:
cd release/
s3cmd put --recursive v1 s3://terraform-provider-privatepreview/
s3cmd put --recursive .well-known s3://terraform-provider-privatepreview/
+
+ - name: Import SSH key
+ run: |
+ mkdir -p ~/.ssh
+ echo "${{ secrets.DOCS_UPLOAD_SSH_KEY }}" > ~/.ssh/id_ed25519
+ chmod 0600 ~/.ssh/id_ed25519
+
+ - name: Upload docs via scp
+ run: |
+ set -e
+ ssh -o StrictHostKeyChecking=no ubuntu@${{ vars.DOCS_SERVER_IP }} 'rm -rf /srv/www/docs'
+ echo "${{ github.ref_name }}" >docs/_version.txt
+ scp -o StrictHostKeyChecking=no -r docs ubuntu@${{ vars.DOCS_SERVER_IP }}:/srv/www/
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 585d0ba3..7d7106ed 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -4,9 +4,9 @@ name: Release
# This GitHub action creates a release when a tag that matches the pattern
# "v*" (e.g. v0.1.0) is created.
on:
- push:
- tags:
- - "v*"
+# push:
+# tags:
+# - "v*"
workflow_dispatch:
# Releases need permissions to read and write the repository contents.
@@ -18,7 +18,7 @@ jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
# Allow goreleaser to access older tag information.
fetch-depth: 0
diff --git a/.github/workflows/renovate.yaml b/.github/workflows/renovate.yaml
index 12454b9f..90adebe6 100644
--- a/.github/workflows/renovate.yaml
+++ b/.github/workflows/renovate.yaml
@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v4
+ uses: actions/checkout@v6
- name: Self-hosted Renovate
uses: renovatebot/github-action@v41.0.0
with:
diff --git a/.github/workflows/runnerstats.yaml b/.github/workflows/runnerstats.yaml
new file mode 100644
index 00000000..08190d4c
--- /dev/null
+++ b/.github/workflows/runnerstats.yaml
@@ -0,0 +1,29 @@
+name: Runner stats
+
+on:
+ workflow_dispatch:
+
+jobs:
+ stats-own:
+ name: "Get own runner stats"
+ runs-on: ubuntu-latest
+ steps:
+ - name: Install needed tools
+ run: |
+ apt-get -y -qq update
+ apt-get -y -qq install inxi
+
+ - name: Show stats
+ run: inxi -c 0
+
+ stats-stackit:
+ name: "Get STACKIT runner stats"
+ runs-on: stackit-docker
+ steps:
+ - name: Install needed tools
+ run: |
+ apt-get -y -qq update
+ apt-get -y -qq install inxi
+
+ - name: Show stats
+ run: inxi -c 0
diff --git a/.github/workflows/tf-acc-test.yaml b/.github/workflows/tf-acc-test.yaml
index a8e6a53f..3b4fb061 100644
--- a/.github/workflows/tf-acc-test.yaml
+++ b/.github/workflows/tf-acc-test.yaml
@@ -7,21 +7,17 @@ on:
workflow_dispatch:
jobs:
- main:
+ acc_test:
name: Acceptance Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v4
- - name: Install project tools and dependencies
- run: make project-tools
- - name: Run tests
- run: |
- make test-acceptance-tf TF_ACC_PROJECT_ID=$${{ secrets.TF_ACC_PROJECT_ID }} TF_ACC_ORGANIZATION_ID=$${{ secrets.TF_ACC_ORGANIZATION_ID }} TF_ACC_REGION="eu01"
- env:
- STACKIT_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TF_ACC_SERVICE_ACCOUNT_TOKEN }}
- TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL: ${{ secrets.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL }}
- TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN }}
- TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID: ${{ secrets.TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID }}
- TF_ACC_TEST_PROJECT_PARENT_UUID: ${{ secrets.TF_ACC_TEST_PROJECT_PARENT_UUID }}
- TF_ACC_TEST_PROJECT_USER_EMAIL: ${{ secrets.TF_ACC_TEST_PROJECT_USER_EMAIL }}
+ uses: actions/checkout@v6
+
+ - name: Run Test
+ uses: ./.github/actions/acc_test
+ with:
+ go-version: ${{ env.GO_VERSION }}
+ project_id: ${{ vars.TEST_PROJECT_ID }}
+ region: 'eu01'
+ service_account_json: ${{ secrets.TF_ACC_SERVICE_ACCOUNT_JSON }}
diff --git a/.gitignore b/.gitignore
index e376491c..1dac2ea3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,9 +15,9 @@ bin/
**/terraform.tfstate**
.terraform.lock.hcl
.terraform.tfstate.lock.info
-main.tf
-example.tf
-index.tf
+**/config.tfrc
+**/variables.tf
+**/service_account.json
# Test binary, built with `go test -c`
*.test
@@ -38,3 +38,13 @@ stackit/internal/services/iaas/test-512k.img
# Test coverage reports
coverage.out
coverage.html
+generated
+stackit-sdk-generator
+dist
+
+.secrets
+
+pkg_gen
+/release/
+.env
+**/.env
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
index 55baab60..e0aafe37 100644
--- a/.goreleaser.yaml
+++ b/.goreleaser.yaml
@@ -5,6 +5,8 @@
# behavior.
version: 2
+project_name: terraform-provider-stackitprivatepreview
+
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
@@ -29,14 +31,16 @@ builds:
ignore:
- goos: darwin
goarch: '386'
+ - goos: windows
+ goarch: arm
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- formats: [ 'zip' ]
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
- extra_files:
- - glob: 'terraform-registry-manifest.json'
- name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
+# extra_files:
+# - glob: 'terraform-registry-manifest.json'
+# name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
diff --git a/Makefile b/Makefile
index cdcc36b2..680cf020 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@
ROOT_DIR ?= $(shell git rev-parse --show-toplevel)
SCRIPTS_BASE ?= $(ROOT_DIR)/scripts
+VERSION ?= ${VER}
# SETUP AND TOOL INITIALIZATION TASKS
project-help:
@@ -11,9 +12,10 @@ project-tools:
# LINT
lint-golangci-lint:
@echo "Linting with golangci-lint"
- @$(SCRIPTS_BASE)/lint-golangci-lint.sh
+ @go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint run --fix --config golang-ci.yaml
-lint-tf:
+
+lint-tf:
@echo "Linting terraform files"
@terraform fmt -check -diff -recursive
@@ -22,10 +24,11 @@ lint: lint-golangci-lint lint-tf
# DOCUMENTATION GENERATION
generate-docs:
@echo "Generating documentation with tfplugindocs"
+
@$(SCRIPTS_BASE)/tfplugindocs.sh
build:
- @go build -o bin/terraform-provider-stackitalpha
+ @go build -o bin/terraform-provider-stackitprivatepreview
fmt:
@gofmt -s -w .
@@ -33,15 +36,16 @@ fmt:
@terraform fmt -diff -recursive
# TEST
+.PHONY: test coverage
test:
@echo "Running tests for the terraform provider"
- @cd $(ROOT_DIR)/stackit && go test ./... -count=1 -coverprofile=coverage.out && cd $(ROOT_DIR)
+ @cd $(ROOT_DIR)/stackit && go test -timeout 0 ./... -count=1 -coverprofile=../coverage.out && cd $(ROOT_DIR)
# Test coverage
coverage:
@echo ">> Creating test coverage report for the terraform provider"
- @cd $(ROOT_DIR)/stackit && (go test ./... -count=1 -coverprofile=coverage.out || true) && cd $(ROOT_DIR)
- @cd $(ROOT_DIR)/stackit && go tool cover -html=coverage.out -o coverage.html && cd $(ROOT_DIR)
+ @cd $(ROOT_DIR)/stackit && (go test -timeout 0 ./... -count=1 -coverprofile=../coverage.out || true) && cd $(ROOT_DIR)
+ @cd $(ROOT_DIR)/stackit && go tool cover -html=../coverage.out -o ../coverage.html && cd $(ROOT_DIR)
test-acceptance-tf:
@if [ -z $(TF_ACC_PROJECT_ID) ]; then echo "Input TF_ACC_PROJECT_ID missing"; exit 1; fi
@@ -57,3 +61,11 @@ test-acceptance-tf:
TF_ACC_REGION=$(TF_ACC_REGION) \
go test ./... -count=1 -timeout=30m && \
cd $(ROOT_DIR)
+
+publish: build
+ifeq ($(strip $(VERSION)),)
+ @echo "please call like this: VER=0.1.0 make publish"
+else
+ @echo "version: $(VERSION)"
+endif
+
diff --git a/README.md b/README.md
index 1da34359..ab79f28e 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,14 @@
-

-
-
-# STACKIT Terraform Provider
+# STACKIT Terraform Provider
(PRIVATE PREVIEW)
-[](https://goreportcard.com/report/github.com/stackitcloud/terraform-provider-stackit) [](https://registry.terraform.io/providers/stackitcloud/stackit/latest)  [](https://www.apache.org/licenses/LICENSE-2.0)
+[](https://registry.terraform.io/providers/stackitcloud/stackit/latest)  [](https://www.apache.org/licenses/LICENSE-2.0)
-This project is the official [Terraform Provider](https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs) for [STACKIT](https://www.stackit.de/en/), which allows you to manage STACKIT resources through Terraform.
+This project is the **NOT** official [Terraform Provider](https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs) for [STACKIT](https://www.stackit.de/en/)!
+
+This a **private preview only**, which allows you to manage STACKIT resources through Terraform.
## Getting Started
@@ -18,20 +17,22 @@ To install the [STACKIT Terraform Provider](https://registry.terraform.io/provid
```hcl
terraform {
required_providers {
- stackit = {
- source = "stackitcloud/stackit"
- version = "X.X.X"
+ stackitprivatepreview = {
+ source = "tfregistry.sysops.stackit.rocks/mhenselin/stackitprivatepreview"
+ version = "= 0.0.5-alpha"
}
}
}
-provider "stackit" {
+provider "stackitprivatepreview" {
# Configuration options
}
```
Check one of the examples in the [examples](examples/) folder.
+TODO: revise the following sections
+
## Authentication
To authenticate, you will need a [service account](https://docs.stackit.cloud/platform/access-and-identity/service-accounts/). Create it in the [STACKIT Portal](https://portal.stackit.cloud/) and assign the necessary permissions to it, e.g. `project.owner`. There are multiple ways to authenticate:
diff --git a/cmd/cmd/build/build.go b/cmd/cmd/build/build.go
new file mode 100644
index 00000000..7b11f214
--- /dev/null
+++ b/cmd/cmd/build/build.go
@@ -0,0 +1,1073 @@
+package build
+
+import (
+ "bufio"
+ "bytes"
+ "errors"
+ "fmt"
+ "go/ast"
+ "go/parser"
+ "go/token"
+ "io"
+ "log"
+ "log/slog"
+ "os"
+ "os/exec"
+ "path"
+ "path/filepath"
+ "regexp"
+ "strconv"
+ "strings"
+ "text/template"
+
+ "github.com/ldez/go-git-cmd-wrapper/v2/clone"
+ "github.com/ldez/go-git-cmd-wrapper/v2/git"
+)
+
+const (
+ OAS_REPO_NAME = "stackit-api-specifications"
+ OAS_REPO = "https://github.com/stackitcloud/stackit-api-specifications.git"
+ GEN_REPO_NAME = "stackit-sdk-generator"
+ GEN_REPO = "https://github.com/stackitcloud/stackit-sdk-generator.git"
+)
+
+type version struct {
+ verString string
+ major int
+ minor int
+}
+
+type Builder struct {
+ SkipClone bool
+ SkipCleanup bool
+ PackagesOnly bool
+}
+
+func (b *Builder) Build() error {
+ slog.Info("Starting Builder")
+ if b.PackagesOnly {
+ slog.Info(" >>> only generating pkg_gen <<<")
+ }
+
+ root, err := getRoot()
+ if err != nil {
+ log.Fatal(err)
+ }
+ if root == nil || *root == "" {
+ return fmt.Errorf("unable to determine root directory from git")
+ }
+ slog.Info(" ... using root directory", "dir", *root)
+
+ if !b.PackagesOnly {
+ slog.Info(" ... Checking needed commands available")
+ err := checkCommands([]string{})
+ if err != nil {
+ return err
+ }
+ }
+
+ if !b.SkipCleanup {
+ slog.Info("Cleaning up old packages directory")
+ err = os.RemoveAll(path.Join(*root, "pkg_gen"))
+ if err != nil {
+ return err
+ }
+ }
+
+ if !b.SkipCleanup && !b.PackagesOnly {
+ slog.Info("Cleaning up old packages directory")
+ err = os.RemoveAll(path.Join(*root, "pkg_gen"))
+ if err != nil {
+ return err
+ }
+ }
+
+ slog.Info("Creating generator dir", "dir", fmt.Sprintf("%s/%s", *root, GEN_REPO_NAME))
+ genDir := path.Join(*root, GEN_REPO_NAME)
+ if !b.SkipClone {
+ err = createGeneratorDir(GEN_REPO, genDir, b.SkipClone)
+ if err != nil {
+ return err
+ }
+ }
+
+ slog.Info("Creating oas repo dir", "dir", fmt.Sprintf("%s/%s", *root, OAS_REPO_NAME))
+ repoDir, err := createRepoDir(genDir, OAS_REPO, OAS_REPO_NAME, b.SkipClone)
+ if err != nil {
+ return fmt.Errorf("%s", err.Error())
+ }
+
+ slog.Info("Retrieving versions from subdirs")
+ // TODO - major
+ verMap, err := getVersions(repoDir)
+ if err != nil {
+ return fmt.Errorf("%s", err.Error())
+ }
+
+ slog.Info("Reducing to only latest or highest")
+ res, err := getOnlyLatest(verMap)
+ if err != nil {
+ return fmt.Errorf("%s", err.Error())
+ }
+
+ slog.Info("Creating OAS dir")
+ err = os.MkdirAll(path.Join(genDir, "oas"), 0o755) //nolint:gosec // this dir is not sensitive, so we can use 0755
+ if err != nil {
+ return err
+ }
+
+ slog.Info("Copying OAS files")
+ for service, item := range res {
+ baseService := strings.TrimSuffix(service, "alpha")
+ baseService = strings.TrimSuffix(baseService, "beta")
+ itemVersion := fmt.Sprintf("v%d%s", item.major, item.verString)
+ if item.minor != 0 {
+ itemVersion = itemVersion + "" + strconv.Itoa(item.minor)
+ }
+ srcFile := path.Join(
+ repoDir,
+ "services",
+ baseService,
+ itemVersion,
+ fmt.Sprintf("%s.json", baseService),
+ )
+ dstFile := path.Join(genDir, "oas", fmt.Sprintf("%s.json", service))
+ _, err = copyFile(srcFile, dstFile)
+ if err != nil {
+ return fmt.Errorf("%s", err.Error())
+ }
+ }
+
+ slog.Info("Changing dir", "dir", genDir)
+ err = os.Chdir(genDir)
+ if err != nil {
+ return err
+ }
+
+ slog.Info("Calling make", "command", "generate-go-sdk")
+ cmd := exec.Command("make", "generate-go-sdk")
+ var stdOut, stdErr bytes.Buffer
+ cmd.Stdout = &stdOut
+ cmd.Stderr = &stdErr
+
+ if err = cmd.Start(); err != nil {
+ slog.Error("cmd.Start", "error", err)
+ return err
+ }
+
+ if err = cmd.Wait(); err != nil {
+ var exitErr *exec.ExitError
+ if errors.As(err, &exitErr) {
+ slog.Error(
+ "cmd.Wait",
+ "code",
+ exitErr.ExitCode(),
+ "error",
+ err,
+ "stdout",
+ stdOut.String(),
+ "stderr",
+ stdErr.String(),
+ )
+ return fmt.Errorf("%s", stdErr.String())
+ }
+ if err != nil {
+ slog.Error("cmd.Wait", "err", err)
+ return err
+ }
+ }
+
+ slog.Info("Cleaning up go.mod and go.sum files")
+ cleanDir := path.Join(genDir, "sdk-repo-updated", "services")
+ dirEntries, err := os.ReadDir(cleanDir)
+ if err != nil {
+ return err
+ }
+ for _, entry := range dirEntries {
+ if entry.IsDir() {
+ err = deleteFiles(
+ path.Join(cleanDir, entry.Name(), "go.mod"),
+ path.Join(cleanDir, entry.Name(), "go.sum"),
+ )
+ if err != nil {
+ return err
+ }
+ }
+ }
+
+ slog.Info("Changing dir", "dir", *root)
+ err = os.Chdir(*root)
+ if err != nil {
+ return err
+ }
+
+ slog.Info("Rearranging package directories")
+ //nolint:gosec // this dir is not sensitive, so we can use 0755
+ err = os.MkdirAll(
+ path.Join(*root, "pkg_gen"),
+ 0o755,
+ )
+ if err != nil {
+ return err
+ }
+ srcDir := path.Join(genDir, "sdk-repo-updated", "services")
+ items, err := os.ReadDir(srcDir)
+ if err != nil {
+ return err
+ }
+ for _, item := range items {
+ if !item.IsDir() {
+ continue
+ }
+ slog.Info(" -> package", "name", item.Name())
+ tgtDir := path.Join(*root, "pkg_gen", item.Name())
+ if fileExists(tgtDir) {
+ delErr := os.RemoveAll(tgtDir)
+ if delErr != nil {
+ return delErr
+ }
+ }
+ err = os.Rename(path.Join(srcDir, item.Name()), tgtDir)
+ if err != nil {
+ return err
+ }
+ }
+
+ if !b.PackagesOnly {
+ slog.Info("Generating service boilerplate")
+ err = generateServiceFiles(*root, path.Join(*root, GEN_REPO_NAME))
+ if err != nil {
+ return err
+ }
+
+ slog.Info("Copying all service files")
+ err = CopyDirectory(
+ path.Join(*root, "generated", "internal", "services"),
+ path.Join(*root, "stackit", "internal", "services"),
+ )
+ if err != nil {
+ return err
+ }
+
+ err = createBoilerplate(*root, path.Join(*root, "stackit", "internal", "services"))
+ if err != nil {
+ return err
+ }
+ }
+
+ if !b.SkipCleanup {
+ slog.Info("Finally removing temporary files and directories")
+ err = os.RemoveAll(path.Join(*root, "generated"))
+ if err != nil {
+ slog.Error("RemoveAll", "dir", path.Join(*root, "generated"), "err", err)
+ return err
+ }
+
+ err = os.RemoveAll(path.Join(*root, GEN_REPO_NAME))
+ if err != nil {
+ slog.Error("RemoveAll", "dir", path.Join(*root, GEN_REPO_NAME), "err", err)
+ return err
+ }
+
+ slog.Info("Cleaning up", "dir", repoDir)
+ err = os.RemoveAll(filepath.Dir(repoDir))
+ if err != nil {
+ return fmt.Errorf("%s", err.Error())
+ }
+ }
+
+ slog.Info("Done")
+ return nil
+}
+
+type templateData struct {
+ PackageName string
+ PackageNameCamel string
+ PackageNamePascal string
+ NameCamel string
+ NamePascal string
+ NameSnake string
+ Fields []string
+}
+
+func fileExists(pathValue string) bool {
+ _, err := os.Stat(pathValue)
+ if os.IsNotExist(err) {
+ return false
+ }
+ if err != nil {
+ panic(err)
+ }
+ return true
+}
+
+func createBoilerplate(rootFolder, folder string) error {
+ services, err := os.ReadDir(folder)
+ if err != nil {
+ return err
+ }
+ for _, svc := range services {
+ if !svc.IsDir() {
+ continue
+ }
+ resources, err := os.ReadDir(path.Join(folder, svc.Name()))
+ if err != nil {
+ return err
+ }
+
+ var handleDS bool
+ var handleRes bool
+ var foundDS bool
+ var foundRes bool
+
+ for _, res := range resources {
+ if !res.IsDir() {
+ continue
+ }
+
+ resourceName := res.Name()
+
+ dsFile := path.Join(
+ folder,
+ svc.Name(),
+ res.Name(),
+ "datasources_gen",
+ fmt.Sprintf("%s_data_source_gen.go", res.Name()),
+ )
+ handleDS = fileExists(dsFile)
+
+ resFile := path.Join(
+ folder,
+ svc.Name(),
+ res.Name(),
+ "resources_gen",
+ fmt.Sprintf("%s_resource_gen.go", res.Name()),
+ )
+ handleRes = fileExists(resFile)
+
+ dsGoFile := path.Join(folder, svc.Name(), res.Name(), "datasource.go")
+ foundDS = fileExists(dsGoFile)
+
+ resGoFile := path.Join(folder, svc.Name(), res.Name(), "resource.go")
+ foundRes = fileExists(resGoFile)
+
+ if handleDS && !foundDS {
+ slog.Info(" creating missing datasource.go", "service", svc.Name(), "resource", resourceName)
+ if !ValidateSnakeCase(resourceName) {
+ return errors.New("resource name is invalid")
+ }
+
+ fields, tokenErr := getTokens(dsFile)
+ if tokenErr != nil {
+ return fmt.Errorf("error reading tokens: %w", tokenErr)
+ }
+
+ tplName := "data_source_scaffold.gotmpl"
+ err = writeTemplateToFile(
+ tplName,
+ path.Join(rootFolder, "cmd", "cmd", "build", "templates", tplName),
+ dsGoFile,
+ &templateData{
+ PackageName: svc.Name(),
+ PackageNameCamel: ToCamelCase(svc.Name()),
+ PackageNamePascal: ToPascalCase(svc.Name()),
+ NameCamel: ToCamelCase(resourceName),
+ NamePascal: ToPascalCase(resourceName),
+ NameSnake: resourceName,
+ Fields: fields,
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+ }
+
+ if handleRes && !foundRes {
+ slog.Info(" creating missing resource.go", "service", svc.Name(), "resource", resourceName)
+ if !ValidateSnakeCase(resourceName) {
+ return errors.New("resource name is invalid")
+ }
+
+ fields, tokenErr := getTokens(resFile)
+ if tokenErr != nil {
+ return fmt.Errorf("error reading tokens: %w", tokenErr)
+ }
+
+ tplName := "resource_scaffold.gotmpl"
+ err = writeTemplateToFile(
+ tplName,
+ path.Join(rootFolder, "cmd", "cmd", "build", "templates", tplName),
+ resGoFile,
+ &templateData{
+ PackageName: svc.Name(),
+ PackageNameCamel: ToCamelCase(svc.Name()),
+ PackageNamePascal: ToPascalCase(svc.Name()),
+ NameCamel: ToCamelCase(resourceName),
+ NamePascal: ToPascalCase(resourceName),
+ NameSnake: resourceName,
+ Fields: fields,
+ },
+ )
+ if err != nil {
+ return err
+ }
+
+ if !fileExists(path.Join(folder, svc.Name(), res.Name(), "functions.go")) {
+ slog.Info(" creating missing functions.go", "service", svc.Name(), "resource", resourceName)
+ if !ValidateSnakeCase(resourceName) {
+ return errors.New("resource name is invalid")
+ }
+ fncTplName := "functions_scaffold.gotmpl"
+ err = writeTemplateToFile(
+ fncTplName,
+ path.Join(rootFolder, "cmd", "cmd", "build", "templates", fncTplName),
+ path.Join(folder, svc.Name(), res.Name(), "functions.go"),
+ &templateData{
+ PackageName: svc.Name(),
+ PackageNameCamel: ToCamelCase(svc.Name()),
+ PackageNamePascal: ToPascalCase(svc.Name()),
+ NameCamel: ToCamelCase(resourceName),
+ NamePascal: ToPascalCase(resourceName),
+ NameSnake: resourceName,
+ },
+ )
+ if err != nil {
+ return err
+ }
+ }
+ }
+ }
+ }
+ return nil
+}
+
+func ucfirst(s string) string {
+ if s == "" {
+ return ""
+ }
+ return strings.ToUpper(s[:1]) + s[1:]
+}
+
+func writeTemplateToFile(tplName, tplFile, outFile string, data *templateData) error {
+ fn := template.FuncMap{
+ "ucfirst": ucfirst,
+ }
+
+ tmpl, err := template.New(tplName).Funcs(fn).ParseFiles(tplFile)
+ if err != nil {
+ return err
+ }
+
+ var f *os.File
+ f, err = os.Create(outFile)
+ if err != nil {
+ return err
+ }
+
+ err = tmpl.Execute(f, *data)
+ if err != nil {
+ return err
+ }
+
+ err = f.Close()
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func generateServiceFiles(rootDir, generatorDir string) error {
+ //nolint:gosec // this file is not sensitive, so we can use 0755
+ err := os.MkdirAll(path.Join(rootDir, "generated", "specs"), 0o755)
+ if err != nil {
+ return err
+ }
+
+ services, err := os.ReadDir(path.Join(rootDir, "service_specs"))
+ if err != nil {
+ return err
+ }
+ for _, service := range services {
+ if !service.IsDir() {
+ continue
+ }
+
+ versions, err := os.ReadDir(path.Join(rootDir, "service_specs", service.Name()))
+ if err != nil {
+ return err
+ }
+ for _, svcVersion := range versions {
+ if !svcVersion.IsDir() {
+ continue
+ }
+
+ // TODO: use const of supported versions
+ if svcVersion.Name() != "alpha" && svcVersion.Name() != "beta" {
+ continue
+ }
+
+ specFiles, err := os.ReadDir(path.Join(rootDir, "service_specs", service.Name(), svcVersion.Name()))
+ if err != nil {
+ return err
+ }
+
+ for _, specFile := range specFiles {
+ if specFile.IsDir() {
+ continue
+ }
+
+ r := regexp.MustCompile(`^(.*)_config.yml$`)
+ matches := r.FindAllStringSubmatch(specFile.Name(), -1)
+ if matches != nil {
+ fileName := matches[0][0]
+ resource := matches[0][1]
+ slog.Info(
+ " found service spec",
+ "name",
+ specFile.Name(),
+ "service",
+ service.Name(),
+ "resource",
+ resource,
+ )
+
+ oasFile := path.Join(
+ generatorDir,
+ "oas",
+ fmt.Sprintf("%s%s.json", service.Name(), svcVersion.Name()),
+ )
+ if _, oasErr := os.Stat(oasFile); os.IsNotExist(oasErr) {
+ slog.Warn(
+ " could not find matching oas",
+ "svc",
+ service.Name(),
+ "version",
+ svcVersion.Name(),
+ )
+ continue
+ }
+
+ scName := fmt.Sprintf("%s%s", service.Name(), svcVersion.Name())
+ scName = strings.ReplaceAll(scName, "-", "")
+ //nolint:gosec // this file is not sensitive, so we can use 0755
+ err = os.MkdirAll(path.Join(rootDir, "generated", "internal", "services", scName, resource), 0o755)
+ if err != nil {
+ return err
+ }
+
+ specJsonFile := path.Join(
+ rootDir,
+ "generated",
+ "specs",
+ fmt.Sprintf("%s_%s_spec.json", scName, resource),
+ )
+
+ var stdOut, stdErr bytes.Buffer
+
+ // nolint:gosec // #nosec this command is not using any untrusted input, so we can ignore gosec warning
+ cmd := exec.Command(
+ "go",
+ "run",
+ "github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi",
+ "generate",
+ "--config",
+ path.Join(rootDir, "service_specs", service.Name(), svcVersion.Name(), fileName),
+ "--output",
+ specJsonFile,
+ oasFile,
+ )
+ cmd.Stdout = &stdOut
+ cmd.Stderr = &stdErr
+
+ if err = cmd.Start(); err != nil {
+ slog.Error(
+ "tfplugingen-openapi generate",
+ "error",
+ err,
+ "stdOut",
+ stdOut.String(),
+ "stdErr",
+ stdErr.String(),
+ )
+ return err
+ }
+
+ if err = cmd.Wait(); err != nil {
+ var exitErr *exec.ExitError
+ if errors.As(err, &exitErr) {
+ slog.Error(
+ "tfplugingen-openapi generate",
+ "code",
+ exitErr.ExitCode(),
+ "error",
+ err,
+ "stdout",
+ stdOut.String(),
+ "stderr",
+ stdErr.String(),
+ )
+ return fmt.Errorf("%s", stdErr.String())
+ }
+ if err != nil {
+ slog.Error(
+ "tfplugingen-openapi generate",
+ "err",
+ err,
+ "stdout",
+ stdOut.String(),
+ "stderr",
+ stdErr.String(),
+ )
+ return err
+ }
+ }
+ if stdOut.Len() > 0 {
+ slog.Warn(" command output", "stdout", stdOut.String(), "stderr", stdErr.String())
+ }
+
+ tgtFolder := path.Join(
+ rootDir,
+ "generated",
+ "internal",
+ "services",
+ scName,
+ resource,
+ "resources_gen",
+ )
+ //nolint:gosec // this file is not sensitive, so we can use 0755
+ err = os.MkdirAll(tgtFolder, 0o755)
+ if err != nil {
+ return err
+ }
+
+ // nolint:gosec // #nosec this command is not using any untrusted input, so we can ignore gosec warning
+ cmd2 := exec.Command(
+ "go",
+ "run",
+ "github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework",
+ "generate",
+ "resources",
+ "--input",
+ specJsonFile,
+ "--output",
+ tgtFolder,
+ "--package",
+ scName,
+ )
+
+ cmd2.Stdout = &stdOut
+ cmd2.Stderr = &stdErr
+ if err = cmd2.Start(); err != nil {
+ slog.Error("tfplugingen-framework generate resources", "error", err)
+ return err
+ }
+
+ if err = cmd2.Wait(); err != nil {
+ var exitErr *exec.ExitError
+ if errors.As(err, &exitErr) {
+ slog.Error(
+ "tfplugingen-framework generate resources",
+ "code",
+ exitErr.ExitCode(),
+ "error",
+ err,
+ "stdout",
+ stdOut.String(),
+ "stderr",
+ stdErr.String(),
+ )
+ return fmt.Errorf("%s", stdErr.String())
+ }
+ if err != nil {
+ slog.Error(
+ "tfplugingen-framework generate resources",
+ "err",
+ err,
+ "stdout",
+ stdOut.String(),
+ "stderr",
+ stdErr.String(),
+ )
+ return err
+ }
+ }
+
+ tgtFolder = path.Join(
+ rootDir,
+ "generated",
+ "internal",
+ "services",
+ scName,
+ resource,
+ "datasources_gen",
+ )
+ //nolint:gosec // this directory is not sensitive, so we can use 0755
+ err = os.MkdirAll(tgtFolder, 0o755)
+ if err != nil {
+ return err
+ }
+
+ // nolint:gosec // #nosec this command is not using any untrusted input, so we can ignore gosec warning
+ cmd3 := exec.Command(
+ "go",
+ "run",
+ "github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework",
+ "generate",
+ "data-sources",
+ "--input",
+ specJsonFile,
+ "--output",
+ tgtFolder,
+ "--package",
+ scName,
+ )
+ var stdOut3, stdErr3 bytes.Buffer
+ cmd3.Stdout = &stdOut3
+ cmd3.Stderr = &stdErr3
+
+ if err = cmd3.Start(); err != nil {
+ slog.Error("tfplugingen-framework generate data-sources", "error", err)
+ return err
+ }
+
+ if err = cmd3.Wait(); err != nil {
+ var exitErr *exec.ExitError
+ if errors.As(err, &exitErr) {
+ slog.Error(
+ "tfplugingen-framework generate data-sources",
+ "code",
+ exitErr.ExitCode(),
+ "error",
+ err,
+ "stdout",
+ stdOut.String(),
+ "stderr",
+ stdErr.String(),
+ )
+ return fmt.Errorf("%s", stdErr.String())
+ }
+ if err != nil {
+ slog.Error(
+ "tfplugingen-framework generate data-sources",
+ "err",
+ err,
+ "stdout",
+ stdOut.String(),
+ "stderr",
+ stdErr.String(),
+ )
+ return err
+ }
+ }
+
+ tfAnoErr := handleTfTagForDatasourceFile(
+ path.Join(tgtFolder, fmt.Sprintf("%s_data_source_gen.go", resource)),
+ scName,
+ resource,
+ )
+ if tfAnoErr != nil {
+ return tfAnoErr
+ }
+ }
+ }
+ }
+ }
+ return nil
+}
+
+// handleTfTagForDatasourceFile replaces existing "id" with "stf_original_api_id"
+func handleTfTagForDatasourceFile(filePath, service, resource string) error {
+ slog.Info(" handle terraform tag for datasource", "service", service, "resource", resource)
+ if !fileExists(filePath) {
+ slog.Warn(" could not find file, skipping", "path", filePath)
+ return nil
+ }
+ f, err := os.Open(filePath)
+ if err != nil {
+ return err
+ }
+
+ root, err := getRoot()
+ if err != nil {
+ //nolint:gocritic // in this case, we want to log the error and exit, as we cannot proceed without the root directory
+ log.Fatal(err)
+ }
+
+ tmp, err := os.CreateTemp(*root, "replace-*")
+ if err != nil {
+ return err
+ }
+
+ sc := bufio.NewScanner(f)
+ for sc.Scan() {
+ resLine, err := handleLine(sc.Text())
+ if err != nil {
+ return err
+ }
+ if _, err := tmp.WriteString(resLine + "\n"); err != nil {
+ return err
+ }
+ }
+ if scErr := sc.Err(); scErr != nil {
+ return scErr
+ }
+
+ if err := tmp.Close(); err != nil {
+ return err
+ }
+
+ if err := f.Close(); err != nil {
+ return err
+ }
+
+ //nolint:gosec // path traversal is not a concern here
+ if err := os.Rename(tmp.Name(), filePath); err != nil {
+ log.Fatal(err)
+ }
+ return nil
+}
+
+func handleLine(line string) (string, error) {
+ schemaRegex := regexp.MustCompile(`(\s+")(id)(": schema.[a-zA-Z0-9]+Attribute{)`)
+
+ schemaMatches := schemaRegex.FindAllStringSubmatch(line, -1)
+ if schemaMatches != nil {
+ return fmt.Sprintf("%stf_original_api_id%s", schemaMatches[0][1], schemaMatches[0][3]), nil
+ }
+
+ modelRegex := regexp.MustCompile(`(\s+Id\s+types.[a-zA-Z0-9]+\s+.tfsdk:")(id)(".)`)
+ modelMatches := modelRegex.FindAllStringSubmatch(line, -1)
+ if modelMatches != nil {
+ return fmt.Sprintf("%stf_original_api_id%s", modelMatches[0][1], modelMatches[0][3]), nil
+ }
+
+ return line, nil
+}
+
+func checkCommands(commands []string) error {
+ for _, commandName := range commands {
+ if !commandExists(commandName) {
+ return fmt.Errorf("missing command %s", commandName)
+ }
+ slog.Info(" found", "command", commandName)
+ }
+ return nil
+}
+
+func commandExists(cmd string) bool {
+ _, err := exec.LookPath(cmd)
+ return err == nil
+}
+
+func deleteFiles(fNames ...string) error {
+ for _, fName := range fNames {
+ if _, err := os.Stat(fName); !os.IsNotExist(err) {
+ err = os.Remove(fName)
+ if err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+}
+
+func copyFile(src, dst string) (int64, error) {
+ sourceFileStat, err := os.Stat(src)
+ if err != nil {
+ return 0, err
+ }
+
+ if !sourceFileStat.Mode().IsRegular() {
+ return 0, fmt.Errorf("%s is not a regular file", src)
+ }
+
+ source, err := os.Open(src)
+ if err != nil {
+ return 0, err
+ }
+ defer func(source *os.File) {
+ err := source.Close()
+ if err != nil {
+ slog.Error("copyFile", "err", err)
+ }
+ }(source)
+
+ destination, err := os.Create(dst)
+ if err != nil {
+ return 0, err
+ }
+ defer func(destination *os.File) {
+ err := destination.Close()
+ if err != nil {
+ slog.Error("copyFile", "err", err)
+ }
+ }(destination)
+ nBytes, err := io.Copy(destination, source)
+ return nBytes, err
+}
+
+func getOnlyLatest(m map[string]version) (map[string]version, error) {
+ tmpMap := make(map[string]version)
+ for k, v := range m {
+ item, ok := tmpMap[k]
+ if !ok {
+ tmpMap[k] = v
+ } else if item.major == v.major && item.minor < v.minor {
+ tmpMap[k] = v
+ }
+ }
+ return tmpMap, nil
+}
+
+func getVersions(dir string) (map[string]version, error) {
+ res := make(map[string]version)
+ children, err := os.ReadDir(path.Join(dir, "services"))
+ if err != nil {
+ return nil, err
+ }
+
+ for _, entry := range children {
+ if !entry.IsDir() {
+ continue
+ }
+ versions, err := os.ReadDir(path.Join(dir, "services", entry.Name()))
+ if err != nil {
+ return nil, err
+ }
+ m, err2 := extractVersions(entry.Name(), versions)
+ if err2 != nil {
+ return m, err2
+ }
+ for k, v := range m {
+ res[k] = v
+ }
+ }
+ return res, nil
+}
+
+func extractVersions(service string, versionDirs []os.DirEntry) (map[string]version, error) {
+ res := make(map[string]version)
+ for _, vDir := range versionDirs {
+ if !vDir.IsDir() {
+ continue
+ }
+ r := regexp.MustCompile(`v(\d+)([a-z]+)(\d*)`)
+ matches := r.FindAllStringSubmatch(vDir.Name(), -1)
+ if matches == nil {
+ continue
+ }
+ svc, ver, err := handleVersion(service, matches[0])
+ if err != nil {
+ return nil, err
+ }
+
+ if svc != nil && ver != nil {
+ res[*svc] = *ver
+ }
+ }
+ return res, nil
+}
+
+func handleVersion(service string, match []string) (*string, *version, error) {
+ if match == nil {
+ fmt.Println("no matches")
+ return nil, nil, nil
+ }
+ verString := match[2]
+ if verString != "alpha" && verString != "beta" {
+ return nil, nil, errors.New("unsupported version")
+ }
+ majVer, err := strconv.Atoi(match[1])
+ if err != nil {
+ return nil, nil, err
+ }
+ if match[3] == "" {
+ match[3] = "0"
+ }
+ minVer, err := strconv.Atoi(match[3])
+ if err != nil {
+ return nil, nil, err
+ }
+ resStr := fmt.Sprintf("%s%s", service, verString)
+ return &resStr, &version{verString: verString, major: majVer, minor: minVer}, nil
+}
+
+func createRepoDir(root, repoUrl, repoName string, skipClone bool) (string, error) {
+ targetDir := path.Join(root, repoName)
+ if !skipClone {
+ if fileExists(targetDir) {
+ slog.Warn("target dir exists - skipping", "targetDir", targetDir)
+ return targetDir, nil
+ }
+ _, err := git.Clone(
+ clone.Repository(repoUrl),
+ clone.Directory(targetDir),
+ )
+ if err != nil {
+ return "", err
+ }
+ }
+ return targetDir, nil
+}
+
+func createGeneratorDir(repoUrl, targetDir string, skipClone bool) error {
+ if !skipClone {
+ if fileExists(targetDir) {
+ remErr := os.RemoveAll(targetDir)
+ if remErr != nil {
+ return remErr
+ }
+ }
+ _, cloneErr := git.Clone(
+ clone.Repository(repoUrl),
+ clone.Directory(targetDir),
+ )
+ if cloneErr != nil {
+ return cloneErr
+ }
+ }
+ return nil
+}
+
+func getRoot() (*string, error) {
+ cmd := exec.Command("git", "rev-parse", "--show-toplevel")
+ out, err := cmd.Output()
+ if err != nil {
+ return nil, err
+ }
+ lines := strings.Split(string(out), "\n")
+ return &lines[0], nil
+}
+
+func getTokens(fileName string) ([]string, error) {
+ fset := token.NewFileSet()
+
+ var result []string
+
+ node, err := parser.ParseFile(fset, fileName, nil, parser.ParseComments)
+ if err != nil {
+ return nil, err
+ }
+
+ ast.Inspect(
+ node, func(n ast.Node) bool {
+ // Suche nach Typ-Deklarationen (structs)
+ ts, ok := n.(*ast.TypeSpec)
+ if ok {
+ if strings.Contains(ts.Name.Name, "Model") {
+ ast.Inspect(
+ ts, func(sn ast.Node) bool {
+ tts, tok := sn.(*ast.Field)
+ if tok {
+ result = append(result, tts.Names[0].String())
+ }
+ return true
+ },
+ )
+ }
+ }
+ return true
+ },
+ )
+ return result, nil
+}
diff --git a/cmd/cmd/build/copy.go b/cmd/cmd/build/copy.go
new file mode 100644
index 00000000..e1243c05
--- /dev/null
+++ b/cmd/cmd/build/copy.go
@@ -0,0 +1,131 @@
+package build
+
+import (
+ "fmt"
+ "io"
+ "log/slog"
+ "os"
+ "path/filepath"
+ "syscall"
+)
+
+// Source - https://stackoverflow.com/a
+// Posted by Oleg Neumyvakin, modified by community. See post 'Timeline' for change history
+// Retrieved 2026-01-20, License - CC BY-SA 4.0
+
+func CopyDirectory(scrDir, dest string) error {
+ entries, err := os.ReadDir(scrDir)
+ if err != nil {
+ return err
+ }
+ for _, entry := range entries {
+ sourcePath := filepath.Join(scrDir, entry.Name())
+ destPath := filepath.Join(dest, entry.Name())
+
+ fileInfo, err := os.Stat(sourcePath)
+ if err != nil {
+ return err
+ }
+
+ stat, ok := fileInfo.Sys().(*syscall.Stat_t)
+ if !ok {
+ return fmt.Errorf("failed to get raw syscall.Stat_t data for '%s'", sourcePath)
+ }
+
+ switch fileInfo.Mode() & os.ModeType {
+ case os.ModeDir:
+ if err := CreateIfNotExists(destPath, 0o755); err != nil {
+ return err
+ }
+ if err := CopyDirectory(sourcePath, destPath); err != nil {
+ return err
+ }
+ case os.ModeSymlink:
+ if err := CopySymLink(sourcePath, destPath); err != nil {
+ return err
+ }
+ default:
+ if err := Copy(sourcePath, destPath); err != nil {
+ return err
+ }
+ }
+
+ if err := os.Lchown(destPath, int(stat.Uid), int(stat.Gid)); err != nil {
+ return err
+ }
+
+ fInfo, err := entry.Info()
+ if err != nil {
+ return err
+ }
+
+ isSymlink := fInfo.Mode()&os.ModeSymlink != 0
+ if !isSymlink {
+ if err := os.Chmod(destPath, fInfo.Mode()); err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+}
+
+func Copy(srcFile, dstFile string) error {
+ out, err := os.Create(dstFile)
+ if err != nil {
+ return err
+ }
+
+ defer func(out *os.File) {
+ err := out.Close()
+ if err != nil {
+ slog.Error("failed to close file", slog.Any("err", err))
+ }
+ }(out)
+
+ in, err := os.Open(srcFile)
+ if err != nil {
+ return err
+ }
+
+ defer func(in *os.File) {
+ err := in.Close()
+ if err != nil {
+ slog.Error("error closing destination file", slog.Any("err", err))
+ }
+ }(in)
+
+ _, err = io.Copy(out, in)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func Exists(filePath string) bool {
+ if _, err := os.Stat(filePath); os.IsNotExist(err) {
+ return false
+ }
+
+ return true
+}
+
+func CreateIfNotExists(dir string, perm os.FileMode) error {
+ if Exists(dir) {
+ return nil
+ }
+
+ if err := os.MkdirAll(dir, perm); err != nil {
+ return fmt.Errorf("failed to create directory: '%s', error: '%s'", dir, err.Error())
+ }
+
+ return nil
+}
+
+func CopySymLink(source, dest string) error {
+ link, err := os.Readlink(source)
+ if err != nil {
+ return err
+ }
+ return os.Symlink(link, dest)
+}
diff --git a/cmd/cmd/build/formats.go b/cmd/cmd/build/formats.go
new file mode 100644
index 00000000..ede6abe5
--- /dev/null
+++ b/cmd/cmd/build/formats.go
@@ -0,0 +1,53 @@
+package build
+
+import (
+ "regexp"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+)
+
+// snakeLetters will match to the first letter and an underscore followed by a letter
+var snakeLetters = regexp.MustCompile("(^[a-z])|_[a-z0-9]")
+
+func ToPascalCase(in string) string {
+ inputSplit := strings.Split(in, ".")
+
+ var ucName string
+
+ for _, v := range inputSplit {
+ if len(v) < 1 {
+ continue
+ }
+
+ firstChar := v[0:1]
+ ucFirstChar := strings.ToUpper(firstChar)
+
+ if len(v) < 2 {
+ ucName += ucFirstChar
+ continue
+ }
+
+ ucName += ucFirstChar + v[1:]
+ }
+
+ return snakeLetters.ReplaceAllStringFunc(ucName, func(s string) string {
+ return strings.ToUpper(strings.ReplaceAll(s, "_", ""))
+ })
+}
+
+func ToCamelCase(in string) string {
+ pascal := ToPascalCase(in)
+
+ // Grab first rune and lower case it
+ firstLetter, size := utf8.DecodeRuneInString(pascal)
+ if firstLetter == utf8.RuneError && size <= 1 {
+ return pascal
+ }
+
+ return string(unicode.ToLower(firstLetter)) + pascal[size:]
+}
+
+func ValidateSnakeCase(in string) bool {
+ return snakeLetters.MatchString(string(in))
+}
diff --git a/cmd/cmd/build/templates/data_source_scaffold.gotmpl b/cmd/cmd/build/templates/data_source_scaffold.gotmpl
new file mode 100644
index 00000000..ba4e8095
--- /dev/null
+++ b/cmd/cmd/build/templates/data_source_scaffold.gotmpl
@@ -0,0 +1,148 @@
+package {{.PackageName}}
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ {{.PackageName}}Pkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/{{.PackageName}}"
+
+ {{.PackageName}}Gen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/{{.PackageName}}/{{.NameSnake}}/datasources_gen"
+)
+
+var _ datasource.DataSource = (*{{.NameCamel}}DataSource)(nil)
+
+const errorPrefix = "[{{.PackageNamePascal}} - {{.NamePascal}}]"
+
+func New{{.NamePascal}}DataSource() datasource.DataSource {
+ return &{{.NameCamel}}DataSource{}
+}
+
+type dsModel struct {
+ {{.PackageName}}Gen.{{.NamePascal}}Model
+ TfId types.String `tfsdk:"id"`
+}
+
+type {{.NameCamel}}DataSource struct{
+ client *{{.PackageName}}Pkg.APIClient
+ providerData core.ProviderData
+}
+
+func (d *{{.NameCamel}}DataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_{{.PackageName}}_{{.NameSnake}}"
+}
+
+func (d *{{.NameCamel}}DataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = {{.PackageName}}Gen.{{.NamePascal}}DataSourceSchema(ctx)
+ resp.Schema.Attributes["id"] = schema.StringAttribute{
+ Computed: true,
+ Description: "The terraform internal identifier.",
+ MarkdownDescription: "The terraform internal identifier.",
+ }
+}
+
+// Configure adds the provider configured client to the data source.
+func (d *{{.NameCamel}}DataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
+ var ok bool
+ d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(d.providerData.RoundTripper),
+ utils.UserAgentConfigOption(d.providerData.Version),
+ }
+ if d.providerData.{{.PackageNamePascal}}CustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(d.providerData.{{.PackageNamePascal}}CustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithRegion(d.providerData.GetRegion()),
+ )
+ }
+ apiClient, err := {{.PackageName}}Pkg.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ d.client = apiClient
+ tflog.Info(ctx, fmt.Sprintf("%s client configured", errorPrefix))
+}
+
+func (d *{{.NameCamel}}DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var data dsModel
+
+ // Read Terraform configuration data into the model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := data.ProjectId.ValueString()
+ region := d.providerData.GetRegionWithOverride(data.Region)
+ {{.NameCamel}}Id := data.{{.NamePascal}}Id.ValueString()
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ // TODO: implement needed fields
+ ctx = tflog.SetField(ctx, "{{.NameCamel}}_id", {{.NameCamel}}Id)
+
+ // TODO: refactor to correct implementation
+ {{.NameCamel}}Resp, err := d.client.Get{{.NamePascal}}Request(ctx, projectId, region, {{.NameCamel}}Id).Execute()
+ if err != nil {
+ utils.LogError(
+ ctx,
+ &resp.Diagnostics,
+ err,
+ "Reading {{.NameCamel}}",
+ fmt.Sprintf("{{.NameCamel}} with ID %q does not exist in project %q.", {{.NameCamel}}Id, projectId),
+ map[int]string{
+ http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId),
+ },
+ )
+ resp.State.RemoveResource(ctx)
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+
+ data.TfId = utils.BuildInternalTerraformId(projectId, region, ..)
+
+ // TODO: fill remaining fields
+{{- range .Fields }}
+ // data.{{.}} = types.Sometype(apiResponse.Get{{.}}())
+{{- end -}}
+
+ // Save data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+
+ tflog.Info(ctx, fmt.Sprintf("%s read successful", errorPrefix))
+}
diff --git a/cmd/cmd/build/templates/functions_scaffold.gotmpl b/cmd/cmd/build/templates/functions_scaffold.gotmpl
new file mode 100644
index 00000000..de4d2dbe
--- /dev/null
+++ b/cmd/cmd/build/templates/functions_scaffold.gotmpl
@@ -0,0 +1,98 @@
+package {{.PackageName}}
+
+import (
+ "context"
+ "fmt"
+ "math"
+
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+
+ {{.PackageName}} "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/{{.PackageName}}"
+ {{.PackageName}}ResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/{{.PackageName}}/instance/resources_gen"
+)
+
+func mapResponseToModel(
+ ctx context.Context,
+ resp *{{.PackageName}}.Get{{.NamePascal}}Response,
+ m *{{.PackageName}}ResGen.{{.NamePascal}}Model,
+ tfDiags diag.Diagnostics,
+) error {
+ // TODO: complete and refactor
+ m.Id = types.StringValue(resp.GetId())
+
+ /*
+ sampleList, diags := types.ListValueFrom(ctx, types.StringType, resp.GetList())
+ tfDiags.Append(diags...)
+ if diags.HasError() {
+ return fmt.Errorf(
+ "error converting list response value",
+ )
+ }
+ sample, diags := {{.PackageName}}ResGen.NewSampleValue(
+ {{.PackageName}}ResGen.SampleValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "field": types.StringValue(string(resp.GetField())),
+ },
+ )
+ tfDiags.Append(diags...)
+ if diags.HasError() {
+ return fmt.Errorf(
+ "error converting sample response value",
+ "sample",
+ types.StringValue(string(resp.GetField())),
+ )
+ }
+ m.Sample = sample
+ */
+ return nil
+}
+
+func handleEncryption(
+ m *{{.PackageName}}ResGen.{{.NamePascal}}Model,
+ resp *{{.PackageName}}.Get{{.NamePascal}}Response,
+) {{.PackageName}}ResGen.EncryptionValue {
+ if !resp.HasEncryption() ||
+ resp.Encryption == nil ||
+ resp.Encryption.KekKeyId == nil ||
+ resp.Encryption.KekKeyRingId == nil ||
+ resp.Encryption.KekKeyVersion == nil ||
+ resp.Encryption.ServiceAccount == nil {
+
+ if m.Encryption.IsNull() || m.Encryption.IsUnknown() {
+ return {{.PackageName}}ResGen.NewEncryptionValueNull()
+ }
+ return m.Encryption
+ }
+
+ enc := {{.PackageName}}ResGen.NewEncryptionValueNull()
+ if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok {
+ enc.KekKeyId = types.StringValue(kVal)
+ }
+ if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok {
+ enc.KekKeyRingId = types.StringValue(kkVal)
+ }
+ if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok {
+ enc.KekKeyVersion = types.StringValue(kkvVal)
+ }
+ if sa, ok := resp.Encryption.GetServiceAccountOk(); ok {
+ enc.ServiceAccount = types.StringValue(sa)
+ }
+ return enc
+}
+
+func toCreatePayload(
+ ctx context.Context,
+ model *{{.PackageName}}ResGen.{{.NamePascal}}Model,
+) (*{{.PackageName}}.Create{{.NamePascal}}RequestPayload, error) {
+ if model == nil {
+ return nil, fmt.Errorf("nil model")
+ }
+
+ return &{{.PackageName}}.Create{{.NamePascal}}RequestPayload{
+ // TODO: fill fields
+ }, nil
+}
diff --git a/cmd/cmd/build/templates/provider_scaffold.gotmpl b/cmd/cmd/build/templates/provider_scaffold.gotmpl
new file mode 100644
index 00000000..8c141ccc
--- /dev/null
+++ b/cmd/cmd/build/templates/provider_scaffold.gotmpl
@@ -0,0 +1,39 @@
+package {{.PackageName}}
+
+import (
+ "context"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/provider"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+)
+
+var _ provider.Provider = (*{{.NameCamel}}Provider)(nil)
+
+func New() func() provider.Provider {
+ return func() provider.Provider {
+ return &{{.NameCamel}}Provider{}
+ }
+}
+
+type {{.NameCamel}}Provider struct{}
+
+func (p *{{.NameCamel}}Provider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) {
+
+}
+
+func (p *{{.NameCamel}}Provider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) {
+
+}
+
+func (p *{{.NameCamel}}Provider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) {
+ resp.TypeName = "{{.NameSnake}}"
+}
+
+func (p *{{.NameCamel}}Provider) DataSources(ctx context.Context) []func() datasource.DataSource {
+ return []func() datasource.DataSource{}
+}
+
+func (p *{{.NameCamel}}Provider) Resources(ctx context.Context) []func() resource.Resource {
+ return []func() resource.Resource{}
+}
diff --git a/cmd/cmd/build/templates/resource_scaffold.gotmpl b/cmd/cmd/build/templates/resource_scaffold.gotmpl
new file mode 100644
index 00000000..3fafc10c
--- /dev/null
+++ b/cmd/cmd/build/templates/resource_scaffold.gotmpl
@@ -0,0 +1,429 @@
+package {{.PackageName}}
+
+import (
+ "context"
+ _ "embed"
+ "fmt"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/{{.PackageName}}"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ {{.PackageName}}ResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/{{.PackageName}}/{{.NameSnake}}/resources_gen"
+)
+
+var (
+ _ resource.Resource = &{{.NameCamel}}Resource{}
+ _ resource.ResourceWithConfigure = &{{.NameCamel}}Resource{}
+ _ resource.ResourceWithImportState = &{{.NameCamel}}Resource{}
+ _ resource.ResourceWithModifyPlan = &{{.NameCamel}}Resource{}
+ _ resource.ResourceWithIdentity = &{{.NameCamel}}Resource{}
+)
+
+func New{{.NamePascal}}Resource() resource.Resource {
+ return &{{.NameCamel}}Resource{}
+}
+
+type {{.NameCamel}}Resource struct{
+ client *{{.PackageName}}.APIClient
+ providerData core.ProviderData
+}
+
+// resourceModel represents the Terraform resource state
+type resourceModel = {{.PackageName}}.{{.NamePascal}}Model
+
+type {{.NamePascal}}ResourceIdentityModel struct {
+ ProjectID types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ // TODO: implement further needed parts
+ {{.NamePascal}}ID types.String `tfsdk:"{{.NameSnake}}_id"`
+}
+
+// Metadata defines terraform resource name
+func (r *{{.NameCamel}}Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_{{.PackageName}}_{{.NameSnake}}"
+}
+
+//go:embed planModifiers.yaml
+var modifiersFileByte []byte
+
+// Schema loads the schema from generated files and adds plan modifiers
+func (r *{{.NameCamel}}Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
+ schema = {{.PackageName}}ResGen.{{.NamePascal}}ResourceSchema(ctx)
+
+ fields, err := {{.PackageName}}Utils.ReadModifiersConfig(modifiersFileByte)
+ if err != nil {
+ resp.Diagnostics.AddError("error during read modifiers config file", err.Error())
+ return
+ }
+
+ err = {{.PackageName}}Utils.AddPlanModifiersToResourceSchema(fields, &schema)
+ if err != nil {
+ resp.Diagnostics.AddError("error adding plan modifiers", err.Error())
+ return
+ }
+ resp.Schema = schema
+}
+
+// IdentitySchema defines the identity schema
+func (r *instanceResource) IdentitySchema(_ context.Context, _ resource.IdentitySchemaRequest, resp *resource.IdentitySchemaResponse) {
+ resp.IdentitySchema = identityschema.Schema{
+ Attributes: map[string]identityschema.Attribute{
+ "project_id": identityschema.StringAttribute{
+ RequiredForImport: true, // must be set during import by the practitioner
+ },
+ "region": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ "instance_id": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ // TODO: implement remaining schema parts
+ },
+ }
+}
+
+// Configure adds the provider configured client to the resource.
+func (r *{{.NameCamel}}Resource) Configure(
+ ctx context.Context,
+ req resource.ConfigureRequest,
+ resp *resource.ConfigureResponse,
+) {
+ var ok bool
+ r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(r.providerData.RoundTripper),
+ utils.UserAgentConfigOption(r.providerData.Version),
+ }
+ if r.providerData.{{.PackageNamePascal}}CustomEndpoint != "" {
+ apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(r.providerData.{{.PackageName}}CustomEndpoint))
+ } else {
+ apiClientConfigOptions = append(apiClientConfigOptions, config.WithRegion(r.providerData.GetRegion()))
+ }
+ apiClient, err := {{.PackageName}}.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ r.client = apiClient
+ tflog.Info(ctx, "{{.PackageName}}.{{.NamePascal}} client configured")
+}
+
+// ModifyPlan implements resource.ResourceWithModifyPlan.
+// Use the modifier to set the effective region in the current plan.
+func (r *{{.NameCamel}}Resource) ModifyPlan(
+ ctx context.Context,
+ req resource.ModifyPlanRequest,
+ resp *resource.ModifyPlanResponse,
+) { // nolint:gocritic // function signature required by Terraform
+
+ // skip initial empty configuration to avoid follow-up errors
+ if req.Config.Raw.IsNull() {
+ return
+ }
+ var configModel {{.PackageName}}ResGen.{{.NamePascal}}Model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &configModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ if req.Plan.Raw.IsNull() {
+ return
+ }
+ var planModel {{.PackageName}}ResGen.{{.NamePascal}}Model
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+}
+
+// Create creates a new resource
+func (r *{{.NameCamel}}Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
+ var data {{.PackageName}}ResGen.{{.NamePascal}}Model
+
+ // Read Terraform plan data into the model
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := data.ProjectId.ValueString()
+ region := data.Region.ValueString()
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+ // TODO: add remaining fields
+
+ // TODO: Create API call logic
+ /*
+ // Generate API request body from model
+ payload, err := toCreatePayload(ctx, &model)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating {{.NamePascal}}",
+ fmt.Sprintf("Creating API payload: %v", err),
+ )
+ return
+ }
+ // Create new {{.NamePascal}}
+ createResp, err := r.client.Create{{.NamePascal}}Request(
+ ctx,
+ projectId,
+ region,
+ ).Create{{.NamePascal}}RequestPayload(*payload).Execute()
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating {{.NamePascal}}", fmt.Sprintf("Calling API: %v", err))
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ {{.NamePascal}}Id := *createResp.Id
+ */
+
+ // Example data value setting
+ data.{{.NameCamel | ucfirst}}Id = types.StringValue("id-from-response")
+
+ // TODO: Set data returned by API in identity
+ identity := {{.NamePascal}}ResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ // TODO: add missing values
+ {{.NamePascal}}ID: types.StringValue({{.NamePascal}}Id),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // TODO: implement wait handler if needed
+ /*
+
+ waitResp, err := wait.Create{{.NamePascal}}WaitHandler(
+ ctx,
+ r.client,
+ projectId,
+ {{.NamePascal}}Id,
+ region,
+ ).SetSleepBeforeWait(
+ 30 * time.Second,
+ ).SetTimeout(
+ 90 * time.Minute,
+ ).WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating {{.NamePascal}}",
+ fmt.Sprintf("{{.NamePascal}} creation waiting: %v", err),
+ )
+ return
+ }
+
+ if waitResp.Id == nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating {{.NamePascal}}",
+ "{{.NamePascal}} creation waiting: returned id is nil",
+ )
+ return
+ }
+
+ // Map response body to schema
+ err = mapResponseToModel(ctx, waitResp, &model, resp.Diagnostics)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating {{.NamePascal}}",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ */
+
+ // Save data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+
+ tflog.Info(ctx, "{{.PackageName}}.{{.NamePascal}} created")
+}
+
+func (r *{{.NameCamel}}Resource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
+ var data {{.PackageName}}ResGen.{{.NamePascal}}Model
+
+ // Read Terraform prior state data into the model
+ resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Read identity data
+ var identityData {{.NamePascal}}ResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ // TODO: Read API call logic
+
+ // Save updated data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+
+ // TODO: Set data returned by API in identity
+ identity := {{.NamePascal}}ResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ // InstanceID: types.StringValue(instanceId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ tflog.Info(ctx, "{{.PackageName}}.{{.NamePascal}} read")
+}
+
+func (r *{{.NameCamel}}Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
+ var data {{.PackageName}}ResGen.{{.NamePascal}}Model
+
+ // Read Terraform prior state data into the model
+ resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := data.ProjectId.ValueString()
+ region := data.Region.ValueString()
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ // TODO: Update API call logic
+
+ // TODO: Set data returned by API in identity
+ identity := {{.NamePascal}}ResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ // TODO: add missing values
+ {{.NamePascal}}ID: types.StringValue({{.NamePascal}}Id),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Save updated data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+
+ tflog.Info(ctx, "{{.PackageName}}.{{.NamePascal}} updated")
+}
+
+func (r *{{.NameCamel}}Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
+ var data {{.PackageName}}ResGen.{{.NamePascal}}Model
+
+ // Read Terraform prior state data into the model
+ resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Read identity data
+ var identityData {{.NamePascal}}ResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ // TODO: Delete API call logic
+
+ tflog.Info(ctx, "{{.PackageName}}.{{.NamePascal}} deleted")
+}
+
+// ImportState imports a resource into the Terraform state on success.
+// The expected format of the resource import identifier is: project_id,zone_id,record_set_id
+func (r *{{.NameCamel}}Resource) ImportState(
+ ctx context.Context,
+ req resource.ImportStateRequest,
+ resp *resource.ImportStateResponse,
+) {
+ idParts := strings.Split(req.ID, core.Separator)
+
+ // TODO: Import logic
+ // TODO: fix len and parts itself
+ if len(idParts) < 2 || idParts[0] == "" || idParts[1] == "" {
+ core.LogAndAddError(
+ ctx, &resp.Diagnostics,
+ "Error importing database",
+ fmt.Sprintf(
+ "Expected import identifier with format [project_id],[region],..., got %q",
+ req.ID,
+ ),
+ )
+ return
+ }
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
+ // ... more ...
+
+ core.LogAndAddWarning(
+ ctx,
+ &resp.Diagnostics,
+ "{{.PackageName | ucfirst}} database imported with empty password",
+ "The database password is not imported as it is only available upon creation of a new database. The password field will be empty.",
+ )
+ tflog.Info(ctx, "{{.PackageName | ucfirst}} {{.NameCamel}} state imported")
+}
diff --git a/cmd/cmd/build/templates/util.gotmpl b/cmd/cmd/build/templates/util.gotmpl
new file mode 100644
index 00000000..cecc8e9e
--- /dev/null
+++ b/cmd/cmd/build/templates/util.gotmpl
@@ -0,0 +1,47 @@
+package utils
+
+import (
+ "context"
+ "fmt"
+
+ {{.PackageName}} "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/{{.PackageName}}"
+
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+func ConfigureClient(
+ ctx context.Context,
+ providerData *core.ProviderData,
+ diags *diag.Diagnostics,
+) *{{.PackageName}}.APIClient {
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(providerData.RoundTripper),
+ utils.UserAgentConfigOption(providerData.Version),
+ }
+ if providerData.{{.PackageName}}CustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(providerData.{{.PackageName}}CustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(apiClientConfigOptions, config.WithRegion(providerData.GetRegion()))
+ }
+ apiClient, err := {{.PackageName}}.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ diags,
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return nil
+ }
+
+ return apiClient
+}
diff --git a/cmd/cmd/build/templates/util_test.gotmpl b/cmd/cmd/build/templates/util_test.gotmpl
new file mode 100644
index 00000000..567f2623
--- /dev/null
+++ b/cmd/cmd/build/templates/util_test.gotmpl
@@ -0,0 +1,97 @@
+package utils
+
+import (
+ "context"
+ "os"
+ "reflect"
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ sdkClients "github.com/stackitcloud/stackit-sdk-go/core/clients"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+ {{.PackageName}} "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/{{.PackageName}}"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+const (
+ testVersion = "1.2.3"
+ testCustomEndpoint = "https://sqlserverflex-custom-endpoint.api.stackit.cloud"
+)
+
+func TestConfigureClient(t *testing.T) {
+ /* mock authentication by setting service account token env variable */
+ os.Clearenv()
+ err := os.Setenv(sdkClients.ServiceAccountToken, "mock-val")
+ if err != nil {
+ t.Errorf("error setting env variable: %v", err)
+ }
+
+ type args struct {
+ providerData *core.ProviderData
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ expected *sqlserverflex.APIClient
+ }{
+ {
+ name: "default endpoint",
+ args: args{
+ providerData: &core.ProviderData{
+ Version: testVersion,
+ },
+ },
+ expected: func() *sqlserverflex.APIClient {
+ apiClient, err := sqlserverflex.NewAPIClient(
+ config.WithRegion("eu01"),
+ utils.UserAgentConfigOption(testVersion),
+ )
+ if err != nil {
+ t.Errorf("error configuring client: %v", err)
+ }
+ return apiClient
+ }(),
+ wantErr: false,
+ },
+ {
+ name: "custom endpoint",
+ args: args{
+ providerData: &core.ProviderData{
+ Version: testVersion,
+ SQLServerFlexCustomEndpoint: testCustomEndpoint,
+ },
+ },
+ expected: func() *sqlserverflex.APIClient {
+ apiClient, err := sqlserverflex.NewAPIClient(
+ utils.UserAgentConfigOption(testVersion),
+ config.WithEndpoint(testCustomEndpoint),
+ )
+ if err != nil {
+ t.Errorf("error configuring client: %v", err)
+ }
+ return apiClient
+ }(),
+ wantErr: false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.name, func(t *testing.T) {
+ ctx := context.Background()
+ diags := diag.Diagnostics{}
+
+ actual := ConfigureClient(ctx, tt.args.providerData, &diags)
+ if diags.HasError() != tt.wantErr {
+ t.Errorf("ConfigureClient() error = %v, want %v", diags.HasError(), tt.wantErr)
+ }
+
+ if !reflect.DeepEqual(actual, tt.expected) {
+ t.Errorf("ConfigureClient() = %v, want %v", actual, tt.expected)
+ }
+ },
+ )
+ }
+}
diff --git a/cmd/cmd/buildCmd.go b/cmd/cmd/buildCmd.go
new file mode 100644
index 00000000..e3e8e7ae
--- /dev/null
+++ b/cmd/cmd/buildCmd.go
@@ -0,0 +1,37 @@
+package cmd
+
+import (
+ "github.com/spf13/cobra"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/cmd/cmd/build"
+)
+
+var (
+ skipCleanup bool
+ skipClone bool
+ packagesOnly bool
+)
+
+var buildCmd = &cobra.Command{
+ Use: "build",
+ Short: "Build the necessary boilerplate",
+ Long: `...`,
+ RunE: func(_ *cobra.Command, _ []string) error {
+ b := build.Builder{
+ SkipClone: skipClone,
+ SkipCleanup: skipCleanup,
+ PackagesOnly: packagesOnly,
+ }
+ return b.Build()
+ },
+}
+
+func NewBuildCmd() *cobra.Command {
+ return buildCmd
+}
+
+func init() { //nolint:gochecknoinits // This is the standard way to set up Cobra commands
+ buildCmd.Flags().BoolVarP(&skipCleanup, "skip-clean", "c", false, "Skip cleanup steps")
+ buildCmd.Flags().BoolVarP(&skipClone, "skip-clone", "g", false, "Skip cloning from git")
+ buildCmd.Flags().BoolVarP(&packagesOnly, "packages-only", "p", false, "Only generate packages")
+}
diff --git a/cmd/cmd/examplesCmd.go b/cmd/cmd/examplesCmd.go
new file mode 100644
index 00000000..a4c75962
--- /dev/null
+++ b/cmd/cmd/examplesCmd.go
@@ -0,0 +1,114 @@
+package cmd
+
+import (
+ "fmt"
+ "os"
+ "path"
+
+ "github.com/spf13/cobra"
+)
+
+var examplesCmd = &cobra.Command{
+ Use: "examples",
+ Short: "create examples",
+ Long: `...`,
+ RunE: func(_ *cobra.Command, _ []string) error {
+ // filePathStr := "stackit/internal/services/postgresflexalpha/database/datasources_gen/database_data_source_gen.go"
+ //
+ // src, err := os.ReadFile(filePathStr)
+ // if err != nil {
+ // return err
+ //}
+ //
+ // i := interp.New(
+ // interp.Options{
+ // GoPath: "/home/henselinm/.asdf/installs/golang/1.25.6/packages",
+ // BuildTags: nil,
+ // Stdin: nil,
+ // Stdout: nil,
+ // Stderr: nil,
+ // Args: nil,
+ // Env: nil,
+ // SourcecodeFilesystem: nil,
+ // Unrestricted: false,
+ // },
+ //)
+ // err = i.Use(i.Symbols("github.com/hashicorp/terraform-plugin-framework-validators"))
+ // if err != nil {
+ // return err
+ //}
+ // err = i.Use(stdlib.Symbols)
+ // if err != nil {
+ // return err
+ //}
+ // _, err = i.Eval(string(src))
+ // if err != nil {
+ // return err
+ //}
+ //
+ // v, err := i.Eval("DatabaseDataSourceSchema")
+ // if err != nil {
+ // return err
+ //}
+ //
+ // bar := v.Interface().(func(string) string)
+ //
+ // r := bar("Kung")
+ // println(r)
+ //
+ // evalPath, err := i.EvalPath(filePathStr)
+ // if err != nil {
+ // return err
+ //}
+ //
+ // fmt.Printf("%+v\n", evalPath)
+
+ // _, err = i.Eval(`import "fmt"`)
+ // if err != nil {
+ // return err
+ //}
+ // _, err = i.Eval(`func Hallo() { fmt.Println("Hi!") }`)
+ // if err != nil {
+ // return err
+ //}
+
+ // v = i.Symbols("Hallo")
+
+ // fmt.Println(v)
+ return workServices()
+ },
+}
+
+func workServices() error {
+ startPath := path.Join("stackit", "internal", "services")
+
+ services, err := os.ReadDir(startPath)
+ if err != nil {
+ return err
+ }
+
+ for _, entry := range services {
+ if !entry.IsDir() {
+ continue
+ }
+ resources, err := os.ReadDir(path.Join(startPath, entry.Name()))
+ if err != nil {
+ return err
+ }
+ for _, res := range resources {
+ if !res.IsDir() {
+ continue
+ }
+ fmt.Println("Gefunden:", startPath, "subdir", entry.Name(), "resource", res.Name())
+ }
+ }
+ return nil
+}
+
+func NewExamplesCmd() *cobra.Command {
+ return examplesCmd
+}
+
+// func init() { // nolint: gochecknoinits
+// examplesCmd.Flags().BoolVarP(&example, "example", "e", false, "example")
+//}
diff --git a/cmd/cmd/getFieldsCmd.go b/cmd/cmd/getFieldsCmd.go
new file mode 100644
index 00000000..06fe9e66
--- /dev/null
+++ b/cmd/cmd/getFieldsCmd.go
@@ -0,0 +1,148 @@
+package cmd
+
+import (
+ "fmt"
+ "go/ast"
+ "go/parser"
+ "go/token"
+ "path"
+ "path/filepath"
+ "strings"
+
+ "github.com/spf13/cobra"
+)
+
+var (
+ inFile string
+ svcName string
+ resName string
+ resType string
+ filePath string
+)
+
+var getFieldsCmd = &cobra.Command{
+ Use: "get-fields",
+ Short: "get fields from file",
+ Long: `...`,
+ PreRunE: func(_ *cobra.Command, _ []string) error {
+ typeStr := "data_source"
+ if resType != "resource" && resType != "datasource" {
+ return fmt.Errorf("--type can only be resource or datasource")
+ }
+
+ if resType == "resource" {
+ typeStr = resType
+ }
+
+ if inFile == "" && svcName == "" && resName == "" {
+ return fmt.Errorf("--infile or --service and --resource must be provided")
+ }
+
+ if inFile != "" {
+ if svcName != "" || resName != "" {
+ return fmt.Errorf("--infile is provided and excludes --service and --resource")
+ }
+ p, err := filepath.Abs(inFile)
+ if err != nil {
+ return err
+ }
+ filePath = p
+ return nil
+ }
+
+ if svcName != "" && resName == "" {
+ return fmt.Errorf("if --service is provided, you MUST also provide --resource")
+ }
+
+ if svcName == "" && resName != "" {
+ return fmt.Errorf("if --resource is provided, you MUST also provide --service")
+ }
+
+ p, err := filepath.Abs(
+ path.Join(
+ "stackit",
+ "internal",
+ "services",
+ svcName,
+ resName,
+ fmt.Sprintf("%ss_gen", resType),
+ fmt.Sprintf("%s_%s_gen.go", resName, typeStr),
+ ),
+ )
+ if err != nil {
+ return err
+ }
+ filePath = p
+
+ //// Enum check
+ // switch format {
+ // case "json", "yaml":
+ //default:
+ // return fmt.Errorf("invalid --format: %s (want json|yaml)", format)
+ //}
+ return nil
+ },
+ RunE: func(_ *cobra.Command, _ []string) error {
+ return getFields(filePath)
+ },
+}
+
+func getFields(f string) error {
+ tokens, err := getTokens(f)
+ if err != nil {
+ return err
+ }
+ for _, item := range tokens {
+ fmt.Printf("%s \n", item)
+ }
+ return nil
+}
+
+func getTokens(fileName string) ([]string, error) {
+ fset := token.NewFileSet()
+ var result []string
+
+ node, err := parser.ParseFile(fset, fileName, nil, parser.ParseComments)
+ if err != nil {
+ return nil, err
+ }
+
+ ast.Inspect(
+ node, func(n ast.Node) bool {
+ // Suche nach Typ-Deklarationen (structs)
+ ts, ok := n.(*ast.TypeSpec)
+ if ok {
+ if strings.Contains(ts.Name.Name, "Model") {
+ ast.Inspect(
+ ts, func(sn ast.Node) bool {
+ tts, tok := sn.(*ast.Field)
+ if tok {
+ result = append(result, tts.Names[0].String())
+ }
+ return true
+ },
+ )
+ }
+ }
+ return true
+ },
+ )
+ return result, nil
+}
+
+func NewGetFieldsCmd() *cobra.Command {
+ return getFieldsCmd
+}
+
+func init() { //nolint:gochecknoinits //this is the only way to add the command to the rootCmd
+ getFieldsCmd.Flags().StringVarP(&inFile, "infile", "i", "", "input filename incl path")
+ getFieldsCmd.Flags().StringVarP(&svcName, "service", "s", "", "service name")
+ getFieldsCmd.Flags().StringVarP(&resName, "resource", "r", "", "resource name")
+ getFieldsCmd.Flags().StringVarP(
+ &resType,
+ "type",
+ "t",
+ "resource",
+ "resource type (data-source or resource [default])",
+ )
+}
diff --git a/cmd/cmd/publish/architecture.go b/cmd/cmd/publish/architecture.go
new file mode 100644
index 00000000..7316a03d
--- /dev/null
+++ b/cmd/cmd/publish/architecture.go
@@ -0,0 +1,137 @@
+package publish
+
+import (
+ "encoding/json"
+ "fmt"
+ "log"
+ "net/url"
+ "os"
+ "path"
+ "strings"
+)
+
+type Architecture struct {
+ Protocols []string `json:"protocols"`
+ OS string `json:"os"`
+ Arch string `json:"arch"`
+ FileName string `json:"filename"`
+ DownloadUrl string `json:"download_url"`
+ ShaSumsUrl string `json:"shasums_url"`
+ ShaSumsSignatureUrl string `json:"shasums_signature_url"`
+ ShaSum string `json:"shasum"`
+ SigningKeys SigningKey `json:"signing_keys"`
+}
+
+type SigningKey struct {
+ GpgPublicKeys []GpgPublicKey `json:"gpg_public_keys"`
+}
+
+type GpgPublicKey struct {
+ KeyId string `json:"key_id"`
+ AsciiArmor string `json:"ascii_armor"`
+ TrustSignature string `json:"trust_signature"`
+ Source string `json:"source"`
+ SourceUrl string `json:"source_url"`
+}
+
+func (p *Provider) CreateArchitectureFiles() error {
+ log.Println("* Creating architecture files in target directories")
+
+ prefix := path.Join("v1", "providers", p.Namespace, p.Provider, p.Version)
+
+ pathPrefix := path.Join("release", prefix)
+
+ urlPrefix, err := url.JoinPath("https://", p.Domain, prefix)
+ if err != nil {
+ return fmt.Errorf("error creating base url: %w", err)
+ }
+
+ downloadUrlPrefix, err := url.JoinPath(urlPrefix, "download")
+ if err != nil {
+ return fmt.Errorf("error crearting download url: %w", err)
+ }
+ downloadPathPrefix := path.Join(pathPrefix, "download")
+
+ shasumsUrl, err := url.JoinPath(urlPrefix, fmt.Sprintf("%s_%s_SHA256SUMS", p.RepoName, p.Version))
+ if err != nil {
+ return fmt.Errorf("error creating shasums url: %w", err)
+ }
+ shasumsSigUrl := shasumsUrl + ".sig"
+
+ gpgAsciiPub, err := p.ReadGpgFile()
+ if err != nil {
+ return err
+ }
+
+ shaSums, err := p.GetShaSums()
+ if err != nil {
+ return err
+ }
+ for _, sum := range shaSums {
+ downloadUrl, err := url.JoinPath(downloadUrlPrefix, sum.Path)
+ if err != nil {
+ return fmt.Errorf("error creating url: %w", err)
+ }
+
+ // get os and arch from filename
+ removeFileExtension := strings.Split(sum.Path, ".zip")
+ fileNameSplit := strings.Split(removeFileExtension[0], "_")
+
+ // Get build target and architecture from the zip file name
+ target := fileNameSplit[2]
+ arch := fileNameSplit[3]
+
+ // build filepath
+ archFileName := path.Join(downloadPathPrefix, target, arch)
+
+ a := Architecture{
+ Protocols: []string{"5.1", "6.0"},
+ OS: target,
+ Arch: arch,
+ FileName: sum.Path,
+ DownloadUrl: downloadUrl,
+ ShaSumsUrl: shasumsUrl,
+ ShaSumsSignatureUrl: shasumsSigUrl,
+ ShaSum: sum.Sum,
+ SigningKeys: SigningKey{},
+ }
+
+ a.SigningKeys = SigningKey{
+ GpgPublicKeys: []GpgPublicKey{
+ {
+ KeyId: p.GpgFingerprint,
+ AsciiArmor: gpgAsciiPub,
+ TrustSignature: "",
+ Source: "",
+ SourceUrl: "",
+ },
+ },
+ }
+
+ log.Printf(" - Arch file: %s", archFileName)
+
+ err = WriteArchitectureFile(archFileName, a)
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+func WriteArchitectureFile(filePath string, arch Architecture) error {
+ jsonString, err := json.Marshal(arch)
+ if err != nil {
+ return fmt.Errorf("error encoding data: %w", err)
+ }
+ //nolint:gosec // this file is not sensitive, so we can use os.ModePerm
+ err = os.WriteFile(
+ filePath,
+ jsonString,
+ os.ModePerm,
+ )
+ if err != nil {
+ return fmt.Errorf("error writing data: %w", err)
+ }
+ return nil
+}
diff --git a/cmd/cmd/publish/gpg.go b/cmd/cmd/publish/gpg.go
new file mode 100644
index 00000000..2de4ce33
--- /dev/null
+++ b/cmd/cmd/publish/gpg.go
@@ -0,0 +1,14 @@
+package publish
+
+import (
+ "fmt"
+ "strings"
+)
+
+func (p *Provider) ReadGpgFile() (string, error) {
+ gpgFile, err := ReadFile(p.GpgPubKeyFile)
+ if err != nil {
+ return "", fmt.Errorf("error reading '%s' file: %w", p.GpgPubKeyFile, err)
+ }
+ return strings.Join(gpgFile, "\n"), nil
+}
diff --git a/cmd/cmd/publish/provider.go b/cmd/cmd/publish/provider.go
new file mode 100644
index 00000000..88849eb0
--- /dev/null
+++ b/cmd/cmd/publish/provider.go
@@ -0,0 +1,297 @@
+package publish
+
+import (
+ "bufio"
+ "errors"
+ "fmt"
+ "io"
+ "io/fs"
+ "log"
+ "log/slog"
+ "os"
+ "os/exec"
+ "path"
+ "strings"
+)
+
+type Provider struct {
+ RootPath string
+ Namespace string
+ Provider string
+ DistPath string
+ RepoName string
+ Version string
+ GpgFingerprint string
+ GpgPubKeyFile string
+ Domain string
+}
+
+func (p *Provider) GetRoot() error {
+ cmd := exec.Command("git", "rev-parse", "--show-toplevel")
+ out, err := cmd.Output()
+ if err != nil {
+ return err
+ }
+ lines := strings.Split(string(out), "\n")
+ p.RootPath = lines[0]
+ return nil
+}
+
+func (p *Provider) CreateV1Dir() error {
+ // Path to semantic version dir
+ versionPath := p.providerDirs()
+
+ // Files to create under v1/providers/[namespace]/[provider_name]
+ err := p.createVersionsFile()
+ if err != nil {
+ return fmt.Errorf("[CreateV1Dir] - create versions file:%w", err)
+ } // Creates version file one above download, which is why downloadPath isn't used
+
+ // Files/Directories to create under v1/providers/[namespace]/[provider_name]/[version]
+ err = p.copyShaFiles(versionPath)
+ if err != nil {
+ return fmt.Errorf("[CreateV1Dir] - copy sha files: %w", err)
+ }
+
+ log.Printf("* Creating download/ in %s directory", versionPath)
+ downloadsPath := path.Join(versionPath, "download")
+ err = CreateDir(downloadsPath)
+ if err != nil {
+ return err
+ }
+
+ // Create darwin, freebsd, linux, windows dirs
+ for _, v := range [4]string{"darwin", "freebsd", "linux", "windows"} {
+ err = CreateDir(path.Join(downloadsPath, v))
+ if err != nil {
+ return fmt.Errorf("error creating dir '%s': %w", path.Join(downloadsPath, v), err)
+ }
+ }
+
+ // Copy all zips
+ err = p.copyBuildZips(downloadsPath)
+ if err != nil {
+ return err
+ }
+
+ // Create all individual files for build targets and each architecture for the build targets
+ err = p.CreateArchitectureFiles()
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (p *Provider) copyBuildZips(destPath string) error {
+ log.Println("* Copying build zips")
+
+ shaSums, err := p.GetShaSums()
+ if err != nil {
+ return err
+ }
+
+ // Loop through and copy each
+ for _, sum := range shaSums {
+ zipSrcPath := path.Join(p.DistPath, sum.Path)
+ zipDestPath := path.Join(destPath, sum.Path)
+
+ log.Printf(" - Zip Source: %s", zipSrcPath)
+ log.Printf(" - Zip Dest: %s", zipDestPath)
+
+ // Copy the zip
+ _, err = CopyFile(zipSrcPath, zipDestPath)
+ if err != nil {
+ return fmt.Errorf("error copying file '%s': %w", zipSrcPath, err)
+ }
+ }
+
+ return nil
+}
+
+func (p *Provider) copyShaFiles(destPath string) error {
+ log.Printf("* Copying SHA files in %s directory", p.DistPath)
+
+ // Copy files from srcPath
+ shaSum := p.RepoName + "_" + p.Version + "_SHA256SUMS"
+ shaSumPath := path.Join(p.DistPath, shaSum)
+
+ // _SHA256SUMS file
+ _, err := CopyFile(shaSumPath, path.Join(destPath, shaSum))
+ if err != nil {
+ return err
+ }
+
+ // _SHA256SUMS.sig file
+ _, err = CopyFile(shaSumPath+".sig", path.Join(destPath, shaSum+".sig"))
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func (p *Provider) createVersionsFile() error {
+ log.Println("* Writing to release/v1/providers/[namespace]/[repo]/versions file")
+
+ versionPath := path.Join("release", "v1", "providers", p.Namespace, p.Provider, "versions")
+
+ shasums, err := p.GetShaSums()
+ if err != nil {
+ return fmt.Errorf("error getting sha sums: %w", err)
+ }
+
+ // Build the versions file...
+ version := Version{
+ Version: p.Version,
+ Protocols: []string{"5.1", "6.1"},
+ Platforms: nil,
+ }
+ for _, sum := range shasums {
+ // get os and arch from filename
+ removeFileExtension := strings.Split(sum.Path, ".zip")
+ if len(removeFileExtension) < 1 {
+ log.Fatalf("error: %s does not have .zip extension", sum.Path)
+ }
+ fileNameSplit := strings.Split(removeFileExtension[0], "_")
+ if len(fileNameSplit) < 4 {
+ log.Fatalf("filename does not match our regex: %s", removeFileExtension[0])
+ }
+
+ // Get build target and architecture from the zip file name
+ target := fileNameSplit[2]
+ arch := fileNameSplit[3]
+
+ version.Platforms = append(
+ version.Platforms, Platform{
+ OS: target,
+ Arch: arch,
+ },
+ )
+ }
+
+ data := Data{}
+
+ downloadPath := path.Join(p.Domain, "v1", "providers", p.Namespace, p.Provider, "versions")
+ err = data.LoadFromUrl(fmt.Sprintf("https://%s", downloadPath))
+ if err != nil {
+ slog.Warn("error getting existing versions file, start with empty")
+ // TODO: create flag for first use or make it more robust
+ // return fmt.Errorf("error getting existing versions file: %w", err)
+ }
+
+ err = data.AddVersion(version)
+ if err != nil {
+ return fmt.Errorf("error appending version: %w", err)
+ }
+
+ err = data.WriteToFile(versionPath)
+ if err != nil {
+ return fmt.Errorf("error saving file '%s':%w", versionPath, err)
+ }
+
+ return nil
+}
+
+func (p *Provider) providerDirs() string {
+ log.Println("* Creating release/v1/providers/[namespace]/[provider]/[version] directories")
+
+ target := path.Join("release", "v1", "providers", p.Namespace, p.Provider, p.Version)
+
+ err := CreateDir(target)
+ if err != nil {
+ return ""
+ }
+ return target
+}
+
+func (p *Provider) CreateWellKnown() error {
+ log.Println("* Creating .well-known directory")
+ pathString := path.Join(p.RootPath, "release", ".well-known")
+
+ //nolint:gosec // this file is not sensitive, so we can use ModePerm
+ err := os.MkdirAll(pathString, os.ModePerm)
+ if err != nil && !errors.Is(err, fs.ErrExist) {
+ return fmt.Errorf("error creating '%s' dir: %w", pathString, err)
+ }
+
+ log.Println(" - Writing to .well-known/terraform.json file")
+
+ //nolint:gosec // this file is not sensitive, so we can use 0644
+ err = os.WriteFile(
+ fmt.Sprintf("%s/terraform.json", pathString),
+ []byte(`{"providers.v1": "/v1/providers/"}`),
+ 0o644,
+ )
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func CreateDir(pathValue string) error {
+ log.Printf("* Creating %s directory", pathValue)
+ //nolint:gosec // this file is not sensitive, so we can use ModePerm
+ err := os.MkdirAll(pathValue, os.ModePerm)
+ if errors.Is(err, fs.ErrExist) {
+ return nil
+ }
+ return err
+}
+
+func ReadFile(filePath string) ([]string, error) {
+ rFile, err := os.Open(filePath)
+
+ if err != nil {
+ return nil, err
+ }
+ fileScanner := bufio.NewScanner(rFile)
+ fileScanner.Split(bufio.ScanLines)
+ var fileLines []string
+
+ for fileScanner.Scan() {
+ fileLines = append(fileLines, fileScanner.Text())
+ }
+
+ err = rFile.Close()
+ if err != nil {
+ return nil, err
+ }
+
+ return fileLines, nil
+}
+
+func CopyFile(src, dst string) (int64, error) {
+ sourceFileStat, err := os.Stat(src)
+ if err != nil {
+ return 0, err
+ }
+
+ if !sourceFileStat.Mode().IsRegular() {
+ return 0, fmt.Errorf("%s is not a regular file", src)
+ }
+
+ source, err := os.Open(src)
+ if err != nil {
+ return 0, err
+ }
+ defer func(source *os.File) {
+ err := source.Close()
+ if err != nil {
+ slog.Error("error closing source file", slog.Any("err", err))
+ }
+ }(source)
+
+ destination, err := os.Create(dst)
+ if err != nil {
+ return 0, err
+ }
+ defer func(destination *os.File) {
+ err := destination.Close()
+ if err != nil {
+ slog.Error("error closing destination file", slog.Any("err", err))
+ }
+ }(destination)
+ nBytes, err := io.Copy(destination, source)
+ return nBytes, err
+}
diff --git a/cmd/cmd/publish/shasums.go b/cmd/cmd/publish/shasums.go
new file mode 100644
index 00000000..a7e71617
--- /dev/null
+++ b/cmd/cmd/publish/shasums.go
@@ -0,0 +1,39 @@
+package publish
+
+import (
+ "log/slog"
+ "path"
+ "regexp"
+)
+
+func (p *Provider) GetShaSums() (ShaSums, error) {
+ return GetShaSumContents(p.DistPath, p.RepoName, p.Version)
+}
+
+type ShaSums []ShaSum
+type ShaSum struct {
+ Sum string
+ Path string
+}
+
+func GetShaSumContents(distPath, repoName, version string) (ShaSums, error) {
+ shaSumFileName := repoName + "_" + version + "_SHA256SUMS"
+ shaSumPath := path.Join(distPath, shaSumFileName)
+
+ shaSumLine, err := ReadFile(shaSumPath)
+ if err != nil {
+ return nil, err
+ }
+
+ regEx := regexp.MustCompile(`([0-9a-fA-F]+)\s+(.+)`)
+ shaSums := ShaSums{}
+ for _, line := range shaSumLine {
+ matches := regEx.FindAllStringSubmatch(line, -1)
+ if len(matches) < 1 {
+ slog.Warn("unable to parse SHA sum line", "line", line)
+ continue
+ }
+ shaSums = append(shaSums, ShaSum{Sum: matches[0][1], Path: matches[0][2]})
+ }
+ return shaSums, nil
+}
diff --git a/cmd/cmd/publish/templates/Caddyfile b/cmd/cmd/publish/templates/Caddyfile
new file mode 100644
index 00000000..5663fbf8
--- /dev/null
+++ b/cmd/cmd/publish/templates/Caddyfile
@@ -0,0 +1,38 @@
+{
+ log {
+ level debug
+ }
+
+
+ filesystem tf s3 {
+ bucket "terraform-provider-privatepreview"
+ region eu01
+ endpoint https://object.storage.eu01.onstackit.cloud
+ use_path_style
+ }
+}
+
+tfregistry.sysops.stackit.rocks {
+ encode zstd gzip
+
+ handle_path /docs/* {
+ root /srv/www
+ templates
+
+ @md {
+ file {path}
+ path *.md
+ }
+
+ rewrite @md /markdown.html
+
+ file_server {
+ browse
+ }
+ }
+
+ file_server {
+ fs tf
+ browse
+ }
+}
diff --git a/cmd/cmd/publish/templates/index.html.gompl b/cmd/cmd/publish/templates/index.html.gompl
new file mode 100644
index 00000000..531032fe
--- /dev/null
+++ b/cmd/cmd/publish/templates/index.html.gompl
@@ -0,0 +1,11 @@
+
+
+
+ Forwarding | Weiterleitung
+
+
+
+Falls Sie nicht automatisch weitergeleitet werden, klicken Sie bitte hier.
+Sie gelangen dann auf unsere Hauptseite
+
+
diff --git a/cmd/cmd/publish/templates/index.md.gompl b/cmd/cmd/publish/templates/index.md.gompl
new file mode 100644
index 00000000..3ebaa0e1
--- /dev/null
+++ b/cmd/cmd/publish/templates/index.md.gompl
@@ -0,0 +1,34 @@
+---
+page_title: STACKIT provider PrivatePreview
+description: none
+---
+
+# provider
+[Provider](docs/index.md)
+
+## PostGreSQL alpha
+### data sources
+
+- [Flavor](docs/data-sources/postgresflexalpha_flavor.md)
+- [Database](docs/data-sources/postgresflexalpha_database.md)
+- [Instance](docs/data-sources/postgresflexalpha_instance.md)
+- [Flavors](docs/data-sources/postgresflexalpha_flavors.md)
+- [User](docs/data-sources/postgresflexalpha_user.md)
+
+### resources
+- [Database](docs/resources/postgresflexalpha_database.md)
+- [Instance](docs/resources/postgresflexalpha_instance.md)
+- [User](docs/resources/postgresflexalpha_user.md)
+
+## SQL Server alpha
+### data sources
+- [Database](docs/data-sources/sqlserverflexalpha_database.md)
+- [Version](docs/data-sources/sqlserverflexalpha_version.md)
+- [User](docs/data-sources/sqlserverflexalpha_user.md)
+- [Flavor](docs/data-sources/sqlserverflexalpha_flavor.md)
+- [Instance](docs/data-sources/sqlserverflexalpha_instance.md)
+
+### resources
+- [Database](docs/resources/sqlserverflexalpha_database.md)
+- [User](docs/resources/sqlserverflexalpha_user.md)
+- [Instance](docs/resources/sqlserverflexalpha_instance.md)
diff --git a/cmd/cmd/publish/templates/markdown.html.gompl b/cmd/cmd/publish/templates/markdown.html.gompl
new file mode 100644
index 00000000..d338b241
--- /dev/null
+++ b/cmd/cmd/publish/templates/markdown.html.gompl
@@ -0,0 +1,79 @@
+
+{{ $mdFile := .OriginalReq.URL.Path | trimPrefix "/docs" }}
+{{ $md := (include $mdFile | splitFrontMatter) }}
+
+
+ {{$md.Meta.page_title}}
+
+
+
+
+{{$md.Meta.page_title}}
+
+
+
+
+
+
+
+
+
+
+ {{markdown $md.Body}}
+
+
+
+
+
+
+
+
+
+
diff --git a/cmd/cmd/publish/versions.go b/cmd/cmd/publish/versions.go
new file mode 100644
index 00000000..5f75d45d
--- /dev/null
+++ b/cmd/cmd/publish/versions.go
@@ -0,0 +1,169 @@
+package publish
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "log/slog"
+ "net/http"
+ "net/url"
+ "os"
+)
+
+type Version struct {
+ Version string `json:"version"`
+ Protocols []string `json:"protocols"`
+ Platforms []Platform `json:"platforms"`
+}
+
+type Platform struct {
+ OS string `json:"os" yaml:"os"`
+ Arch string `json:"arch" yaml:"arch"`
+}
+
+type Data struct {
+ Id string `json:"id,omitempty"`
+ Versions []Version `json:"versions"`
+}
+
+func (d *Data) WriteToFile(filePath string) error {
+ // TODO: make it variable
+ d.Id = "tfregistry.sysops.stackit.rocks/mhenselin/stackitprivatepreview"
+
+ jsonString, err := json.Marshal(d)
+ if err != nil {
+ return fmt.Errorf("error encoding data: %w", err)
+ }
+
+ //nolint:gosec // this file is not sensitive, so we can use os.ModePerm
+ err = os.WriteFile(
+ filePath,
+ jsonString,
+ os.ModePerm,
+ )
+ if err != nil {
+ return fmt.Errorf("error writing data: %w", err)
+ }
+ return nil
+}
+
+func (d *Data) AddVersion(v Version) error {
+ var newVersions []Version
+ for _, ver := range d.Versions {
+ if ver.Version != v.Version {
+ newVersions = append(newVersions, ver)
+ }
+ }
+ newVersions = append(newVersions, v)
+ d.Versions = newVersions
+ return nil
+}
+
+func (d *Data) Validate() error {
+ for _, v := range d.Versions {
+ err := v.Validate()
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func (d *Data) LoadFromFile(filePath string) error {
+ plan, err := os.ReadFile(filePath)
+ if err != nil {
+ return err
+ }
+ err = json.Unmarshal(plan, &d)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func (d *Data) LoadFromUrl(uri string) error {
+ u, err := url.ParseRequestURI(uri)
+ if err != nil {
+ return err
+ }
+
+ file, err := os.CreateTemp("", "versions.*.json")
+ if err != nil {
+ return err
+ }
+ defer func(name string) {
+ //nolint:gosec // The file path is generated by os.CreateTemp and is not user-controllable
+ err := os.Remove(name)
+ if err != nil {
+ slog.Error("failed to remove temporary file", slog.Any("err", err))
+ }
+ }(file.Name()) // Clean up
+
+ err = DownloadFile(
+ u.String(),
+ file.Name(),
+ )
+ if err != nil {
+ return err
+ }
+
+ return d.LoadFromFile(file.Name())
+}
+
+func (v *Version) Validate() error {
+ slog.Warn("validation needs to be implemented")
+ return nil
+}
+
+func (v *Version) AddPlatform(p Platform) error {
+ if p.OS == "" || p.Arch == "" {
+ return fmt.Errorf("OS and Arch MUST NOT be empty")
+ }
+ v.Platforms = append(v.Platforms, p)
+ return nil
+}
+
+func (v *Version) AddProtocol(p string) error {
+ if p == "" {
+ return fmt.Errorf("protocol MUST NOT be empty")
+ }
+ v.Protocols = append(v.Protocols, p)
+ return nil
+}
+
+// DownloadFile will download a url and store it in local filepath.
+// It writes to the destination file as it downloads it, without
+// loading the entire file into memory.
+func DownloadFile(urlValue, filepath string) error {
+ // Create the file
+ //nolint:gosec // path traversal is not a concern here, as the filepath is generated by us and not user input
+ out, err := os.Create(filepath)
+ if err != nil {
+ return err
+ }
+ defer func(out *os.File) {
+ err := out.Close()
+ if err != nil {
+ slog.Error("failed to close file", slog.Any("err", err))
+ }
+ }(out)
+
+ // Get the data
+
+ //nolint:gosec,bodyclose // this is a controlled URL, not user input
+ resp, err := http.Get(urlValue)
+ if err != nil {
+ return err
+ }
+ defer func(Body io.ReadCloser) {
+ _ = Body.Close()
+ }(resp.Body)
+
+ // Write the body to file
+ _, err = io.Copy(out, resp.Body)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
diff --git a/cmd/cmd/publishCmd.go b/cmd/cmd/publishCmd.go
new file mode 100644
index 00000000..a428d436
--- /dev/null
+++ b/cmd/cmd/publishCmd.go
@@ -0,0 +1,139 @@
+package cmd
+
+import (
+ "errors"
+ "fmt"
+ "io/fs"
+ "log"
+ "os"
+ "path"
+ "path/filepath"
+
+ "github.com/spf13/cobra"
+
+ publish2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/cmd/cmd/publish"
+)
+
+var (
+ namespace string
+ domain string
+ providerName string
+ distPath string
+ repoName string
+ version string
+ gpgFingerprint string
+ gpgPubKeyFile string
+)
+
+var publishCmd = &cobra.Command{
+ Use: "publish",
+ Short: "Publish terraform provider",
+ Long: `...`,
+ RunE: func(_ *cobra.Command, _ []string) error {
+ return publish()
+ },
+}
+
+func init() { //nolint:gochecknoinits //this is the standard way to set up cobra commands
+ publishCmd.Flags().StringVarP(&namespace, "namespace", "n", "", "Namespace for the Terraform registry.")
+ publishCmd.Flags().StringVarP(&domain, "domain", "d", "", "Domain for the Terraform registry.")
+ publishCmd.Flags().StringVarP(&providerName, "providerName", "p", "", "ProviderName for the Terraform registry.")
+ publishCmd.Flags().StringVarP(&distPath, "distPath", "x", "dist", "Dist Path for the Terraform registry.")
+ publishCmd.Flags().StringVarP(&repoName, "repoName", "r", "", "RepoName for the Terraform registry.")
+ publishCmd.Flags().StringVarP(&version, "version", "v", "", "Version for the Terraform registry.")
+ publishCmd.Flags().StringVarP(
+ &gpgFingerprint,
+ "gpgFingerprint",
+ "f",
+ "",
+ "GPG Fingerprint for the Terraform registry.",
+ )
+ publishCmd.Flags().StringVarP(
+ &gpgPubKeyFile,
+ "gpgPubKeyFile",
+ "k",
+ "",
+ "GPG PubKey file name for the Terraform registry.",
+ )
+
+ err := publishCmd.MarkFlagRequired("namespace")
+ if err != nil {
+ return
+ }
+ err = publishCmd.MarkFlagRequired("domain")
+ if err != nil {
+ return
+ }
+ err = publishCmd.MarkFlagRequired("providerName")
+ if err != nil {
+ return
+ }
+ err = publishCmd.MarkFlagRequired("gpgFingerprint")
+ if err != nil {
+ return
+ }
+ err = publishCmd.MarkFlagRequired("gpgPubKeyFile")
+ if err != nil {
+ return
+ }
+ err = publishCmd.MarkFlagRequired("repoName")
+ if err != nil {
+ return
+ }
+ err = publishCmd.MarkFlagRequired("version")
+ if err != nil {
+ return
+ }
+ err = publishCmd.MarkFlagRequired("gpgFingerprint")
+ if err != nil {
+ return
+ }
+ err = publishCmd.MarkFlagRequired("gpgPubKeyFile")
+ if err != nil {
+ return
+ }
+}
+
+func NewPublishCmd() *cobra.Command {
+ return publishCmd
+}
+
+func publish() error {
+ log.Println("📦 Packaging Terraform Provider for private registry...")
+ p := publish2.Provider{
+ Namespace: namespace,
+ Provider: providerName,
+ DistPath: filepath.Clean(distPath) + "/",
+ RepoName: repoName,
+ Version: version,
+ GpgFingerprint: gpgFingerprint,
+ GpgPubKeyFile: gpgPubKeyFile,
+ Domain: domain,
+ }
+ err := p.GetRoot()
+ if err != nil {
+ return err
+ }
+
+ // Create release dir - only the contents of this need to be uploaded to S3
+ log.Printf("* Creating release directory")
+ //nolint:gosec // this directory is not sensitive, so we can use 0750
+ err = os.MkdirAll(path.Join(p.RootPath, "release"), os.ModePerm)
+ if err != nil && !errors.Is(err, fs.ErrExist) {
+ return fmt.Errorf("error creating '%s' dir: %w", path.Join(p.RootPath, "release"), err)
+ }
+
+ // Create .wellKnown directory and terraform.json file
+ err = p.CreateWellKnown()
+ if err != nil {
+ return fmt.Errorf("error creating '.well-known' dir: %w", err)
+ }
+
+ err = p.CreateV1Dir()
+ if err != nil {
+ return fmt.Errorf("error creating 'v1' dir: %w", err)
+ }
+
+ log.Println("📦 Packaged Terraform Provider for private registry.")
+ return nil
+}
diff --git a/cmd/cmd/rootCmd.go b/cmd/cmd/rootCmd.go
new file mode 100644
index 00000000..924d8794
--- /dev/null
+++ b/cmd/cmd/rootCmd.go
@@ -0,0 +1,23 @@
+package cmd
+
+import (
+ "github.com/spf13/cobra"
+)
+
+func NewRootCmd() *cobra.Command {
+ return &cobra.Command{
+ Use: "build-tools",
+ Short: "...",
+ Long: "...",
+ SilenceErrors: true, // Error is beautified in a custom way before being printed
+ SilenceUsage: true,
+ DisableAutoGenTag: true,
+ RunE: func(cmd *cobra.Command, _ []string) error {
+ err := cmd.Help()
+ if err != nil {
+ return err
+ }
+ return nil
+ },
+ }
+}
diff --git a/cmd/main.go b/cmd/main.go
new file mode 100644
index 00000000..19fb38e0
--- /dev/null
+++ b/cmd/main.go
@@ -0,0 +1,40 @@
+package main
+
+import (
+ "log"
+ "log/slog"
+ "os"
+
+ "github.com/SladkyCitron/slogcolor"
+ cc "github.com/ivanpirog/coloredcobra"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/cmd/cmd"
+)
+
+func main() {
+ slog.SetDefault(slog.New(slogcolor.NewHandler(os.Stderr, slogcolor.DefaultOptions)))
+
+ rootCmd := cmd.NewRootCmd()
+
+ cc.Init(&cc.Config{
+ RootCmd: rootCmd,
+ Headings: cc.HiCyan + cc.Bold + cc.Underline,
+ Commands: cc.HiYellow + cc.Bold,
+ Example: cc.Italic,
+ ExecName: cc.Bold,
+ Flags: cc.Bold,
+ })
+ rootCmd.SetOut(os.Stdout)
+
+ rootCmd.AddCommand(
+ cmd.NewBuildCmd(),
+ cmd.NewPublishCmd(),
+ cmd.NewGetFieldsCmd(),
+ cmd.NewExamplesCmd(),
+ )
+
+ err := rootCmd.Execute()
+ if err != nil {
+ log.Fatal(err)
+ }
+}
diff --git a/docs/data-sources/sqlserverflexalpha_user.md b/docs/data-sources/sqlserverflexalpha_user.md
deleted file mode 100644
index 5e646af1..00000000
--- a/docs/data-sources/sqlserverflexalpha_user.md
+++ /dev/null
@@ -1,46 +0,0 @@
----
-# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "stackitprivatepreview_sqlserverflexalpha_user Data Source - stackitprivatepreview"
-subcategory: ""
-description: |-
- SQLServer Flex user data source schema. Must have a region specified in the provider configuration.
----
-
-# stackitprivatepreview_sqlserverflexalpha_user (Data Source)
-
-SQLServer Flex user data source schema. Must have a `region` specified in the provider configuration.
-
-## Example Usage
-
-```terraform
-# Copyright (c) STACKIT
-
-data "stackitprivatepreview_sqlserverflexalpha_user" "example" {
- project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
- instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
- user_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
-}
-```
-
-
-## Schema
-
-### Required
-
-- `instance_id` (String) ID of the SQLServer Flex instance.
-- `project_id` (String) STACKIT project ID to which the instance is associated.
-- `user_id` (Number) User ID.
-
-### Optional
-
-- `region` (String) The resource region. If not defined, the provider region is used.
-
-### Read-Only
-
-- `default_database` (String)
-- `host` (String)
-- `id` (String) Terraform's internal data source. ID. It is structured as "`project_id`,`region`,`instance_id`,`user_id`".
-- `port` (Number)
-- `roles` (Set of String) Database access levels for the user.
-- `status` (String)
-- `username` (String) Username of the SQLServer Flex instance.
diff --git a/docs/index.md b/docs/index.md
deleted file mode 100644
index 10a64dc1..00000000
--- a/docs/index.md
+++ /dev/null
@@ -1,86 +0,0 @@
----
-# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "stackitprivatepreview Provider"
-description: |-
-
----
-
-# stackitprivatepreview Provider
-
-
-
-## Example Usage
-
-```terraform
-# Copyright (c) STACKIT
-
-provider "stackitprivatepreview" {
- default_region = "eu01"
-}
-
-# Authentication
-
-# Token flow (scheduled for deprecation and will be removed on December 17, 2025)
-provider "stackitprivatepreview" {
- default_region = "eu01"
- service_account_token = var.service_account_token
-}
-
-# Key flow
-provider "stackitprivatepreview" {
- default_region = "eu01"
- service_account_key = var.service_account_key
- private_key = var.private_key
-}
-
-# Key flow (using path)
-provider "stackitprivatepreview" {
- default_region = "eu01"
- service_account_key_path = var.service_account_key_path
- private_key_path = var.private_key_path
-}
-```
-
-
-## Schema
-
-### Optional
-
-- `authorization_custom_endpoint` (String) Custom endpoint for the Membership service
-- `cdn_custom_endpoint` (String) Custom endpoint for the CDN service
-- `credentials_path` (String) Path of JSON from where the credentials are read. Takes precedence over the env var `STACKIT_CREDENTIALS_PATH`. Default value is `~/.stackit/credentials.json`.
-- `default_region` (String) Region will be used as the default location for regional services. Not all services require a region, some are global
-- `dns_custom_endpoint` (String) Custom endpoint for the DNS service
-- `enable_beta_resources` (Boolean) Enable beta resources. Default is false.
-- `experiments` (List of String) Enables experiments. These are unstable features without official support. More information can be found in the README. Available Experiments: iam, routing-tables, network
-- `git_custom_endpoint` (String) Custom endpoint for the Git service
-- `iaas_custom_endpoint` (String) Custom endpoint for the IaaS service
-- `kms_custom_endpoint` (String) Custom endpoint for the KMS service
-- `loadbalancer_custom_endpoint` (String) Custom endpoint for the Load Balancer service
-- `logme_custom_endpoint` (String) Custom endpoint for the LogMe service
-- `mariadb_custom_endpoint` (String) Custom endpoint for the MariaDB service
-- `modelserving_custom_endpoint` (String) Custom endpoint for the AI Model Serving service
-- `mongodbflex_custom_endpoint` (String) Custom endpoint for the MongoDB Flex service
-- `objectstorage_custom_endpoint` (String) Custom endpoint for the Object Storage service
-- `observability_custom_endpoint` (String) Custom endpoint for the Observability service
-- `opensearch_custom_endpoint` (String) Custom endpoint for the OpenSearch service
-- `postgresflex_custom_endpoint` (String) Custom endpoint for the PostgresFlex service
-- `private_key` (String) Private RSA key used for authentication, relevant for the key flow. It takes precedence over the private key that is included in the service account key.
-- `private_key_path` (String) Path for the private RSA key used for authentication, relevant for the key flow. It takes precedence over the private key that is included in the service account key.
-- `rabbitmq_custom_endpoint` (String) Custom endpoint for the RabbitMQ service
-- `redis_custom_endpoint` (String) Custom endpoint for the Redis service
-- `region` (String, Deprecated) Region will be used as the default location for regional services. Not all services require a region, some are global
-- `resourcemanager_custom_endpoint` (String) Custom endpoint for the Resource Manager service
-- `scf_custom_endpoint` (String) Custom endpoint for the Cloud Foundry (SCF) service
-- `secretsmanager_custom_endpoint` (String) Custom endpoint for the Secrets Manager service
-- `server_backup_custom_endpoint` (String) Custom endpoint for the Server Backup service
-- `server_update_custom_endpoint` (String) Custom endpoint for the Server Update service
-- `service_account_custom_endpoint` (String) Custom endpoint for the Service Account service
-- `service_account_email` (String, Deprecated) Service account email. It can also be set using the environment variable STACKIT_SERVICE_ACCOUNT_EMAIL. It is required if you want to use the resource manager project resource.
-- `service_account_key` (String) Service account key used for authentication. If set, the key flow will be used to authenticate all operations.
-- `service_account_key_path` (String) Path for the service account key used for authentication. If set, the key flow will be used to authenticate all operations.
-- `service_account_token` (String, Deprecated) Token used for authentication. If set, the token flow will be used to authenticate all operations.
-- `service_enablement_custom_endpoint` (String) Custom endpoint for the Service Enablement API
-- `ske_custom_endpoint` (String) Custom endpoint for the Kubernetes Engine (SKE) service
-- `sqlserverflex_custom_endpoint` (String) Custom endpoint for the SQL Server Flex service
-- `token_custom_endpoint` (String) Custom endpoint for the token API, which is used to request access tokens when using the key flow
diff --git a/docs/resources/postgresflexalpha_instance.md b/docs/resources/postgresflexalpha_instance.md
deleted file mode 100644
index 64878367..00000000
--- a/docs/resources/postgresflexalpha_instance.md
+++ /dev/null
@@ -1,106 +0,0 @@
----
-# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "stackitprivatepreview_postgresflexalpha_instance Resource - stackitprivatepreview"
-subcategory: ""
-description: |-
- Postgres Flex instance resource schema. Must have a region specified in the provider configuration.
----
-
-# stackitprivatepreview_postgresflexalpha_instance (Resource)
-
-Postgres Flex instance resource schema. Must have a `region` specified in the provider configuration.
-
-## Example Usage
-
-```terraform
-# Copyright (c) STACKIT
-
-resource "stackitprivatepreview_postgresflexalpha_instance" "example" {
- project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
- name = "example-instance"
- acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
- backup_schedule = "00 00 * * *"
- flavor = {
- cpu = 2
- ram = 4
- }
- replicas = 3
- storage = {
- class = "class"
- size = 5
- }
- version = 14
-}
-
-# Only use the import statement, if you want to import an existing postgresflex instance
-import {
- to = stackitprivatepreview_postgresflexalpha_instance.import-example
- id = "${var.project_id},${var.region},${var.postgres_instance_id}"
-}
-```
-
-
-## Schema
-
-### Required
-
-- `acl` (List of String) The Access Control List (ACL) for the PostgresFlex instance.
-- `backup_schedule` (String)
-- `encryption` (Attributes) The encryption block. (see [below for nested schema](#nestedatt--encryption))
-- `flavor` (Attributes) (see [below for nested schema](#nestedatt--flavor))
-- `name` (String) Instance name.
-- `network` (Attributes) (see [below for nested schema](#nestedatt--network))
-- `project_id` (String) STACKIT project ID to which the instance is associated.
-- `replicas` (Number)
-- `storage` (Attributes) (see [below for nested schema](#nestedatt--storage))
-- `version` (String)
-
-### Optional
-
-- `region` (String) The resource region. If not defined, the provider region is used.
-
-### Read-Only
-
-- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`region`,`instance_id`".
-- `instance_id` (String) ID of the PostgresFlex instance.
-
-
-### Nested Schema for `encryption`
-
-Required:
-
-- `key_id` (String) Key ID of the encryption key.
-- `key_ring_id` (String)
-- `key_version` (String)
-- `service_account` (String)
-
-
-
-### Nested Schema for `flavor`
-
-Required:
-
-- `cpu` (Number)
-- `ram` (Number)
-
-Read-Only:
-
-- `description` (String)
-- `id` (String)
-
-
-
-### Nested Schema for `network`
-
-Required:
-
-- `access_scope` (String)
-
-
-
-### Nested Schema for `storage`
-
-Required:
-
-- `class` (String)
-- `size` (Number)
diff --git a/docs/resources/sqlserverflexalpha_user.md b/docs/resources/sqlserverflexalpha_user.md
deleted file mode 100644
index 1554ad07..00000000
--- a/docs/resources/sqlserverflexalpha_user.md
+++ /dev/null
@@ -1,54 +0,0 @@
----
-# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "stackitprivatepreview_sqlserverflexalpha_user Resource - stackitprivatepreview"
-subcategory: ""
-description: |-
- SQLServer Flex user resource schema. Must have a region specified in the provider configuration.
----
-
-# stackitprivatepreview_sqlserverflexalpha_user (Resource)
-
-SQLServer Flex user resource schema. Must have a `region` specified in the provider configuration.
-
-## Example Usage
-
-```terraform
-# Copyright (c) STACKIT
-
-resource "stackitprivatepreview_sqlserverflexalpha_user" "example" {
- project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
- instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
- username = "username"
- roles = ["role"]
-}
-
-# Only use the import statement, if you want to import an existing sqlserverflex user
-import {
- to = stackitprivatepreview_sqlserverflexalpha_user.import-example
- id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}"
-}
-```
-
-
-## Schema
-
-### Required
-
-- `instance_id` (String) ID of the SQLServer Flex instance.
-- `project_id` (String) STACKIT project ID to which the instance is associated.
-- `roles` (Set of String) Database access levels for the user. The values for the default roles are: `##STACKIT_DatabaseManager##`, `##STACKIT_LoginManager##`, `##STACKIT_ProcessManager##`, `##STACKIT_ServerManager##`, `##STACKIT_SQLAgentManager##`, `##STACKIT_SQLAgentUser##`
-- `username` (String) Username of the SQLServer Flex instance.
-
-### Optional
-
-- `region` (String)
-
-### Read-Only
-
-- `default_database` (String)
-- `host` (String)
-- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`region`,`instance_id`,`user_id`".
-- `password` (String, Sensitive) Password of the user account.
-- `port` (Number)
-- `status` (String)
-- `user_id` (String) User ID.
diff --git a/examples/data-sources/stackitprivatepreview_postgresflexalpha_database/data-source.tf b/examples/data-sources/stackitprivatepreview_postgresflexalpha_database/data-source.tf
index 81f069ff..05ac4233 100644
--- a/examples/data-sources/stackitprivatepreview_postgresflexalpha_database/data-source.tf
+++ b/examples/data-sources/stackitprivatepreview_postgresflexalpha_database/data-source.tf
@@ -1,5 +1,3 @@
-# Copyright (c) STACKIT
-
data "stackitprivatepreview_postgresflexalpha_database" "example" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
diff --git a/examples/data-sources/stackitprivatepreview_postgresflexalpha_flavor/data-source.tf b/examples/data-sources/stackitprivatepreview_postgresflexalpha_flavor/data-source.tf
new file mode 100644
index 00000000..67017935
--- /dev/null
+++ b/examples/data-sources/stackitprivatepreview_postgresflexalpha_flavor/data-source.tf
@@ -0,0 +1,8 @@
+data "stackitprivatepreview_postgresflexalpha_flavor" "flavor" {
+ project_id = var.project_id
+ region = var.region
+ cpu = 4
+ ram = 16
+ node_type = "Single"
+ storage_class = "premium-perf2-stackit"
+}
diff --git a/examples/data-sources/stackitprivatepreview_postgresflexalpha_instance/data-source.tf b/examples/data-sources/stackitprivatepreview_postgresflexalpha_instance/data-source.tf
index 6485022a..cc65ff6a 100644
--- a/examples/data-sources/stackitprivatepreview_postgresflexalpha_instance/data-source.tf
+++ b/examples/data-sources/stackitprivatepreview_postgresflexalpha_instance/data-source.tf
@@ -1,5 +1,3 @@
-# Copyright (c) STACKIT
-
data "stackitprivatepreview_postgresflexalpha_instance" "example" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
diff --git a/examples/data-sources/stackitprivatepreview_postgresflexalpha_user/data-source.tf b/examples/data-sources/stackitprivatepreview_postgresflexalpha_user/data-source.tf
index eed426b2..02781e32 100644
--- a/examples/data-sources/stackitprivatepreview_postgresflexalpha_user/data-source.tf
+++ b/examples/data-sources/stackitprivatepreview_postgresflexalpha_user/data-source.tf
@@ -1,5 +1,3 @@
-# Copyright (c) STACKIT
-
data "stackitprivatepreview_postgresflexalpha_user" "example" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
diff --git a/examples/data-sources/stackitprivatepreview_sqlserverflexalpha_flavor/data-source.tf b/examples/data-sources/stackitprivatepreview_sqlserverflexalpha_flavor/data-source.tf
new file mode 100644
index 00000000..25d94537
--- /dev/null
+++ b/examples/data-sources/stackitprivatepreview_sqlserverflexalpha_flavor/data-source.tf
@@ -0,0 +1,8 @@
+data "stackitprivatepreview_sqlserverflexalpha_flavor" "flavor" {
+ project_id = var.project_id
+ region = var.region
+ cpu = 4
+ ram = 16
+ node_type = "Single"
+ storage_class = "premium-perf2-stackit"
+}
diff --git a/examples/data-sources/stackitprivatepreview_sqlserverflexalpha_instance/data-source.tf b/examples/data-sources/stackitprivatepreview_sqlserverflexalpha_instance/data-source.tf
index 75779eac..8af56828 100644
--- a/examples/data-sources/stackitprivatepreview_sqlserverflexalpha_instance/data-source.tf
+++ b/examples/data-sources/stackitprivatepreview_sqlserverflexalpha_instance/data-source.tf
@@ -1,5 +1,3 @@
-# Copyright (c) STACKIT
-
data "stackitprivatepreview_sqlserverflexalpha_instance" "example" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
diff --git a/examples/data-sources/stackitprivatepreview_sqlserverflexalpha_user/data-source.tf b/examples/data-sources/stackitprivatepreview_sqlserverflexalpha_user/data-source.tf
index 8ba5af78..489d252a 100644
--- a/examples/data-sources/stackitprivatepreview_sqlserverflexalpha_user/data-source.tf
+++ b/examples/data-sources/stackitprivatepreview_sqlserverflexalpha_user/data-source.tf
@@ -1,5 +1,3 @@
-# Copyright (c) STACKIT
-
data "stackitprivatepreview_sqlserverflexalpha_user" "example" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
diff --git a/examples/data-sources/stackitprivatepreview_sqlserverflexbeta_database/data-source.tf b/examples/data-sources/stackitprivatepreview_sqlserverflexbeta_database/data-source.tf
new file mode 100644
index 00000000..894fcd33
--- /dev/null
+++ b/examples/data-sources/stackitprivatepreview_sqlserverflexbeta_database/data-source.tf
@@ -0,0 +1,5 @@
+data "stackitprivatepreview_sqlserverflexbeta_database" "example" {
+ project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ database_name = "dbname"
+}
diff --git a/examples/data-sources/stackitprivatepreview_sqlserverflexbeta_flavor/data-source.tf b/examples/data-sources/stackitprivatepreview_sqlserverflexbeta_flavor/data-source.tf
new file mode 100644
index 00000000..f40b9680
--- /dev/null
+++ b/examples/data-sources/stackitprivatepreview_sqlserverflexbeta_flavor/data-source.tf
@@ -0,0 +1,8 @@
+data "stackitprivatepreview_sqlserverflexbeta_flavor" "flavor" {
+ project_id = var.project_id
+ region = var.region
+ cpu = 4
+ ram = 16
+ node_type = "Single"
+ storage_class = "premium-perf2-stackit"
+}
diff --git a/examples/data-sources/stackitprivatepreview_sqlserverflexbeta_instance/data-source.tf b/examples/data-sources/stackitprivatepreview_sqlserverflexbeta_instance/data-source.tf
new file mode 100644
index 00000000..b8c8fc2b
--- /dev/null
+++ b/examples/data-sources/stackitprivatepreview_sqlserverflexbeta_instance/data-source.tf
@@ -0,0 +1,4 @@
+data "stackitprivatepreview_sqlserverflexbeta_instance" "example" {
+ project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+}
diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf
index 85a2a39b..4db0aed3 100644
--- a/examples/provider/provider.tf
+++ b/examples/provider/provider.tf
@@ -1,17 +1,14 @@
-# Copyright (c) STACKIT
-
provider "stackitprivatepreview" {
default_region = "eu01"
}
-# Authentication
-
-# Token flow (scheduled for deprecation and will be removed on December 17, 2025)
provider "stackitprivatepreview" {
- default_region = "eu01"
- service_account_token = var.service_account_token
+ default_region = "eu01"
+ service_account_key_path = "service_account.json"
}
+# Authentication
+
# Key flow
provider "stackitprivatepreview" {
default_region = "eu01"
@@ -25,4 +22,3 @@ provider "stackitprivatepreview" {
service_account_key_path = var.service_account_key_path
private_key_path = var.private_key_path
}
-
diff --git a/examples/resources/stackitprivatepreview_postgresflexalpha_database/resource.tf b/examples/resources/stackitprivatepreview_postgresflexalpha_database/resource.tf
index 4dac8bfe..ad0c051e 100644
--- a/examples/resources/stackitprivatepreview_postgresflexalpha_database/resource.tf
+++ b/examples/resources/stackitprivatepreview_postgresflexalpha_database/resource.tf
@@ -1,5 +1,3 @@
-# Copyright (c) STACKIT
-
resource "stackitprivatepreview_postgresflexalpha_database" "example" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
@@ -11,4 +9,14 @@ resource "stackitprivatepreview_postgresflexalpha_database" "example" {
import {
to = stackitprivatepreview_postgresflexalpha_database.import-example
id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.postgres_database_id}"
-}
\ No newline at end of file
+}
+
+import {
+ to = stackitprivatepreview_postgresflexalpha_database.import-example
+ identity = {
+ project_id = "project_id"
+ region = "region"
+ instance_id = "instance_id"
+ database_id = "database_id"
+ }
+}
diff --git a/examples/resources/stackitprivatepreview_postgresflexalpha_instance/resource.tf b/examples/resources/stackitprivatepreview_postgresflexalpha_instance/resource.tf
index e65f8073..b503f0ce 100644
--- a/examples/resources/stackitprivatepreview_postgresflexalpha_instance/resource.tf
+++ b/examples/resources/stackitprivatepreview_postgresflexalpha_instance/resource.tf
@@ -1,24 +1,39 @@
-# Copyright (c) STACKIT
-
-resource "stackitprivatepreview_postgresflexalpha_instance" "example" {
+resource "stackitprivatepreview_postgresflexalpha_instance" "example-instance" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
name = "example-instance"
acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
- backup_schedule = "00 00 * * *"
- flavor = {
- cpu = 2
- ram = 4
- }
- replicas = 3
+ backup_schedule = "0 0 * * *"
+ retention_days = 30
+ flavor_id = "flavor.id"
+ replicas = 1
storage = {
- class = "class"
- size = 5
+ performance_class = "premium-perf2-stackit"
+ size = 10
}
- version = 14
+ encryption = {
+ kek_key_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ kek_key_ring_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ kek_key_version = 1
+ service_account = "service@account.email"
+ }
+ network = {
+ acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
+ access_scope = "PUBLIC"
+ }
+ version = 17
}
# Only use the import statement, if you want to import an existing postgresflex instance
import {
to = stackitprivatepreview_postgresflexalpha_instance.import-example
id = "${var.project_id},${var.region},${var.postgres_instance_id}"
-}
\ No newline at end of file
+}
+
+import {
+ to = stackitprivatepreview_postgresflexalpha_instance.import-example
+ identity = {
+ project_id = var.project_id
+ region = var.region
+ instance_id = var.postgres_instance_id
+ }
+}
diff --git a/examples/resources/stackitprivatepreview_postgresflexalpha_user/resource.tf b/examples/resources/stackitprivatepreview_postgresflexalpha_user/resource.tf
index 5ab8c922..695741c4 100644
--- a/examples/resources/stackitprivatepreview_postgresflexalpha_user/resource.tf
+++ b/examples/resources/stackitprivatepreview_postgresflexalpha_user/resource.tf
@@ -1,9 +1,7 @@
-# Copyright (c) STACKIT
-
resource "stackitprivatepreview_postgresflexalpha_user" "example" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
- username = "username"
+ name = "username"
roles = ["role"]
}
@@ -11,4 +9,14 @@ resource "stackitprivatepreview_postgresflexalpha_user" "example" {
import {
to = stackitprivatepreview_postgresflexalpha_user.import-example
id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.user_id}"
-}
\ No newline at end of file
+}
+
+import {
+ to = stackitprivatepreview_postgresflexalpha_user.import-example
+ identity = {
+ project_id = "project.id"
+ region = "region"
+ instance_id = "instance.id"
+ user_id = "user.id"
+ }
+}
diff --git a/examples/resources/stackitprivatepreview_sqlserverflexalpha_database/resource.tf b/examples/resources/stackitprivatepreview_sqlserverflexalpha_database/resource.tf
new file mode 100644
index 00000000..b85cc22b
--- /dev/null
+++ b/examples/resources/stackitprivatepreview_sqlserverflexalpha_database/resource.tf
@@ -0,0 +1,24 @@
+resource "stackitprivatepreview_sqlserverflexalpha_database" "example" {
+ project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ collation = ""
+ compatibility = "160"
+ name = ""
+ owner = ""
+}
+
+# Only use the import statement, if you want to import a existing sqlserverflex database
+import {
+ to = stackitprivatepreview_sqlserverflexalpha_database.import-example
+ id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}"
+}
+
+import {
+ to = stackitprivatepreview_sqlserverflexalpha_database.import-example
+ identity = {
+ project_id = "project.id"
+ region = "region"
+ instance_id = "instance.id"
+ database_id = "database.id"
+ }
+}
\ No newline at end of file
diff --git a/examples/resources/stackitprivatepreview_sqlserverflexalpha_instance/resource.tf b/examples/resources/stackitprivatepreview_sqlserverflexalpha_instance/resource.tf
index 059948d0..3cc861d3 100644
--- a/examples/resources/stackitprivatepreview_sqlserverflexalpha_instance/resource.tf
+++ b/examples/resources/stackitprivatepreview_sqlserverflexalpha_instance/resource.tf
@@ -1,5 +1,3 @@
-# Copyright (c) STACKIT
-
resource "stackitprivatepreview_sqlserverflexalpha_instance" "example" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
name = "example-instance"
diff --git a/examples/resources/stackitprivatepreview_sqlserverflexalpha_user/resource.tf b/examples/resources/stackitprivatepreview_sqlserverflexalpha_user/resource.tf
index b328576c..83c52561 100644
--- a/examples/resources/stackitprivatepreview_sqlserverflexalpha_user/resource.tf
+++ b/examples/resources/stackitprivatepreview_sqlserverflexalpha_user/resource.tf
@@ -1,5 +1,3 @@
-# Copyright (c) STACKIT
-
resource "stackitprivatepreview_sqlserverflexalpha_user" "example" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
diff --git a/examples/resources/stackitprivatepreview_sqlserverflexbeta_database/resource.tf b/examples/resources/stackitprivatepreview_sqlserverflexbeta_database/resource.tf
new file mode 100644
index 00000000..83c52561
--- /dev/null
+++ b/examples/resources/stackitprivatepreview_sqlserverflexbeta_database/resource.tf
@@ -0,0 +1,12 @@
+resource "stackitprivatepreview_sqlserverflexalpha_user" "example" {
+ project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ username = "username"
+ roles = ["role"]
+}
+
+# Only use the import statement, if you want to import an existing sqlserverflex user
+import {
+ to = stackitprivatepreview_sqlserverflexalpha_user.import-example
+ id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}"
+}
\ No newline at end of file
diff --git a/examples/resources/stackitprivatepreview_sqlserverflexbeta_instance/resource.tf b/examples/resources/stackitprivatepreview_sqlserverflexbeta_instance/resource.tf
new file mode 100644
index 00000000..06e88f64
--- /dev/null
+++ b/examples/resources/stackitprivatepreview_sqlserverflexbeta_instance/resource.tf
@@ -0,0 +1,76 @@
+# without encryption and SNA
+resource "stackitprivatepreview_sqlserverflexbeta_instance" "instance" {
+ project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ name = "example-instance"
+ backup_schedule = "0 3 * * *"
+ retention_days = 31
+ flavor_id = "flavor_id"
+ storage = {
+ class = "premium-perf2-stackit"
+ size = 50
+ }
+ version = 2022
+ network = {
+ acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
+ access_scope = "SNA"
+ }
+}
+
+# without encryption and PUBLIC
+resource "stackitprivatepreview_sqlserverflexbeta_instance" "instance" {
+ project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ name = "example-instance"
+ backup_schedule = "0 3 * * *"
+ retention_days = 31
+ flavor_id = "flavor_id"
+ storage = {
+ class = "premium-perf2-stackit"
+ size = 50
+ }
+ version = 2022
+ network = {
+ acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
+ access_scope = "PUBLIC"
+ }
+}
+
+# with encryption and SNA
+resource "stackitprivatepreview_sqlserverflexbeta_instance" "instance" {
+ project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ name = "example-instance"
+ backup_schedule = "0 3 * * *"
+ retention_days = 31
+ flavor_id = "flavor_id"
+ storage = {
+ class = "premium-perf2-stackit"
+ size = 50
+ }
+ version = 2022
+ encryption = {
+ kek_key_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ kek_key_ring_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ kek_key_version = 1
+ service_account = "service_account@email"
+ }
+ network = {
+ acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
+ access_scope = "SNA"
+ }
+}
+
+
+# Only use the import statement, if you want to import an existing sqlserverflex instance
+import {
+ to = stackitprivatepreview_sqlserverflexalpha_instance.import-example
+ id = "${var.project_id},${var.region},${var.sql_instance_id}"
+}
+
+# import with identity
+import {
+ to = stackitprivatepreview_sqlserverflexalpha_instance.import-example
+ identity = {
+ project_id = var.project_id
+ region = var.region
+ instance_id = var.sql_instance_id
+ }
+}
diff --git a/examples/resources/stackitprivatepreview_sqlserverflexbeta_user/resource.tf b/examples/resources/stackitprivatepreview_sqlserverflexbeta_user/resource.tf
new file mode 100644
index 00000000..83c52561
--- /dev/null
+++ b/examples/resources/stackitprivatepreview_sqlserverflexbeta_user/resource.tf
@@ -0,0 +1,12 @@
+resource "stackitprivatepreview_sqlserverflexalpha_user" "example" {
+ project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ username = "username"
+ roles = ["role"]
+}
+
+# Only use the import statement, if you want to import an existing sqlserverflex user
+import {
+ to = stackitprivatepreview_sqlserverflexalpha_user.import-example
+ id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}"
+}
\ No newline at end of file
diff --git a/go.mod b/go.mod
index d3409ce0..d4cfe7c4 100644
--- a/go.mod
+++ b/go.mod
@@ -1,156 +1,302 @@
-module github.com/stackitcloud/terraform-provider-stackit
+module tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview
+
+go 1.25.6
+
-go 1.24.0
require (
+ github.com/SladkyCitron/slogcolor v1.8.0
+ github.com/golang-jwt/jwt/v5 v5.3.1
+ github.com/golangci/golangci-lint/v2 v2.10.1
github.com/google/go-cmp v0.7.0
github.com/google/uuid v1.6.0
- github.com/gorilla/mux v1.8.1
+ github.com/hashicorp/terraform-plugin-codegen-framework v0.4.1
+ github.com/hashicorp/terraform-plugin-codegen-openapi v0.3.0
+ github.com/hashicorp/terraform-plugin-docs v0.24.0
github.com/hashicorp/terraform-plugin-framework v1.17.0
github.com/hashicorp/terraform-plugin-framework-validators v0.19.0
github.com/hashicorp/terraform-plugin-go v0.29.0
github.com/hashicorp/terraform-plugin-log v0.10.0
github.com/hashicorp/terraform-plugin-testing v1.14.0
- github.com/stackitcloud/stackit-sdk-go/core v0.20.1
- github.com/stackitcloud/stackit-sdk-go/services/cdn v1.6.0
- github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.1
- github.com/stackitcloud/stackit-sdk-go/services/git v0.8.0
- github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.0
- github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.21-alpha
- github.com/stackitcloud/stackit-sdk-go/services/kms v1.0.0
- github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.6.0
- github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.1
- github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.1
- github.com/stackitcloud/stackit-sdk-go/services/modelserving v0.6.0
- github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.2
- github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.4.0
- github.com/stackitcloud/stackit-sdk-go/services/observability v0.15.0
- github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.1
- github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.2.1
- github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.25.1
- github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.1
- github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.18.2
- github.com/stackitcloud/stackit-sdk-go/services/scf v0.2.1
- github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.13.1
- github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.2
- github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.1
- github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.11.1
- github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.2
- github.com/stackitcloud/stackit-sdk-go/services/ske v1.4.0
- github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.3.3
+ github.com/iancoleman/strcase v0.3.0
+ github.com/ivanpirog/coloredcobra v1.0.1
+ github.com/jarcoal/httpmock v1.4.1
+ github.com/joho/godotenv v1.5.1
+ github.com/ldez/go-git-cmd-wrapper/v2 v2.9.1
+ github.com/spf13/cobra v1.10.2
+ github.com/stackitcloud/stackit-sdk-go/core v0.21.1
+ github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha
github.com/teambition/rrule-go v1.8.2
- golang.org/x/mod v0.31.0
+ golang.org/x/tools v0.42.0
+ gopkg.in/yaml.v3 v3.0.1
)
+require github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
+
require (
- github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
- github.com/BurntSushi/toml v1.2.1 // indirect
+ 4d63.com/gocheckcompilerdirectives v1.3.0 // indirect
+ 4d63.com/gochecknoglobals v0.2.2 // indirect
+ codeberg.org/chavacava/garif v0.2.0 // indirect
+ codeberg.org/polyfloyd/go-errorlint v1.9.0 // indirect
+ dario.cat/mergo v1.0.1 // indirect
+ dev.gaijin.team/go/exhaustruct/v4 v4.0.0 // indirect
+ dev.gaijin.team/go/golib v0.6.0 // indirect
+ github.com/4meepo/tagalign v1.4.3 // indirect
+ github.com/Abirdcfly/dupword v0.1.7 // indirect
+ github.com/AdminBenni/iota-mixing v1.0.0 // indirect
+ github.com/AlwxSin/noinlineerr v1.0.5 // indirect
+ github.com/Antonboom/errname v1.1.1 // indirect
+ github.com/Antonboom/nilnil v1.1.1 // indirect
+ github.com/Antonboom/testifylint v1.6.4 // indirect
+ github.com/BurntSushi/toml v1.6.0 // indirect
+ github.com/Djarvur/go-err113 v0.1.1 // indirect
github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
- github.com/Masterminds/semver/v3 v3.2.0 // indirect
+ github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
- github.com/armon/go-radix v1.0.0 // indirect
- github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect
- github.com/bgentry/speakeasy v0.1.0 // indirect
- github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect
- github.com/bradleyfalzon/ghinstallation/v2 v2.5.0 // indirect
- github.com/cli/go-gh/v2 v2.11.2 // indirect
- github.com/cli/safeexec v1.0.0 // indirect
- github.com/fsnotify/fsnotify v1.5.4 // indirect
- github.com/go-openapi/errors v0.20.2 // indirect
- github.com/go-openapi/strfmt v0.21.3 // indirect
- github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
- github.com/google/go-github/v45 v45.2.0 // indirect
- github.com/google/go-github/v53 v53.0.0 // indirect
- github.com/google/go-querystring v1.1.0 // indirect
- github.com/hashicorp/cli v1.1.7 // indirect
- github.com/hashicorp/copywrite v0.22.0 // indirect
- github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
- github.com/hashicorp/hcl v1.0.0 // indirect
- github.com/hashicorp/terraform-plugin-docs v0.24.0 // indirect
- github.com/huandu/xstrings v1.3.3 // indirect
- github.com/imdario/mergo v0.3.15 // indirect
- github.com/inconshreveable/mousetrap v1.0.1 // indirect
- github.com/jedib0t/go-pretty v4.3.0+incompatible // indirect
- github.com/jedib0t/go-pretty/v6 v6.4.6 // indirect
- github.com/joho/godotenv v1.3.0 // indirect
- github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
- github.com/knadh/koanf v1.5.0 // indirect
- github.com/kr/text v0.2.0 // indirect
- github.com/mattn/go-runewidth v0.0.15 // indirect
- github.com/mergestat/timediff v0.0.3 // indirect
- github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
- github.com/mitchellh/go-homedir v1.1.0 // indirect
- github.com/oklog/ulid v1.3.1 // indirect
- github.com/posener/complete v1.2.3 // indirect
- github.com/rivo/uniseg v0.4.7 // indirect
- github.com/samber/lo v1.37.0 // indirect
- github.com/shopspring/decimal v1.3.1 // indirect
- github.com/spf13/cast v1.5.0 // indirect
- github.com/spf13/cobra v1.6.1 // indirect
- github.com/spf13/pflag v1.0.5 // indirect
- github.com/thanhpk/randstr v1.0.4 // indirect
- github.com/yuin/goldmark v1.7.7 // indirect
- github.com/yuin/goldmark-meta v1.1.0 // indirect
- go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
- go.mongodb.org/mongo-driver v1.10.0 // indirect
- golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
- golang.org/x/oauth2 v0.30.0 // indirect
- golang.org/x/telemetry v0.0.0-20251203150158-8fff8a5912fc // indirect
- golang.org/x/term v0.38.0 // indirect
- gopkg.in/yaml.v2 v2.4.0 // indirect
- gopkg.in/yaml.v3 v3.0.1 // indirect
-)
-
-require (
- github.com/ProtonMail/go-crypto v1.1.6 // indirect
- github.com/agext/levenshtein v1.2.2 // indirect
+ github.com/MirrexOne/unqueryvet v1.5.3 // indirect
+ github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect
+ github.com/ProtonMail/go-crypto v1.3.0 // indirect
+ github.com/agext/levenshtein v1.2.3 // indirect
+ github.com/alecthomas/chroma/v2 v2.23.1 // indirect
+ github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
+ github.com/alexkohler/nakedret/v2 v2.0.6 // indirect
+ github.com/alexkohler/prealloc v1.0.2 // indirect
+ github.com/alfatraining/structtag v1.0.0 // indirect
+ github.com/alingse/asasalint v0.0.11 // indirect
+ github.com/alingse/nilnesserr v0.2.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
- github.com/cloudflare/circl v1.6.1 // indirect
+ github.com/armon/go-radix v1.0.0 // indirect
+ github.com/ashanbrown/forbidigo/v2 v2.3.0 // indirect
+ github.com/ashanbrown/makezero/v2 v2.1.0 // indirect
+ github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
+ github.com/bahlo/generic-list-go v0.2.0 // indirect
+ github.com/beorn7/perks v1.0.1 // indirect
+ github.com/bgentry/speakeasy v0.1.0 // indirect
+ github.com/bkielbasa/cyclop v1.2.3 // indirect
+ github.com/blizzy78/varnamelen v0.8.0 // indirect
+ github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect
+ github.com/bombsimon/wsl/v4 v4.7.0 // indirect
+ github.com/bombsimon/wsl/v5 v5.6.0 // indirect
+ github.com/breml/bidichk v0.3.3 // indirect
+ github.com/breml/errchkjson v0.4.1 // indirect
+ github.com/buger/jsonparser v1.1.1 // indirect
+ github.com/butuzov/ireturn v0.4.0 // indirect
+ github.com/butuzov/mirror v1.3.0 // indirect
+ github.com/catenacyber/perfsprint v0.10.1 // indirect
+ github.com/ccojocar/zxcvbn-go v1.0.4 // indirect
+ github.com/cespare/xxhash/v2 v2.3.0 // indirect
+ github.com/charithe/durationcheck v0.0.11 // indirect
+ github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
+ github.com/charmbracelet/lipgloss v1.1.0 // indirect
+ github.com/charmbracelet/x/ansi v0.10.1 // indirect
+ github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
+ github.com/charmbracelet/x/term v0.2.1 // indirect
+ github.com/ckaznocha/intrange v0.3.1 // indirect
+ github.com/cloudflare/circl v1.6.3 // indirect
+ github.com/curioswitch/go-reassign v0.3.0 // indirect
+ github.com/daixiang0/gci v0.13.7 // indirect
+ github.com/dave/dst v0.27.3 // indirect
+ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
+ github.com/denis-tingaikin/go-header v0.5.0 // indirect
+ github.com/dlclark/regexp2 v1.11.5 // indirect
+ github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
+ github.com/ettle/strcase v0.2.0 // indirect
github.com/fatih/color v1.18.0 // indirect
- github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
+ github.com/fatih/structtag v1.2.0 // indirect
+ github.com/firefart/nonamedreturns v1.0.6 // indirect
+ github.com/fsnotify/fsnotify v1.5.4 // indirect
+ github.com/fzipp/gocyclo v0.6.0 // indirect
+ github.com/ghostiam/protogetter v0.3.20 // indirect
+ github.com/go-critic/go-critic v0.14.3 // indirect
+ github.com/go-toolsmith/astcast v1.1.0 // indirect
+ github.com/go-toolsmith/astcopy v1.1.0 // indirect
+ github.com/go-toolsmith/astequal v1.2.0 // indirect
+ github.com/go-toolsmith/astfmt v1.1.0 // indirect
+ github.com/go-toolsmith/astp v1.1.0 // indirect
+ github.com/go-toolsmith/strparse v1.1.0 // indirect
+ github.com/go-toolsmith/typep v1.1.0 // indirect
+ github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
+ github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
+ github.com/gobwas/glob v0.2.3 // indirect
+ github.com/godoc-lint/godoc-lint v0.11.2 // indirect
+ github.com/gofrs/flock v0.13.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
+ github.com/golangci/asciicheck v0.5.0 // indirect
+ github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 // indirect
+ github.com/golangci/go-printf-func-name v0.1.1 // indirect
+ github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
+ github.com/golangci/golines v0.15.0 // indirect
+ github.com/golangci/misspell v0.8.0 // indirect
+ github.com/golangci/plugin-module-register v0.1.2 // indirect
+ github.com/golangci/revgrep v0.8.0 // indirect
+ github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e // indirect
+ github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect
+ github.com/gordonklaus/ineffassign v0.2.0 // indirect
+ github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
+ github.com/gostaticanalysis/comment v1.5.0 // indirect
+ github.com/gostaticanalysis/forcetypeassert v0.2.0 // indirect
+ github.com/gostaticanalysis/nilerr v0.1.2 // indirect
+ github.com/hashicorp/cli v1.1.7 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.5.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
+ github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.7.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
- github.com/hashicorp/go-version v1.7.0 // indirect
- github.com/hashicorp/hc-install v0.9.2 // indirect
+ github.com/hashicorp/go-version v1.8.0 // indirect
+ github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
+ github.com/hashicorp/hc-install v0.9.3 // indirect
+ github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.24.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
- github.com/hashicorp/terraform-exec v0.24.0 // indirect
+ github.com/hashicorp/terraform-exec v0.25.0 // indirect
github.com/hashicorp/terraform-json v0.27.2 // indirect
- github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 // indirect
+ github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0 // indirect
+ github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.2 // indirect
github.com/hashicorp/terraform-registry-address v0.4.0 // indirect
- github.com/hashicorp/terraform-svchost v0.1.1 // indirect
+ github.com/hashicorp/terraform-svchost v0.2.0 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
+ github.com/hexops/gotextdiff v1.0.3 // indirect
+ github.com/huandu/xstrings v1.4.0 // indirect
+ github.com/imdario/mergo v0.3.16 // indirect
+ github.com/inconshreveable/mousetrap v1.1.0 // indirect
+ github.com/jgautheron/goconst v1.8.2 // indirect
+ github.com/jingyugao/rowserrcheck v1.1.1 // indirect
+ github.com/jjti/go-spancheck v0.6.5 // indirect
+ github.com/julz/importas v0.2.0 // indirect
+ github.com/karamaru-alpha/copyloopvar v1.2.2 // indirect
+ github.com/kisielk/errcheck v1.9.0 // indirect
+ github.com/kkHAIKE/contextcheck v1.1.6 // indirect
+ github.com/kulti/thelper v0.7.1 // indirect
+ github.com/kunwardeep/paralleltest v1.0.15 // indirect
+ github.com/lasiar/canonicalheader v1.1.2 // indirect
+ github.com/ldez/exptostd v0.4.5 // indirect
+ github.com/ldez/gomoddirectives v0.8.0 // indirect
+ github.com/ldez/grignotin v0.10.1 // indirect
+ github.com/ldez/structtags v0.6.1 // indirect
+ github.com/ldez/tagliatelle v0.7.2 // indirect
+ github.com/ldez/usetesting v0.5.0 // indirect
+ github.com/leonklingele/grouper v1.1.2 // indirect
+ github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
+ github.com/macabu/inamedparam v0.2.0 // indirect
+ github.com/magiconair/properties v1.8.6 // indirect
+ github.com/mailru/easyjson v0.7.7 // indirect
+ github.com/manuelarte/embeddedstructfieldcheck v0.4.0 // indirect
+ github.com/manuelarte/funcorder v0.5.0 // indirect
+ github.com/maratori/testableexamples v1.0.1 // indirect
+ github.com/maratori/testpackage v1.1.2 // indirect
+ github.com/matoous/godox v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
+ github.com/mattn/go-runewidth v0.0.16 // indirect
+ github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
+ github.com/mgechev/revive v1.14.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
+ github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
+ github.com/moricho/tparallel v0.3.2 // indirect
+ github.com/muesli/termenv v0.16.0 // indirect
+ github.com/nakabonne/nestif v0.3.1 // indirect
+ github.com/nishanths/exhaustive v0.12.0 // indirect
+ github.com/nishanths/predeclared v0.2.2 // indirect
+ github.com/nunnatsa/ginkgolinter v0.23.0 // indirect
github.com/oklog/run v1.2.0 // indirect
- github.com/stackitcloud/stackit-sdk-go/services/authorization v0.9.0
+ github.com/pb33f/libopenapi v0.15.0 // indirect
+ github.com/pelletier/go-toml v1.9.5 // indirect
+ github.com/pelletier/go-toml/v2 v2.2.4 // indirect
+ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
+ github.com/posener/complete v1.2.3 // indirect
+ github.com/prometheus/client_golang v1.12.1 // indirect
+ github.com/prometheus/client_model v0.2.0 // indirect
+ github.com/prometheus/common v0.32.1 // indirect
+ github.com/prometheus/procfs v0.7.3 // indirect
+ github.com/quasilyte/go-ruleguard v0.4.5 // indirect
+ github.com/quasilyte/go-ruleguard/dsl v0.3.23 // indirect
+ github.com/quasilyte/gogrep v0.5.0 // indirect
+ github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
+ github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
+ github.com/raeperd/recvcheck v0.2.0 // indirect
+ github.com/rivo/uniseg v0.4.7 // indirect
+ github.com/rogpeppe/go-internal v1.14.1 // indirect
+ github.com/ryancurrah/gomodguard v1.4.1 // indirect
+ github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
+ github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect
+ github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect
+ github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
+ github.com/sashamelentyev/usestdlibvars v1.29.0 // indirect
+ github.com/securego/gosec/v2 v2.23.0 // indirect
+ github.com/shopspring/decimal v1.3.1 // indirect
+ github.com/sirupsen/logrus v1.9.4 // indirect
+ github.com/sivchari/containedctx v1.0.3 // indirect
+ github.com/sonatard/noctx v0.4.0 // indirect
+ github.com/sourcegraph/go-diff v0.7.0 // indirect
+ github.com/spf13/afero v1.15.0 // indirect
+ github.com/spf13/cast v1.5.1 // indirect
+ github.com/spf13/jwalterweatherman v1.1.0 // indirect
+ github.com/spf13/pflag v1.0.10 // indirect
+ github.com/spf13/viper v1.12.0 // indirect
+ github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
+ github.com/stbenjam/no-sprintf-host-port v0.3.1 // indirect
+ github.com/stretchr/objx v0.5.2 // indirect
+ github.com/stretchr/testify v1.11.1 // indirect
+ github.com/subosito/gotenv v1.4.1 // indirect
+ github.com/tetafro/godot v1.5.4 // indirect
+ github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 // indirect
+ github.com/timonwong/loggercheck v0.11.0 // indirect
+ github.com/tomarrell/wrapcheck/v2 v2.12.0 // indirect
+ github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
+ github.com/ultraware/funlen v0.2.0 // indirect
+ github.com/ultraware/whitespace v0.2.0 // indirect
+ github.com/uudashr/gocognit v1.2.0 // indirect
+ github.com/uudashr/iface v1.4.1 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
+ github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect
+ github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
+ github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
+ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
+ github.com/xeipuuv/gojsonschema v1.2.0 // indirect
+ github.com/xen0n/gosmopolitan v1.3.0 // indirect
+ github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
+ github.com/yagipy/maintidx v1.0.0 // indirect
+ github.com/yeya24/promlinter v0.3.0 // indirect
+ github.com/ykadowak/zerologlint v0.1.5 // indirect
+ github.com/yuin/goldmark v1.7.7 // indirect
+ github.com/yuin/goldmark-meta v1.1.0 // indirect
github.com/zclconf/go-cty v1.17.0 // indirect
- golang.org/x/crypto v0.46.0 // indirect
- golang.org/x/net v0.48.0 // indirect
+ gitlab.com/bosi/decorder v0.4.2 // indirect
+ go-simpler.org/musttag v0.14.0 // indirect
+ go-simpler.org/sloglint v0.11.1 // indirect
+ go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
+ go.augendre.info/arangolint v0.4.0 // indirect
+ go.augendre.info/fatcontext v0.9.0 // indirect
+ go.uber.org/multierr v1.10.0 // indirect
+ go.uber.org/zap v1.27.0 // indirect
+ go.yaml.in/yaml/v3 v3.0.4 // indirect
+ golang.org/x/crypto v0.48.0 // indirect
+ golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
+ golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 // indirect
+ golang.org/x/mod v0.33.0 // indirect
+ golang.org/x/net v0.50.0 // indirect
golang.org/x/sync v0.19.0 // indirect
- golang.org/x/sys v0.39.0 // indirect
- golang.org/x/text v0.32.0 // indirect
- golang.org/x/tools v0.40.0 // indirect
+ golang.org/x/sys v0.41.0 // indirect
+ golang.org/x/telemetry v0.0.0-20260209163413-e7419c687ee4 // indirect
+ golang.org/x/text v0.34.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
- google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
- google.golang.org/grpc v1.75.1 // indirect
- google.golang.org/protobuf v1.36.9 // indirect
+ google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 // indirect
+ google.golang.org/grpc v1.79.1 // indirect
+ google.golang.org/protobuf v1.36.11 // indirect
+ gopkg.in/ini.v1 v1.67.0 // indirect
+ gopkg.in/yaml.v2 v2.4.0 // indirect
+ honnef.co/go/tools v0.7.0 // indirect
+ mvdan.cc/gofumpt v0.9.2 // indirect
+ mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15 // indirect
)
-
-tool golang.org/x/tools/cmd/goimports
diff --git a/go.sum b/go.sum
index b87cbdf3..00f1e6ff 100644
--- a/go.sum
+++ b/go.sum
@@ -1,122 +1,247 @@
+4d63.com/gocheckcompilerdirectives v1.3.0 h1:Ew5y5CtcAAQeTVKUVFrE7EwHMrTO6BggtEj8BZSjZ3A=
+4d63.com/gocheckcompilerdirectives v1.3.0/go.mod h1:ofsJ4zx2QAuIP/NO/NAh1ig6R1Fb18/GI7RVMwz7kAY=
+4d63.com/gochecknoglobals v0.2.2 h1:H1vdnwnMaZdQW/N+NrkT1SZMTBmcwHe9Vq8lJcYYTtU=
+4d63.com/gochecknoglobals v0.2.2/go.mod h1:lLxwTQjL5eIesRbvnzIP3jZtG140FnTdz+AlMa+ogt0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
-dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
-dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
-github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
-github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
+cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
+cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
+cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
+cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
+cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
+cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
+cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
+cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
+cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
+cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
+cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
+cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
+cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
+cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
+cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
+cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
+cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
+cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
+cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
+cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
+cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
+cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
+cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
+cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
+cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
+cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
+cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
+cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
+cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
+cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
+codeberg.org/chavacava/garif v0.2.0 h1:F0tVjhYbuOCnvNcU3YSpO6b3Waw6Bimy4K0mM8y6MfY=
+codeberg.org/chavacava/garif v0.2.0/go.mod h1:P2BPbVbT4QcvLZrORc2T29szK3xEOlnl0GiPTJmEqBQ=
+codeberg.org/polyfloyd/go-errorlint v1.9.0 h1:VkdEEmA1VBpH6ecQoMR4LdphVI3fA4RrCh2an7YmodI=
+codeberg.org/polyfloyd/go-errorlint v1.9.0/go.mod h1:GPRRu2LzVijNn4YkrZYJfatQIdS+TrcK8rL5Xs24qw8=
+dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
+dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
+dev.gaijin.team/go/exhaustruct/v4 v4.0.0 h1:873r7aNneqoBB3IaFIzhvt2RFYTuHgmMjoKfwODoI1Y=
+dev.gaijin.team/go/exhaustruct/v4 v4.0.0/go.mod h1:aZ/k2o4Y05aMJtiux15x8iXaumE88YdiB0Ai4fXOzPI=
+dev.gaijin.team/go/golib v0.6.0 h1:v6nnznFTs4bppib/NyU1PQxobwDHwCXXl15P7DV5Zgo=
+dev.gaijin.team/go/golib v0.6.0/go.mod h1:uY1mShx8Z/aNHWDyAkZTkX+uCi5PdX7KsG1eDQa2AVE=
+dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
+github.com/4meepo/tagalign v1.4.3 h1:Bnu7jGWwbfpAie2vyl63Zup5KuRv21olsPIha53BJr8=
+github.com/4meepo/tagalign v1.4.3/go.mod h1:00WwRjiuSbrRJnSVeGWPLp2epS5Q/l4UEy0apLLS37c=
+github.com/Abirdcfly/dupword v0.1.7 h1:2j8sInznrje4I0CMisSL6ipEBkeJUJAmK1/lfoNGWrQ=
+github.com/Abirdcfly/dupword v0.1.7/go.mod h1:K0DkBeOebJ4VyOICFdppB23Q0YMOgVafM0zYW0n9lF4=
+github.com/AdminBenni/iota-mixing v1.0.0 h1:Os6lpjG2dp/AE5fYBPAA1zfa2qMdCAWwPMCgpwKq7wo=
+github.com/AdminBenni/iota-mixing v1.0.0/go.mod h1:i4+tpAaB+qMVIV9OK3m4/DAynOd5bQFaOu+2AhtBCNY=
+github.com/AlwxSin/noinlineerr v1.0.5 h1:RUjt63wk1AYWTXtVXbSqemlbVTb23JOSRiNsshj7TbY=
+github.com/AlwxSin/noinlineerr v1.0.5/go.mod h1:+QgkkoYrMH7RHvcdxdlI7vYYEdgeoFOVjU9sUhw/rQc=
+github.com/Antonboom/errname v1.1.1 h1:bllB7mlIbTVzO9jmSWVWLjxTEbGBVQ1Ff/ClQgtPw9Q=
+github.com/Antonboom/errname v1.1.1/go.mod h1:gjhe24xoxXp0ScLtHzjiXp0Exi1RFLKJb0bVBtWKCWQ=
+github.com/Antonboom/nilnil v1.1.1 h1:9Mdr6BYd8WHCDngQnNVV0b554xyisFioEKi30sksufQ=
+github.com/Antonboom/nilnil v1.1.1/go.mod h1:yCyAmSw3doopbOWhJlVci+HuyNRuHJKIv6V2oYQa8II=
+github.com/Antonboom/testifylint v1.6.4 h1:gs9fUEy+egzxkEbq9P4cpcMB6/G0DYdMeiFS87UiqmQ=
+github.com/Antonboom/testifylint v1.6.4/go.mod h1:YO33FROXX2OoUfwjz8g+gUxQXio5i9qpVy7nXGbxDD4=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
-github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
+github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
+github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
+github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
+github.com/Djarvur/go-err113 v0.1.1 h1:eHfopDqXRwAi+YmCUas75ZE0+hoBHJ2GQNLYRSxao4g=
+github.com/Djarvur/go-err113 v0.1.1/go.mod h1:IaWJdYFLg76t2ihfflPZnM1LIQszWOsFDh2hhhAVF6k=
github.com/Kunde21/markdownfmt/v3 v3.1.0 h1:KiZu9LKs+wFFBQKhrZJrFZwtLnCCWJahL+S+E/3VnM0=
github.com/Kunde21/markdownfmt/v3 v3.1.0/go.mod h1:tPXN1RTyOzJwhfHoon9wUr4HGYmWgVxSQN6VBJDkrVc=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
-github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
+github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
+github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
-github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
-github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g=
-github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw=
-github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
-github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
-github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
+github.com/MirrexOne/unqueryvet v1.5.3 h1:LpT3rsH+IY3cQddWF9bg4C7jsbASdGnrOSofY8IPEiw=
+github.com/MirrexOne/unqueryvet v1.5.3/go.mod h1:fs9Zq6eh1LRIhsDIsxf9PONVUjYdFHdtkHIgZdJnyPU=
+github.com/OpenPeeDeeP/depguard/v2 v2.2.1 h1:vckeWVESWp6Qog7UZSARNqfu/cZqvki8zsuj3piCMx4=
+github.com/OpenPeeDeeP/depguard/v2 v2.2.1/go.mod h1:q4DKzC4UcVaAvcfd41CZh0PWpGgzrVxUYBlgKNGquUo=
+github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw=
+github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE=
+github.com/SladkyCitron/slogcolor v1.8.0 h1:ln4mUPfVhs7a/vZfjnKkz5YZ71Bg/KFWneS2hfFq6FM=
+github.com/SladkyCitron/slogcolor v1.8.0/go.mod h1:ft8LEVIl4isUkebakhv+ngNXJjWBumnwhXfxTLApf3M=
+github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
+github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
+github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
+github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
+github.com/alecthomas/chroma/v2 v2.23.1 h1:nv2AVZdTyClGbVQkIzlDm/rnhk1E9bU9nXwmZ/Vk/iY=
+github.com/alecthomas/chroma/v2 v2.23.1/go.mod h1:NqVhfBR0lte5Ouh3DcthuUCTUpDC9cxBOfyMbMQPs3o=
+github.com/alecthomas/go-check-sumtype v0.3.1 h1:u9aUvbGINJxLVXiFvHUlPEaD7VDULsrxJb4Aq31NLkU=
+github.com/alecthomas/go-check-sumtype v0.3.1/go.mod h1:A8TSiN3UPRw3laIgWEUOHHLPa6/r9MtoigdlP5h3K/E=
+github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
+github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
-github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
+github.com/alexkohler/nakedret/v2 v2.0.6 h1:ME3Qef1/KIKr3kWX3nti3hhgNxw6aqN5pZmQiFSsuzQ=
+github.com/alexkohler/nakedret/v2 v2.0.6/go.mod h1:l3RKju/IzOMQHmsEvXwkqMDzHHvurNQfAgE1eVmT40Q=
+github.com/alexkohler/prealloc v1.0.2 h1:MPo8cIkGkZytq7WNH9UHv3DIX1mPz1RatPXnZb0zHWQ=
+github.com/alexkohler/prealloc v1.0.2/go.mod h1:fT39Jge3bQrfA7nPMDngUfvUbQGQeJyGQnR+913SCig=
+github.com/alfatraining/structtag v1.0.0 h1:2qmcUqNcCoyVJ0up879K614L9PazjBSFruTB0GOFjCc=
+github.com/alfatraining/structtag v1.0.0/go.mod h1:p3Xi5SwzTi+Ryj64DqjLWz7XurHxbGsq6y3ubePJPus=
+github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw=
+github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I=
+github.com/alingse/nilnesserr v0.2.0 h1:raLem5KG7EFVb4UIDAXgrv3N2JIaffeKNtcEXkEWd/w=
+github.com/alingse/nilnesserr v0.2.0/go.mod h1:1xJPrXonEtX7wyTq8Dytns5P2hNzoWymVUIaKm4HNFg=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
-github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
-github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
-github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
-github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg=
-github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
-github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4=
-github.com/aws/aws-sdk-go-v2/config v1.8.3/go.mod h1:4AEiLtAb8kLs7vgw2ZV3p2VZ1+hBavOc84hqxVNpCyw=
-github.com/aws/aws-sdk-go-v2/credentials v1.4.3/go.mod h1:FNNC6nQZQUuyhq5aE5c7ata8o9e4ECGmS4lAXC7o1mQ=
-github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0/go.mod h1:gqlclDEZp4aqJOancXK6TN24aKhT0W0Ae9MHk3wzTMM=
-github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4/go.mod h1:ZcBrrI3zBKlhGFNYWvju0I3TR93I7YIgAfy82Fh4lcQ=
-github.com/aws/aws-sdk-go-v2/service/appconfig v1.4.2/go.mod h1:FZ3HkCe+b10uFZZkFdvf98LHW21k49W8o8J366lqVKY=
-github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2/go.mod h1:72HRZDLMtmVQiLG2tLfQcaWLCssELvGl+Zf2WVxMmR8=
-github.com/aws/aws-sdk-go-v2/service/sso v1.4.2/go.mod h1:NBvT9R1MEF+Ud6ApJKM0G+IkPchKS7p7c2YPKwHmBOk=
-github.com/aws/aws-sdk-go-v2/service/sts v1.7.2/go.mod h1:8EzeIqfWt2wWT4rJVu3f21TfrhJ8AEMzVybRNSb/b4g=
-github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
+github.com/ashanbrown/forbidigo/v2 v2.3.0 h1:OZZDOchCgsX5gvToVtEBoV2UWbFfI6RKQTir2UZzSxo=
+github.com/ashanbrown/forbidigo/v2 v2.3.0/go.mod h1:5p6VmsG5/1xx3E785W9fouMxIOkvY2rRV9nMdWadd6c=
+github.com/ashanbrown/makezero/v2 v2.1.0 h1:snuKYMbqosNokUKm+R6/+vOPs8yVAi46La7Ck6QYSaE=
+github.com/ashanbrown/makezero/v2 v2.1.0/go.mod h1:aEGT/9q3S8DHeE57C88z2a6xydvgx8J5hgXIGWgo0MY=
+github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
+github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
+github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
+github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
+github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
-github.com/bmatcuk/doublestar/v4 v4.6.0 h1:HTuxyug8GyFbRkrffIpzNCSK4luc0TY3wzXvzIZhEXc=
-github.com/bmatcuk/doublestar/v4 v4.6.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
+github.com/bkielbasa/cyclop v1.2.3 h1:faIVMIGDIANuGPWH031CZJTi2ymOQBULs9H21HSMa5w=
+github.com/bkielbasa/cyclop v1.2.3/go.mod h1:kHTwA9Q0uZqOADdupvcFJQtp/ksSnytRMe8ztxG8Fuo=
+github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M=
+github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k=
github.com/bmatcuk/doublestar/v4 v4.9.1 h1:X8jg9rRZmJd4yRy7ZeNDRnM+T3ZfHv15JiBJ/avrEXE=
github.com/bmatcuk/doublestar/v4 v4.9.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
-github.com/bradleyfalzon/ghinstallation/v2 v2.5.0 h1:yaYcGQ7yEIGbsJfW/9z7v1sLiZg/5rSNNXwmMct5XaE=
-github.com/bradleyfalzon/ghinstallation/v2 v2.5.0/go.mod h1:amcvPQMrRkWNdueWOjPytGL25xQGzox7425qMgzo+Vo=
+github.com/bombsimon/wsl/v4 v4.7.0 h1:1Ilm9JBPRczjyUs6hvOPKvd7VL1Q++PL8M0SXBDf+jQ=
+github.com/bombsimon/wsl/v4 v4.7.0/go.mod h1:uV/+6BkffuzSAVYD+yGyld1AChO7/EuLrCF/8xTiapg=
+github.com/bombsimon/wsl/v5 v5.6.0 h1:4z+/sBqC5vUmSp1O0mS+czxwH9+LKXtCWtHH9rZGQL8=
+github.com/bombsimon/wsl/v5 v5.6.0/go.mod h1:Uqt2EfrMj2NV8UGoN1f1Y3m0NpUVCsUdrNCdet+8LvU=
+github.com/breml/bidichk v0.3.3 h1:WSM67ztRusf1sMoqH6/c4OBCUlRVTKq+CbSeo0R17sE=
+github.com/breml/bidichk v0.3.3/go.mod h1:ISbsut8OnjB367j5NseXEGGgO/th206dVa427kR8YTE=
+github.com/breml/errchkjson v0.4.1 h1:keFSS8D7A2T0haP9kzZTi7o26r7kE3vymjZNeNDRDwg=
+github.com/breml/errchkjson v0.4.1/go.mod h1:a23OvR6Qvcl7DG/Z4o0el6BRAjKnaReoPQFciAl9U3s=
github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw=
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
-github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
-github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
+github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
+github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
+github.com/butuzov/ireturn v0.4.0 h1:+s76bF/PfeKEdbG8b54aCocxXmi0wvYdOVsWxVO7n8E=
+github.com/butuzov/ireturn v0.4.0/go.mod h1:ghI0FrCmap8pDWZwfPisFD1vEc56VKH4NpQUxDHta70=
+github.com/butuzov/mirror v1.3.0 h1:HdWCXzmwlQHdVhwvsfBb2Au0r3HyINry3bDWLYXiKoc=
+github.com/butuzov/mirror v1.3.0/go.mod h1:AEij0Z8YMALaq4yQj9CPPVYOyJQyiexpQEQgihajRfI=
+github.com/catenacyber/perfsprint v0.10.1 h1:u7Riei30bk46XsG8nknMhKLXG9BcXz3+3tl/WpKm0PQ=
+github.com/catenacyber/perfsprint v0.10.1/go.mod h1:DJTGsi/Zufpuus6XPGJyKOTMELe347o6akPvWG9Zcsc=
+github.com/ccojocar/zxcvbn-go v1.0.4 h1:FWnCIRMXPj43ukfX000kvBZvV6raSxakYr1nzyNrUcc=
+github.com/ccojocar/zxcvbn-go v1.0.4/go.mod h1:3GxGX+rHmueTUMvm5ium7irpyjmm7ikxYFOSJB21Das=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
-github.com/cli/go-gh/v2 v2.11.2 h1:oad1+sESTPNTiTvh3I3t8UmxuovNDxhwLzeMHk45Q9w=
-github.com/cli/go-gh/v2 v2.11.2/go.mod h1:vVFhi3TfjseIW26ED9itAR8gQK0aVThTm8sYrsZ5QTI=
-github.com/cli/safeexec v1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI=
-github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q=
+github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
+github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/charithe/durationcheck v0.0.11 h1:g1/EX1eIiKS57NTWsYtHDZ/APfeXKhye1DidBcABctk=
+github.com/charithe/durationcheck v0.0.11/go.mod h1:x5iZaixRNl8ctbM+3B2RrPG5t856TxRyVQEnbIEM2X4=
+github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
+github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
+github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
+github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
+github.com/charmbracelet/x/ansi v0.10.1 h1:rL3Koar5XvX0pHGfovN03f5cxLbCF2YvLeyz7D2jVDQ=
+github.com/charmbracelet/x/ansi v0.10.1/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
+github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
+github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
+github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
+github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
+github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
+github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
+github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
+github.com/ckaznocha/intrange v0.3.1 h1:j1onQyXvHUsPWujDH6WIjhyH26gkRt/txNlV7LspvJs=
+github.com/ckaznocha/intrange v0.3.1/go.mod h1:QVepyz1AkUoFQkpEqksSYpNpUo3c5W7nWh/s6SHIJJk=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
-github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
-github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
-github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
-github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
+github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
+github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
-github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
-github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
-github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
-github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
-github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
-github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
+github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
+github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
+github.com/curioswitch/go-reassign v0.3.0 h1:dh3kpQHuADL3cobV/sSGETA8DOv457dwl+fbBAhrQPs=
+github.com/curioswitch/go-reassign v0.3.0/go.mod h1:nApPCCTtqLJN/s8HfItCcKV0jIPwluBOvZP+dsJGA88=
github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s=
github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
+github.com/daixiang0/gci v0.13.7 h1:+0bG5eK9vlI08J+J/NWGbWPTNiXPG4WhNLJOkSxWITQ=
+github.com/daixiang0/gci v0.13.7/go.mod h1:812WVN6JLFY9S6Tv76twqmNqevN0pa3SX3nih0brVzQ=
+github.com/dave/dst v0.27.3 h1:P1HPoMza3cMEquVf9kKy8yXsFirry4zEnWOdYPOoIzY=
+github.com/dave/dst v0.27.3/go.mod h1:jHh6EOibnHgcUW3WjKHisiooEkYwqpHLBSX1iOBhEyc=
+github.com/dave/jennifer v1.7.1 h1:B4jJJDHelWcDhlRQxWeo0Npa/pYKBLrirAQoTN45txo=
+github.com/dave/jennifer v1.7.1/go.mod h1:nXbxhEmQfOZhWml3D1cDK5M1FLnMSozpbFN/m3RmGZc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
+github.com/denis-tingaikin/go-header v0.5.0 h1:SRdnP5ZKvcO9KKRP1KJrhFR3RrlGuD+42t4429eC9k8=
+github.com/denis-tingaikin/go-header v0.5.0/go.mod h1:mMenU5bWrok6Wl2UsZjy+1okegmwQ3UgWl4V1D8gjlY=
+github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
+github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
+github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960/go.mod h1:9HQzr9D/0PGwMEbC3d5AB7oi67+h4TsQqItC1GVYG58=
+github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 h1:PRxIJD8XjimM5aTknUK9w6DHLDox2r2M3DI4i2pnd3w=
+github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936/go.mod h1:ttYvX5qlB+mlV1okblJqcSMtR4c52UKxDiX9GRBS8+Q=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
-github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
-github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
-github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
+github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q=
+github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
-github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
+github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
+github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
+github.com/firefart/nonamedreturns v1.0.6 h1:vmiBcKV/3EqKY3ZiPxCINmpS431OcE1S47AQUwhrg8E=
+github.com/firefart/nonamedreturns v1.0.6/go.mod h1:R8NisJnSIpvPWheCq0mNRXJok6D8h7fagJTF8EMEwCo=
+github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
+github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
-github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
+github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo=
+github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA=
+github.com/ghostiam/protogetter v0.3.20 h1:oW7OPFit2FxZOpmMRPP9FffU4uUpfeE/rEdE1f+MzD0=
+github.com/ghostiam/protogetter v0.3.20/go.mod h1:FjIu5Yfs6FT391m+Fjp3fbAYJ6rkL/J6ySpZBfnODuI=
+github.com/go-critic/go-critic v0.14.3 h1:5R1qH2iFeo4I/RJU8vTezdqs08Egi4u5p6vOESA0pog=
+github.com/go-critic/go-critic v0.14.3/go.mod h1:xwntfW6SYAd7h1OqDzmN6hBX/JxsEKl5up/Y2bsxgVQ=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM=
github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU=
-github.com/go-git/go-git/v5 v5.14.0 h1:/MD3lCrGjCen5WfEAzKg00MJJffKhC8gzS80ycmCi60=
-github.com/go-git/go-git/v5 v5.14.0/go.mod h1:Z5Xhoia5PcWA3NF8vRLURn9E5FRhSl7dGj9ItW3Wk5k=
+github.com/go-git/go-git/v5 v5.16.5 h1:mdkuqblwr57kVfXri5TTH+nMFLNUxIj9Z7F5ykFbw5s=
+github.com/go-git/go-git/v5 v5.16.5/go.mod h1:QOMLpNf1qxuSY4StA/ArOdfFR2TrKEjJiye2kel2m+M=
+github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
-github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
@@ -124,31 +249,67 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
-github.com/go-openapi/errors v0.20.2 h1:dxy7PGTqEh94zj2E3h1cUmQQWiM1+aeCROfAr02EmK8=
-github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
-github.com/go-openapi/strfmt v0.21.3 h1:xwhj5X6CjXEZZHMWy1zKJxvW9AfHC9pkyUjLvHtKG7o=
-github.com/go-openapi/strfmt v0.21.3/go.mod h1:k+RzNO0Da+k3FrrynSNN8F7n/peCmQQqbbXjtDfvmGg=
+github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI=
+github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
-github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
+github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
+github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
+github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
+github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
-github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/go-toolsmith/astcast v1.1.0 h1:+JN9xZV1A+Re+95pgnMgDboWNVnIMMQXwfBwLRPgSC8=
+github.com/go-toolsmith/astcast v1.1.0/go.mod h1:qdcuFWeGGS2xX5bLM/c3U9lewg7+Zu4mr+xPwZIB4ZU=
+github.com/go-toolsmith/astcopy v1.1.0 h1:YGwBN0WM+ekI/6SS6+52zLDEf8Yvp3n2seZITCUBt5s=
+github.com/go-toolsmith/astcopy v1.1.0/go.mod h1:hXM6gan18VA1T/daUEHCFcYiW8Ai1tIwIzHY6srfEAw=
+github.com/go-toolsmith/astequal v1.0.3/go.mod h1:9Ai4UglvtR+4up+bAD4+hCj7iTo4m/OXVTSLnCyTAx4=
+github.com/go-toolsmith/astequal v1.1.0/go.mod h1:sedf7VIdCL22LD8qIvv7Nn9MuWJruQA/ysswh64lffQ=
+github.com/go-toolsmith/astequal v1.2.0 h1:3Fs3CYZ1k9Vo4FzFhwwewC3CHISHDnVUPC4x0bI2+Cw=
+github.com/go-toolsmith/astequal v1.2.0/go.mod h1:c8NZ3+kSFtFY/8lPso4v8LuJjdJiUFVnSuU3s0qrrDY=
+github.com/go-toolsmith/astfmt v1.1.0 h1:iJVPDPp6/7AaeLJEruMsBUlOYCmvg0MoCfJprsOmcco=
+github.com/go-toolsmith/astfmt v1.1.0/go.mod h1:OrcLlRwu0CuiIBp/8b5PYF9ktGVZUjlNMV634mhwuQ4=
+github.com/go-toolsmith/astp v1.1.0 h1:dXPuCl6u2llURjdPLLDxJeZInAeZ0/eZwFJmqZMnpQA=
+github.com/go-toolsmith/astp v1.1.0/go.mod h1:0T1xFGz9hicKs8Z5MfAqSUitoUYS30pDMsRVIDHs8CA=
+github.com/go-toolsmith/pkgload v1.2.2 h1:0CtmHq/02QhxcF7E9N5LIFcYFsMR5rdovfqTtRKkgIk=
+github.com/go-toolsmith/pkgload v1.2.2/go.mod h1:R2hxLNRKuAsiXCo2i5J6ZQPhnPMOVtU+f0arbFPWCus=
+github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8=
+github.com/go-toolsmith/strparse v1.1.0 h1:GAioeZUK9TGxnLS+qfdqNbA4z0SSm5zVNtCQiyP2Bvw=
+github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJin1rfoPS4lBSQ=
+github.com/go-toolsmith/typep v1.1.0 h1:fIRYDyF+JywLfqzyhdiHzRop/GQDxxNhLGQ6gFUNHus=
+github.com/go-toolsmith/typep v1.1.0/go.mod h1:fVIw+7zjdsMxDA3ITWnH1yOiw1rnTQKCsF/sk2H/qig=
+github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
+github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
+github.com/go-xmlfmt/xmlfmt v1.1.3 h1:t8Ey3Uy7jDSEisW2K3somuMKIpzktkWptA0iFCnRUWY=
+github.com/go-xmlfmt/xmlfmt v1.1.3/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM=
+github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
+github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
+github.com/godoc-lint/godoc-lint v0.11.2 h1:Bp0FkJWoSdNsBikdNgIcgtaoo+xz6I/Y9s5WSBQUeeM=
+github.com/godoc-lint/godoc-lint v0.11.2/go.mod h1:iVpGdL1JCikNH2gGeAn3Hh+AgN5Gx/I/cxV+91L41jo=
+github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw=
+github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
-github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
-github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
-github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
-github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
-github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
-github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
+github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
+github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
+github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
+github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
+github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
+github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
@@ -161,100 +322,127 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
-github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/golangci/asciicheck v0.5.0 h1:jczN/BorERZwK8oiFBOGvlGPknhvq0bjnysTj4nUfo0=
+github.com/golangci/asciicheck v0.5.0/go.mod h1:5RMNAInbNFw2krqN6ibBxN/zfRFa9S6tA1nPdM0l8qQ=
+github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 h1:WUvBfQL6EW/40l6OmeSBYQJNSif4O11+bmWEz+C7FYw=
+github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32/go.mod h1:NUw9Zr2Sy7+HxzdjIULge71wI6yEg1lWQr7Evcu8K0E=
+github.com/golangci/go-printf-func-name v0.1.1 h1:hIYTFJqAGp1iwoIfsNTpoq1xZAarogrvjO9AfiW3B4U=
+github.com/golangci/go-printf-func-name v0.1.1/go.mod h1:Es64MpWEZbh0UBtTAICOZiB+miW53w/K9Or/4QogJss=
+github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d h1:viFft9sS/dxoYY0aiOTsLKO2aZQAPT4nlQCsimGcSGE=
+github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d/go.mod h1:ivJ9QDg0XucIkmwhzCDsqcnxxlDStoTl89jDMIoNxKY=
+github.com/golangci/golangci-lint/v2 v2.10.1 h1:flhw5Px6ojbLyEFzXvJn5B2HEdkkRlkhE1SnmCbQBiE=
+github.com/golangci/golangci-lint/v2 v2.10.1/go.mod h1:dBsrOk6zj0vDhlTv+IiJGqkDokR24IVTS7W3EVfPTQY=
+github.com/golangci/golines v0.15.0 h1:Qnph25g8Y1c5fdo1X7GaRDGgnMHgnxh4Gk4VfPTtRx0=
+github.com/golangci/golines v0.15.0/go.mod h1:AZjXd23tbHMpowhtnGlj9KCNsysj72aeZVVHnVcZx10=
+github.com/golangci/misspell v0.8.0 h1:qvxQhiE2/5z+BVRo1kwYA8yGz+lOlu5Jfvtx2b04Jbg=
+github.com/golangci/misspell v0.8.0/go.mod h1:WZyyI2P3hxPY2UVHs3cS8YcllAeyfquQcKfdeE9AFVg=
+github.com/golangci/plugin-module-register v0.1.2 h1:e5WM6PO6NIAEcij3B053CohVp3HIYbzSuP53UAYgOpg=
+github.com/golangci/plugin-module-register v0.1.2/go.mod h1:1+QGTsKBvAIvPvoY/os+G5eoqxWn70HYDm2uvUyGuVw=
+github.com/golangci/revgrep v0.8.0 h1:EZBctwbVd0aMeRnNUsFogoyayvKHyxlV3CdUA46FX2s=
+github.com/golangci/revgrep v0.8.0/go.mod h1:U4R/s9dlXZsg8uJmaR1GrloUr14D7qDl8gi2iPXJH8k=
+github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e h1:ai0EfmVYE2bRA5htgAG9r7s3tHsfjIhN98WshBTJ9jM=
+github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e/go.mod h1:Vrn4B5oR9qRwM+f54koyeH3yzphlecwERs0el27Fr/s=
+github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e h1:gD6P7NEo7Eqtt0ssnqSJNNndxe69DOQ24A5h7+i3KpM=
+github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e/go.mod h1:h+wZwLjUTJnm/P2rwlbJdRPZXOzaT36/FwnPnY2inzc=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
-github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
-github.com/google/go-github/v45 v45.2.0 h1:5oRLszbrkvxDDqBCNj2hjDZMKmvexaZ1xw/FCD+K3FI=
-github.com/google/go-github/v45 v45.2.0/go.mod h1:FObaZJEDSTa/WGCzZ2Z3eoCDXWJKMenWWTrd8jrta28=
-github.com/google/go-github/v53 v53.0.0 h1:T1RyHbSnpHYnoF0ZYKiIPSgPtuJ8G6vgc0MKodXsQDQ=
-github.com/google/go-github/v53 v53.0.0/go.mod h1:XhFRObz+m/l+UCm9b7KSIC3lT3NWSXGt7mOsAWEloao=
-github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
-github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
+github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
+github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
+github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 h1:z2ogiKUYzX5Is6zr/vP9vJGqPwcdqsWjOt+V8J7+bTc=
+github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
+github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
-github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
-github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
-github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
+github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
+github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
+github.com/gordonklaus/ineffassign v0.2.0 h1:Uths4KnmwxNJNzq87fwQQDDnbNb7De00VOk9Nu0TySs=
+github.com/gordonklaus/ineffassign v0.2.0/go.mod h1:TIpymnagPSexySzs7F9FnO1XFTy8IT3a59vmZp5Y9Lw=
+github.com/gostaticanalysis/analysisutil v0.7.1 h1:ZMCjoue3DtDWQ5WyU16YbjbQEQ3VuzwxALrpYd+HeKk=
+github.com/gostaticanalysis/analysisutil v0.7.1/go.mod h1:v21E3hY37WKMGSnbsw2S/ojApNWb6C1//mXO48CXbVc=
+github.com/gostaticanalysis/comment v1.4.2/go.mod h1:KLUTGDv6HOCotCH8h2erHKmpci2ZoR8VPu34YA2uzdM=
+github.com/gostaticanalysis/comment v1.5.0 h1:X82FLl+TswsUMpMh17srGRuKaaXprTaytmEpgnKIDu8=
+github.com/gostaticanalysis/comment v1.5.0/go.mod h1:V6eb3gpCv9GNVqb6amXzEUX3jXLVK/AdA+IrAMSqvEc=
+github.com/gostaticanalysis/forcetypeassert v0.2.0 h1:uSnWrrUEYDr86OCxWa4/Tp2jeYDlogZiZHzGkWFefTk=
+github.com/gostaticanalysis/forcetypeassert v0.2.0/go.mod h1:M5iPavzE9pPqWyeiVXSFghQjljW1+l/Uke3PXHS6ILY=
+github.com/gostaticanalysis/nilerr v0.1.2 h1:S6nk8a9N8g062nsx63kUkF6AzbHGw7zzyHMcpu52xQU=
+github.com/gostaticanalysis/nilerr v0.1.2/go.mod h1:A19UHhoY3y8ahoL7YKz6sdjDtduwTSI4CsymaC2htPA=
+github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod h1:D+FIZ+7OahH3ePw/izIEeH5I06eKs1IKI4Xr64/Am3M=
+github.com/gostaticanalysis/testutil v0.5.0 h1:Dq4wT1DdTwTGCQQv3rl3IvD5Ld0E6HiY+3Zh0sUGqw8=
+github.com/gostaticanalysis/testutil v0.5.0/go.mod h1:OLQSbuM6zw2EvCcXTz1lVq5unyoNft372msDY0nY5Hs=
github.com/hashicorp/cli v1.1.7 h1:/fZJ+hNdwfTSfsxMBa9WWMlfjUZbX8/LnUxgAd7lCVU=
github.com/hashicorp/cli v1.1.7/go.mod h1:e6Mfpga9OCT1vqzFuoGZiiF/KaG9CbUfO5s3ghU3YgU=
-github.com/hashicorp/consul/api v1.13.0/go.mod h1:ZlVrynguJKcYr54zGaDbaL3fOvKC9m72FhPvA8T35KQ=
-github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms=
-github.com/hashicorp/copywrite v0.22.0 h1:mqjMrgP3VptS7aLbu2l39rtznoK+BhphHst6i7HiTAo=
-github.com/hashicorp/copywrite v0.22.0/go.mod h1:FqvGJt2+yoYDpVYgFSdg3R2iyhkCVaBmPMhfso0MR2k=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
-github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-cty v1.5.0 h1:EkQ/v+dDNUqnuVpmS5fPqyY71NXVgT5gf32+57xY8g0=
github.com/hashicorp/go-cty v1.5.0/go.mod h1:lFUCG5kd8exDobgSfyj4ONE/dc822kiYMguVKdHGMLM=
-github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI=
-github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
-github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
-github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
-github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
+github.com/hashicorp/go-immutable-radix/v2 v2.1.0 h1:CUW5RYIcysz+D3B+l1mDeXrQ7fUvGGCwJfdASSzbrfo=
+github.com/hashicorp/go-immutable-radix/v2 v2.1.0/go.mod h1:hgdqLXA4f6NIjRVisM1TJ9aOJVNRqKZj+xDGF6m7PBw=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
-github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
-github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY=
github.com/hashicorp/go-plugin v1.7.0 h1:YghfQH/0QmPNc/AZMTFE3ac8fipZyZECHdDPshfk+mA=
github.com/hashicorp/go-plugin v1.7.0/go.mod h1:BExt6KEaIYx804z8k4gRzRLEvxKVb+kn0NMcihqOqb8=
-github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
-github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
-github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
-github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
-github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
-github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
-github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A=
-github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
+github.com/hashicorp/go-retryablehttp v0.7.8 h1:ylXZWnqa7Lhqpk0L1P1LzDtGcCR0rPVUrx/c8Unxc48=
+github.com/hashicorp/go-retryablehttp v0.7.8/go.mod h1:rjiScheydd+CxvumBsIrFKlx3iS0jrZ7LvzFGFmuKbw=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
-github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
-github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
-github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
-github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
+github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
+github.com/hashicorp/go-version v1.8.0 h1:KAkNb1HAiZd1ukkxDFGmokVZe1Xy9HG6NUp+bPle2i4=
+github.com/hashicorp/go-version v1.8.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
-github.com/hashicorp/hc-install v0.9.2 h1:v80EtNX4fCVHqzL9Lg/2xkp62bbvQMnvPQ0G+OmtO24=
-github.com/hashicorp/hc-install v0.9.2/go.mod h1:XUqBQNnuT4RsxoxiM9ZaUk0NX8hi2h+Lb6/c0OZnC/I=
+github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
+github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
+github.com/hashicorp/hc-install v0.9.3 h1:1H4dgmgzxEVwT6E/d/vIL5ORGVKz9twRwDw+qA5Hyho=
+github.com/hashicorp/hc-install v0.9.3/go.mod h1:FQlQ5I3I/X409N/J1U4pPeQQz1R3BoV0IysB7aiaQE0=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/hcl/v2 v2.24.0 h1:2QJdZ454DSsYGoaE6QheQZjtKZSUs9Nh2izTWiwQxvE=
github.com/hashicorp/hcl/v2 v2.24.0/go.mod h1:oGoO1FIQYfn/AgyOhlg9qLC6/nOJPX3qGbkZpYAcqfM=
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
-github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc=
-github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
-github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
-github.com/hashicorp/terraform-exec v0.24.0 h1:mL0xlk9H5g2bn0pPF6JQZk5YlByqSqrO5VoaNtAf8OE=
-github.com/hashicorp/terraform-exec v0.24.0/go.mod h1:lluc/rDYfAhYdslLJQg3J0oDqo88oGQAdHR+wDqFvo4=
+github.com/hashicorp/terraform-exec v0.25.0 h1:Bkt6m3VkJqYh+laFMrWIpy9KHYFITpOyzRMNI35rNaY=
+github.com/hashicorp/terraform-exec v0.25.0/go.mod h1:dl9IwsCfklDU6I4wq9/StFDp7dNbH/h5AnfS1RmiUl8=
github.com/hashicorp/terraform-json v0.27.2 h1:BwGuzM6iUPqf9JYM/Z4AF1OJ5VVJEEzoKST/tRDBJKU=
github.com/hashicorp/terraform-json v0.27.2/go.mod h1:GzPLJ1PLdUG5xL6xn1OXWIjteQRT2CNT9o/6A9mi9hE=
+github.com/hashicorp/terraform-plugin-codegen-framework v0.4.1 h1:eaI/3dsu2T5QAXbA+7N+B+UBj20GdtYnsRuYypKh3S4=
+github.com/hashicorp/terraform-plugin-codegen-framework v0.4.1/go.mod h1:kpYM23L7NtcfaQdWAN0QFkV/lU0w16qJ2ddAPCI4zAg=
+github.com/hashicorp/terraform-plugin-codegen-openapi v0.3.0 h1:IKpc337XKk50QyQPSxLrHwdqSo1E2XqCMxFkWsZcTvc=
+github.com/hashicorp/terraform-plugin-codegen-openapi v0.3.0/go.mod h1:tT6wl80h7nsMBw+1yZRgJXi+Ys85PUai11weDqysvp4=
+github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0 h1:91dQG1A/DxP6vRz9GiytDTrZTXDbhHPvmpYnAyWA/Vw=
+github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0/go.mod h1:fywrEKpordQypmAjz/HIfm2LuNVmyJ6KDe8XT9GdJxQ=
github.com/hashicorp/terraform-plugin-docs v0.24.0 h1:YNZYd+8cpYclQyXbl1EEngbld8w7/LPOm99GD5nikIU=
github.com/hashicorp/terraform-plugin-docs v0.24.0/go.mod h1:YLg+7LEwVmRuJc0EuCw0SPLxuQXw5mW8iJ5ml/kvi+o=
github.com/hashicorp/terraform-plugin-framework v1.17.0 h1:JdX50CFrYcYFY31gkmitAEAzLKoBgsK+iaJjDC8OexY=
@@ -265,111 +453,146 @@ github.com/hashicorp/terraform-plugin-go v0.29.0 h1:1nXKl/nSpaYIUBU1IG/EsDOX0vv+
github.com/hashicorp/terraform-plugin-go v0.29.0/go.mod h1:vYZbIyvxyy0FWSmDHChCqKvI40cFTDGSb3D8D70i9GM=
github.com/hashicorp/terraform-plugin-log v0.10.0 h1:eu2kW6/QBVdN4P3Ju2WiB2W3ObjkAsyfBsL3Wh1fj3g=
github.com/hashicorp/terraform-plugin-log v0.10.0/go.mod h1:/9RR5Cv2aAbrqcTSdNmY1NRHP4E3ekrXRGjqORpXyB0=
-github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 h1:mlAq/OrMlg04IuJT7NpefI1wwtdpWudnEmjuQs04t/4=
-github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1/go.mod h1:GQhpKVvvuwzD79e8/NZ+xzj+ZpWovdPAe8nfV/skwNU=
+github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.2 h1:sy0Bc4A/GZNdmwpVX/Its9aIweCfY9fRfY1IgmXkOj8=
+github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.2/go.mod h1:MQisArXYCowb/5q4lDS/BWp5KnXiZ4lxOIyrpKBpUBE=
github.com/hashicorp/terraform-plugin-testing v1.14.0 h1:5t4VKrjOJ0rg0sVuSJ86dz5K7PHsMO6OKrHFzDBerWA=
github.com/hashicorp/terraform-plugin-testing v1.14.0/go.mod h1:1qfWkecyYe1Do2EEOK/5/WnTyvC8wQucUkkhiGLg5nk=
github.com/hashicorp/terraform-registry-address v0.4.0 h1:S1yCGomj30Sao4l5BMPjTGZmCNzuv7/GDTDX99E9gTk=
github.com/hashicorp/terraform-registry-address v0.4.0/go.mod h1:LRS1Ay0+mAiRkUyltGT+UHWkIqTFvigGn/LbMshfflE=
-github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
-github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
-github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q=
-github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M=
-github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
-github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
+github.com/hashicorp/terraform-svchost v0.2.0 h1:wVc2vMiodOHvNZcQw/3y9af1XSomgjGSv+rv3BMCk7I=
+github.com/hashicorp/terraform-svchost v0.2.0/go.mod h1:/98rrS2yZsbppi4VGVCjwYmh8dqsKzISqK7Hli+0rcQ=
github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8=
github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns=
-github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
-github.com/hjson/hjson-go/v4 v4.0.0/go.mod h1:KaYt3bTw3zhBjYqnXkYywcYctk0A2nxeEFTse3rH13E=
-github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
+github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
+github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
+github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
+github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
+github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
+github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
+github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
+github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
-github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
-github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
-github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
-github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
+github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
+github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
+github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
+github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/ivanpirog/coloredcobra v1.0.1 h1:aURSdEmlR90/tSiWS0dMjdwOvCVUeYLfltLfbgNxrN4=
+github.com/ivanpirog/coloredcobra v1.0.1/go.mod h1:iho4nEKcnwZFiniGSdcgdvRgZNjxm+h20acv8vqmN6Q=
+github.com/jarcoal/httpmock v1.4.1 h1:0Ju+VCFuARfFlhVXFc2HxlcQkfB+Xq12/EotHko+x2A=
+github.com/jarcoal/httpmock v1.4.1/go.mod h1:ftW1xULwo+j0R0JJkJIIi7UKigZUXCLLanykgjwBXL0=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
-github.com/jedib0t/go-pretty v4.3.0+incompatible h1:CGs8AVhEKg/n9YbUenWmNStRW2PHJzaeDodcfvRAbIo=
-github.com/jedib0t/go-pretty v4.3.0+incompatible/go.mod h1:XemHduiw8R651AF9Pt4FwCTKeG3oo7hrHJAoznj9nag=
-github.com/jedib0t/go-pretty/v6 v6.4.6 h1:v6aG9h6Uby3IusSSEjHaZNXpHFhzqMmjXcPq1Rjl9Jw=
-github.com/jedib0t/go-pretty/v6 v6.4.6/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs=
+github.com/jgautheron/goconst v1.8.2 h1:y0XF7X8CikZ93fSNT6WBTb/NElBu9IjaY7CCYQrCMX4=
+github.com/jgautheron/goconst v1.8.2/go.mod h1:A0oxgBCHy55NQn6sYpO7UdnA9p+h7cPtoOZUmvNIako=
github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94=
github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8=
-github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
-github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
-github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
-github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
+github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs=
+github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c=
+github.com/jjti/go-spancheck v0.6.5 h1:lmi7pKxa37oKYIMScialXUK6hP3iY5F1gu+mLBPgYB8=
+github.com/jjti/go-spancheck v0.6.5/go.mod h1:aEogkeatBrbYsyW6y5TgDfihCulDYciL1B7rG2vSsrU=
+github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
+github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
+github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
+github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
-github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
-github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
+github.com/julz/importas v0.2.0 h1:y+MJN/UdL63QbFJHws9BVC5RpA2iq0kpjrFajTGivjQ=
+github.com/julz/importas v0.2.0/go.mod h1:pThlt589EnCYtMnmhmRYY/qn9lCf/frPOK+WMx3xiJY=
+github.com/karamaru-alpha/copyloopvar v1.2.2 h1:yfNQvP9YaGQR7VaWLYcfZUlRP2eo2vhExWKxD/fP6q0=
+github.com/karamaru-alpha/copyloopvar v1.2.2/go.mod h1:oY4rGZqZ879JkJMtX3RRkcXRkmUvH0x35ykgaKgsgJY=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
-github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
+github.com/kisielk/errcheck v1.9.0 h1:9xt1zI9EBfcYBvdU1nVrzMzzUPUtPKs9bVSIM3TAb3M=
+github.com/kisielk/errcheck v1.9.0/go.mod h1:kQxWMMVZgIkDq7U8xtG/n2juOjbLgZtedi0D+/VL/i8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
-github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
-github.com/knadh/koanf v1.5.0 h1:q2TSd/3Pyc/5yP9ldIrSdIz26MCcyNQzW0pEAugLPNs=
-github.com/knadh/koanf v1.5.0/go.mod h1:Hgyjp4y8v44hpZtPzs7JZfRAW5AhN7KfZcwv1RYggDs=
+github.com/kkHAIKE/contextcheck v1.1.6 h1:7HIyRcnyzxL9Lz06NGhiKvenXq7Zw6Q0UQu/ttjfJCE=
+github.com/kkHAIKE/contextcheck v1.1.6/go.mod h1:3dDbMRNBFaq8HFXWC1JyvDSPm43CmE6IuHam8Wr0rkg=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
-github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
-github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
-github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
-github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
-github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/kulti/thelper v0.7.1 h1:fI8QITAoFVLx+y+vSyuLBP+rcVIB8jKooNSCT2EiI98=
+github.com/kulti/thelper v0.7.1/go.mod h1:NsMjfQEy6sd+9Kfw8kCP61W1I0nerGSYSFnGaxQkcbs=
+github.com/kunwardeep/paralleltest v1.0.15 h1:ZMk4Qt306tHIgKISHWFJAO1IDQJLc6uDyJMLyncOb6w=
+github.com/kunwardeep/paralleltest v1.0.15/go.mod h1:di4moFqtfz3ToSKxhNjhOZL+696QtJGCFe132CbBLGk=
+github.com/lasiar/canonicalheader v1.1.2 h1:vZ5uqwvDbyJCnMhmFYimgMZnJMjwljN5VGY0VKbMXb4=
+github.com/lasiar/canonicalheader v1.1.2/go.mod h1:qJCeLFS0G/QlLQ506T+Fk/fWMa2VmBUiEI2cuMK4djI=
+github.com/ldez/exptostd v0.4.5 h1:kv2ZGUVI6VwRfp/+bcQ6Nbx0ghFWcGIKInkG/oFn1aQ=
+github.com/ldez/exptostd v0.4.5/go.mod h1:QRjHRMXJrCTIm9WxVNH6VW7oN7KrGSht69bIRwvdFsM=
+github.com/ldez/go-git-cmd-wrapper/v2 v2.9.1 h1:QJRB9Gs5i/h6TVJI6yl09Qm6rNooznRiKwIw+VIxd90=
+github.com/ldez/go-git-cmd-wrapper/v2 v2.9.1/go.mod h1:0eUeas7XtKDPKQbB0KijfaMPbuQ/cIprtoTRiwaUoFg=
+github.com/ldez/gomoddirectives v0.8.0 h1:JqIuTtgvFC2RdH1s357vrE23WJF2cpDCPFgA/TWDGpk=
+github.com/ldez/gomoddirectives v0.8.0/go.mod h1:jutzamvZR4XYJLr0d5Honycp4Gy6GEg2mS9+2YX3F1Q=
+github.com/ldez/grignotin v0.10.1 h1:keYi9rYsgbvqAZGI1liek5c+jv9UUjbvdj3Tbn5fn4o=
+github.com/ldez/grignotin v0.10.1/go.mod h1:UlDbXFCARrXbWGNGP3S5vsysNXAPhnSuBufpTEbwOas=
+github.com/ldez/structtags v0.6.1 h1:bUooFLbXx41tW8SvkfwfFkkjPYvFFs59AAMgVg6DUBk=
+github.com/ldez/structtags v0.6.1/go.mod h1:YDxVSgDy/MON6ariaxLF2X09bh19qL7MtGBN5MrvbdY=
+github.com/ldez/tagliatelle v0.7.2 h1:KuOlL70/fu9paxuxbeqlicJnCspCRjH0x8FW+NfgYUk=
+github.com/ldez/tagliatelle v0.7.2/go.mod h1:PtGgm163ZplJfZMZ2sf5nhUT170rSuPgBimoyYtdaSI=
+github.com/ldez/usetesting v0.5.0 h1:3/QtzZObBKLy1F4F8jLuKJiKBjjVFi1IavpoWbmqLwc=
+github.com/ldez/usetesting v0.5.0/go.mod h1:Spnb4Qppf8JTuRgblLrEWb7IE6rDmUpGvxY3iRrzvDQ=
+github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84YrjT3mIY=
+github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA=
+github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
+github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
+github.com/macabu/inamedparam v0.2.0 h1:VyPYpOc10nkhI2qeNUdh3Zket4fcZjEWe35poddBCpE=
+github.com/macabu/inamedparam v0.2.0/go.mod h1:+Pee9/YfGe5LJ62pYXqB89lJ+0k5bsR8Wgz/C0Zlq3U=
+github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
+github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
+github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
+github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
+github.com/manuelarte/embeddedstructfieldcheck v0.4.0 h1:3mAIyaGRtjK6EO9E73JlXLtiy7ha80b2ZVGyacxgfww=
+github.com/manuelarte/embeddedstructfieldcheck v0.4.0/go.mod h1:z8dFSyXqp+fC6NLDSljRJeNQJJDWnY7RoWFzV3PC6UM=
+github.com/manuelarte/funcorder v0.5.0 h1:llMuHXXbg7tD0i/LNw8vGnkDTHFpTnWqKPI85Rknc+8=
+github.com/manuelarte/funcorder v0.5.0/go.mod h1:Yt3CiUQthSBMBxjShjdXMexmzpP8YGvGLjrxJNkO2hA=
+github.com/maratori/testableexamples v1.0.1 h1:HfOQXs+XgfeRBJ+Wz0XfH+FHnoY9TVqL6Fcevpzy4q8=
+github.com/maratori/testableexamples v1.0.1/go.mod h1:XE2F/nQs7B9N08JgyRmdGjYVGqxWwClLPCGSQhXQSrQ=
+github.com/maratori/testpackage v1.1.2 h1:ffDSh+AgqluCLMXhM19f/cpvQAKygKAJXFl9aUjmbqs=
+github.com/maratori/testpackage v1.1.2/go.mod h1:8F24GdVDFW5Ew43Et02jamrVMNXLUNaOynhDssITGfc=
+github.com/matoous/godox v1.1.0 h1:W5mqwbyWrwZv6OQ5Z1a/DHGMOvXYCBP3+Ht7KMoJhq4=
+github.com/matoous/godox v1.1.0/go.mod h1:jgE/3fUXiTurkdHOLT5WEkThTSuE7yxHv5iWPa80afs=
+github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
+github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
-github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
-github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
-github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
-github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
-github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
-github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
-github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
+github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
+github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
+github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
-github.com/mergestat/timediff v0.0.3 h1:ucCNh4/ZrTPjFZ081PccNbhx9spymCJkFxSzgVuPU+Y=
-github.com/mergestat/timediff v0.0.3/go.mod h1:yvMUaRu2oetc+9IbPLYBJviz6sA7xz8OXMDfhBl7YSI=
-github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
-github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
-github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
-github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
-github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
-github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
-github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
+github.com/maxatome/go-testdeep v1.14.0 h1:rRlLv1+kI8eOI3OaBXZwb3O7xY3exRzdW5QyX48g9wI=
+github.com/maxatome/go-testdeep v1.14.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM=
+github.com/mgechev/revive v1.14.0 h1:CC2Ulb3kV7JFYt+izwORoS3VT/+Plb8BvslI/l1yZsc=
+github.com/mgechev/revive v1.14.0/go.mod h1:MvnujelCZBZCaoDv5B3foPo6WWgULSSFxvfxp7GsPfo=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
-github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
-github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
-github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
-github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
-github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
-github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
@@ -379,154 +602,201 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
-github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
+github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/moricho/tparallel v0.3.2 h1:odr8aZVFA3NZrNybggMkYO3rgPRcqjeQUlBBFVxKHTI=
+github.com/moricho/tparallel v0.3.2/go.mod h1:OQ+K3b4Ln3l2TZveGCywybl68glfLEwFGqvnjok8b+U=
+github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
+github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
-github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
-github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk=
-github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
+github.com/nakabonne/nestif v0.3.1 h1:wm28nZjhQY5HyYPx+weN3Q65k6ilSBxDb8v5S81B81U=
+github.com/nakabonne/nestif v0.3.1/go.mod h1:9EtoZochLn5iUprVDmDjqGKPofoUEBL8U4Ngq6aY7OE=
+github.com/nishanths/exhaustive v0.12.0 h1:vIY9sALmw6T/yxiASewa4TQcFsVYZQQRUQJhKRf3Swg=
+github.com/nishanths/exhaustive v0.12.0/go.mod h1:mEZ95wPIZW+x8kC4TgC+9YCUgiST7ecevsVDTgc2obs=
+github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk=
+github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c=
+github.com/nunnatsa/ginkgolinter v0.23.0 h1:x3o4DGYOWbBMP/VdNQKgSj+25aJKx2Pe6lHr8gBcgf8=
+github.com/nunnatsa/ginkgolinter v0.23.0/go.mod h1:9qN1+0akwXEccwV1CAcCDfcoBlWXHB+ML9884pL4SZ4=
+github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
+github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
+github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oklog/run v1.2.0 h1:O8x3yXwah4A73hJdlrwo/2X6J62gE5qTMusH0dvz60E=
github.com/oklog/run v1.2.0/go.mod h1:mgDbKRSwPhJfesJ4PntqFUbKQRZ50NgmZTSPlFA0YFk=
-github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
-github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
-github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
-github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
-github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
-github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
+github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
+github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
+github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
+github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
+github.com/onsi/ginkgo/v2 v2.28.1 h1:S4hj+HbZp40fNKuLUQOYLDgZLwNUVn19N3Atb98NCyI=
+github.com/onsi/ginkgo/v2 v2.28.1/go.mod h1:CLtbVInNckU3/+gC8LzkGUb9oF+e8W8TdUsxPwvdOgE=
+github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
+github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
+github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
+github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
+github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
+github.com/onsi/gomega v1.39.1 h1:1IJLAad4zjPn2PsnhH70V4DKRFlrCzGBNrNaru+Vf28=
+github.com/onsi/gomega v1.39.1/go.mod h1:hL6yVALoTOxeWudERyfppUcZXjMwIMLnuSfruD2lcfg=
+github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
+github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU=
+github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w=
+github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
+github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
+github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
+github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
+github.com/pb33f/libopenapi v0.15.0 h1:AoBYIY3HXqDDF8O9kcudlqWaRFZZJmgtueE649oHzIw=
+github.com/pb33f/libopenapi v0.15.0/go.mod h1:m+4Pwri31UvcnZjuP8M7TlbR906DXJmMvYsbis234xg=
+github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
+github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
+github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
+github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4=
github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
-github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
-github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
+github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
+github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk=
+github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
+github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
+github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
-github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA=
+github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
+github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
+github.com/quasilyte/go-ruleguard v0.4.5 h1:AGY0tiOT5hJX9BTdx/xBdoCubQUAE2grkqY2lSwvZcA=
+github.com/quasilyte/go-ruleguard v0.4.5/go.mod h1:Vl05zJ538vcEEwu16V/Hdu7IYZWyKSwIy4c88Ro1kRE=
+github.com/quasilyte/go-ruleguard/dsl v0.3.23 h1:lxjt5B6ZCiBeeNO8/oQsegE6fLeCzuMRoVWSkXC4uvY=
+github.com/quasilyte/go-ruleguard/dsl v0.3.23/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
+github.com/quasilyte/gogrep v0.5.0 h1:eTKODPXbI8ffJMN+W2aE0+oL0z/nh8/5eNdiO34SOAo=
+github.com/quasilyte/gogrep v0.5.0/go.mod h1:Cm9lpz9NZjEoL1tgZ2OgeUKPIxL1meE7eo60Z6Sk+Ng=
+github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 h1:TCg2WBOl980XxGFEZSS6KlBGIV0diGdySzxATTWoqaU=
+github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0=
+github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4lu7Gd+PU1fV2/qnDNfzT635KRSObncs=
+github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ=
+github.com/raeperd/recvcheck v0.2.0 h1:GnU+NsbiCqdC2XX5+vMZzP+jAJC5fht7rcVTAhX74UI=
+github.com/raeperd/recvcheck v0.2.0/go.mod h1:n04eYkwIR0JbgD73wT8wL4JjPC3wm0nFtzBnWNocnYU=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
-github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
+github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
-github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
-github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
-github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
-github.com/samber/lo v1.37.0 h1:XjVcB8g6tgUp8rsPsJ2CvhClfImrpL04YpQHXeHPhRw=
-github.com/samber/lo v1.37.0/go.mod h1:9vaz2O4o8oOnK23pd2TrXufcbdbJIa3b6cstBWKpopA=
-github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
+github.com/ryancurrah/gomodguard v1.4.1 h1:eWC8eUMNZ/wM/PWuZBv7JxxqT5fiIKSIyTvjb7Elr+g=
+github.com/ryancurrah/gomodguard v1.4.1/go.mod h1:qnMJwV1hX9m+YJseXEBhd2s90+1Xn6x9dLz11ualI1I=
+github.com/ryanrolds/sqlclosecheck v0.5.1 h1:dibWW826u0P8jNLsLN+En7+RqWWTYrjCB9fJfSfdyCU=
+github.com/ryanrolds/sqlclosecheck v0.5.1/go.mod h1:2g3dUjoS6AL4huFdv6wn55WpLIDjY7ZgUR4J8HOO/XQ=
+github.com/sanposhiho/wastedassign/v2 v2.1.0 h1:crurBF7fJKIORrV85u9UUpePDYGWnwvv3+A96WvwXT0=
+github.com/sanposhiho/wastedassign/v2 v2.1.0/go.mod h1:+oSmSC+9bQ+VUAxA66nBb0Z7N8CK7mscKTDYC6aIek4=
+github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ=
+github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
+github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tMEOsumirXcOJqAw=
+github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ=
+github.com/sashamelentyev/usestdlibvars v1.29.0 h1:8J0MoRrw4/NAXtjQqTHrbW9NN+3iMf7Knkq057v4XOQ=
+github.com/sashamelentyev/usestdlibvars v1.29.0/go.mod h1:8PpnjHMk5VdeWlVb4wCdrB8PNbLqZ3wBZTZWkrpZZL8=
+github.com/securego/gosec/v2 v2.23.0 h1:h4TtF64qFzvnkqvsHC/knT7YC5fqyOCItlVR8+ptEBo=
+github.com/securego/gosec/v2 v2.23.0/go.mod h1:qRHEgXLFuYUDkI2T7W7NJAmOkxVhkR0x9xyHOIcMNZ0=
+github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
+github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
+github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
+github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=
+github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g=
+github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+Wwfd0XE=
+github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4=
github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8=
github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY=
+github.com/sonatard/noctx v0.4.0 h1:7MC/5Gg4SQ4lhLYR6mvOP6mQVSxCrdyiExo7atBs27o=
+github.com/sonatard/noctx v0.4.0/go.mod h1:64XdbzFb18XL4LporKXp8poqZtPKbCrqQ402CV+kJas=
+github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0=
+github.com/sourcegraph/go-diff v0.7.0/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs=
+github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
+github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
-github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
-github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
-github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
-github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
-github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
+github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA=
+github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48=
+github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
+github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
+github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
+github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
+github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
-github.com/stackitcloud/stackit-sdk-go/core v0.20.1 h1:odiuhhRXmxvEvnVTeZSN9u98edvw2Cd3DcnkepncP3M=
-github.com/stackitcloud/stackit-sdk-go/core v0.20.1/go.mod h1:fqto7M82ynGhEnpZU6VkQKYWYoFG5goC076JWXTUPRQ=
-github.com/stackitcloud/stackit-sdk-go/services/authorization v0.9.0 h1:7ZKd3b+E/R4TEVShLTXxx5FrsuDuJBOyuVOuKTMa4mo=
-github.com/stackitcloud/stackit-sdk-go/services/authorization v0.9.0/go.mod h1:/FoXa6hF77Gv8brrvLBCKa5ie1Xy9xn39yfHwaln9Tw=
-github.com/stackitcloud/stackit-sdk-go/services/cdn v1.6.0 h1:Q+qIdejeMsYMkbtVoI9BpGlKGdSVFRBhH/zj44SP8TM=
-github.com/stackitcloud/stackit-sdk-go/services/cdn v1.6.0/go.mod h1:YGadfhuy8yoseczTxF7vN4t9ES2WxGQr0Pug14ii7y4=
-github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.1 h1:CnhAMLql0MNmAeq4roQKN8OpSKX4FSgTU6Eu6detB4I=
-github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.1/go.mod h1:7Bx85knfNSBxulPdJUFuBePXNee3cO+sOTYnUG6M+iQ=
-github.com/stackitcloud/stackit-sdk-go/services/git v0.8.0 h1:/weT7P5Uwy1Qlhw0NidqtQBlbbb/dQehweDV/I9ShXg=
-github.com/stackitcloud/stackit-sdk-go/services/git v0.8.0/go.mod h1:AXFfYBJZIW1o0W0zZEb/proQMhMsb3Nn5E1htS8NDPE=
-github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.0 h1:U/x0tc487X9msMS5yZYjrBAAKrCx87Trmt0kh8JiARA=
-github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.0/go.mod h1:6+5+RCDfU7eQN3+/SGdOtx7Bq9dEa2FrHz/jflgY1M4=
-github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.21-alpha h1:m1jq6a8dbUe+suFuUNdHmM/cSehpGLUtDbK1CqLqydg=
-github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.21-alpha/go.mod h1:Nu1b5Phsv8plgZ51+fkxPVsU91ZJ5Ayz+cthilxdmQ8=
-github.com/stackitcloud/stackit-sdk-go/services/kms v1.0.0 h1:zxoOv7Fu+FmdsvTKiKkbmLItrMKfL+QoVtz9ReEF30E=
-github.com/stackitcloud/stackit-sdk-go/services/kms v1.0.0/go.mod h1:KEPVoO21pC4bjy5l0nyhjUJ0+uVwVWb+k2TYrzJ8xYw=
-github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.6.0 h1:q33ZaCBVEBUsnMDxYyuJKtJvGcE5nKgvuPed3s8zXNI=
-github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.6.0/go.mod h1:20QOZ3rBC9wTGgzXzLz9M6YheX0VaxWE0/JI+s8On7k=
-github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.1 h1:hv5WrRU9rN6Jx4OwdOGJRyaQrfA9p1tzEoQK6/CDyoA=
-github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.1/go.mod h1:ivt8lvnAoBZsde2jSAuicyn6RgTmHvvNAJ3whaUbAD4=
-github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.1 h1:Db/ebOL2vbpIeh5XB2Ews2B9Lj5DJlMWIEJh60FfZ4Y=
-github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.1/go.mod h1:8jdN4v2euK3f9gfdzbRi8e4nBJ8g/Q5YF9aPB4M4fCQ=
-github.com/stackitcloud/stackit-sdk-go/services/modelserving v0.6.0 h1:JZI+3sLVAtTFk4QJ/ao2bAumzBq+iV6dUvDoIrOKTcw=
-github.com/stackitcloud/stackit-sdk-go/services/modelserving v0.6.0/go.mod h1:DvNLTENxoJEQ8AwUvcVBoWqVtdZNS4vEJppTKfvfeec=
-github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.2 h1:BQ+qAkVS/aGHepE/+gVsvSg1sRkPOyIUI/jkCyUOrWg=
-github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.2/go.mod h1:oc8Mpwl7O6EZwG0YxfhOzNCJwNQBWK5rFh764OtxoMY=
-github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.4.0 h1:g3yNDUc3JydAikezUrI9bQ4nuMJpVeAQ35jOFfFmq1U=
-github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.4.0/go.mod h1:foslkEiICdtHR3v0A/i/Rgo6EP9MMula9XNC9luNOgw=
-github.com/stackitcloud/stackit-sdk-go/services/observability v0.15.0 h1:MA5i1ScjXLWe5CYeFCLHeZzNS1AH4mbx1kUyiVbxKjI=
-github.com/stackitcloud/stackit-sdk-go/services/observability v0.15.0/go.mod h1:tJEOi6L0le4yQZPGwalup/PZ13gqs1aCQDqlUs2cYW0=
-github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.1 h1:50n87uZn0EvSP9hJGLqd3Wm2hfqbyh7BMGGCk7axgqA=
-github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.1/go.mod h1:jfguuSPa56Z5Bzs/Xg/CI37XzPo5Zn5lzC5LhfuT8Qc=
-github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.2.1 h1:K8vXele3U6b5urcSIpq21EkVblWfPDY3eMPSuQ48TkI=
-github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.2.1/go.mod h1:hyhw+I19NtjKmRLcUkY4boaTxnYSPFGbpn4RxvGqH2s=
-github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.25.1 h1:ALrDCBih8Fu8e6530KdOjuH0iMxOLntO381BbKFlTFY=
-github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.25.1/go.mod h1:+qGWSehoV0Js3FalgvT/bOgPj+UqW4I7lP5s8uAxP+o=
-github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.1 h1:8uPt82Ez34OYMOijjEYxB1zUW6kiybkt6veQKl0AL68=
-github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.1/go.mod h1:1Y2GEICmZDt+kr8aGnBx/sjYVAIYHmtfC8xYi9oxNEE=
-github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.18.2 h1:VDIXOvRNmSYMeF0qQ2+w4/ez04YutVDz73hSMuuOJ54=
-github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.18.2/go.mod h1:9zyEzPL4DnmU/SHq+SuMWTSO5BPxM1Z4g8Fp28n00ds=
-github.com/stackitcloud/stackit-sdk-go/services/scf v0.2.1 h1:OdofRB6uj6lwN/TXLVHVrEOwNMG34MlFNwkiHD+eOts=
-github.com/stackitcloud/stackit-sdk-go/services/scf v0.2.1/go.mod h1:5p7Xi8jadpJNDYr0t+07DXS104/RJLfhhA1r6P7PlGs=
-github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.13.1 h1:WKFzlHllql3JsVcAq+Y1m5pSMkvwp1qH3Vf2N7i8CPg=
-github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.13.1/go.mod h1:WGMFtGugBmUxI+nibI7eUZIQk4AGlDvwqX+m17W1y5w=
-github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.2 h1:tfKC4Z6Uah9AQZrtCn/ytqOgc//ChQRfJ6ozxovgads=
-github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.2/go.mod h1:wV7/BUV3BCLq5+E1bHXrKKt/eOPVdWgLArWLAq7rZ/U=
-github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.1 h1:hcHX2n5pUsOcv2PPPbSJph1fQ/I6P7g7781T1f1ycEI=
-github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.1/go.mod h1:jZwTg3wU4/UxgNJ7TKlFZ3dTIlnfvppnW8kJTc4UXy8=
-github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.11.1 h1:crKlHl7QVF97A8CTBK3PBtVpO9c/7qwFvRJi5UN/F7Y=
-github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.11.1/go.mod h1:QCrAW/Rmf+styT25ke8cUV6hDHpdKNmAY14kkJ3+Fd8=
-github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.2 h1:s2iag/Gc4tuQH7x5I0n4mQWVhpfl/cj+SVNAFAB5ck0=
-github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.2/go.mod h1:DFEamKVoOjm/rjMwzfZK0Zg/hwsSkXOibdA4HcC6swk=
-github.com/stackitcloud/stackit-sdk-go/services/ske v1.4.0 h1:V6RFvybDeJvvmT3g7/BZodF0gozz3TEpahbpiTftbeY=
-github.com/stackitcloud/stackit-sdk-go/services/ske v1.4.0/go.mod h1:xRBgpJ8P5Nf1T5tD0tGAeNg1FNQzx5VF7qqOXt2Fp3s=
-github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.3.3 h1:TFefEGGxvcI7euqyosbLS/zSEOy+3JMGOirW3vNj/84=
-github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.3.3/go.mod h1:Jsry+gfhuXv2P0ldfa48BaL605NhDjdQMgaoV8czlbo=
+github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
+github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ=
+github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI=
+github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0=
+github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I=
+github.com/stackitcloud/stackit-sdk-go/core v0.21.1 h1:Y/PcAgM7DPYMNqum0MLv4n1mF9ieuevzcCIZYQfm3Ts=
+github.com/stackitcloud/stackit-sdk-go/core v0.21.1/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI=
+github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha h1:ugpMOMUZGB0yXsWcfe97F7GCdjlexbjFuGD8ZeyMSts=
+github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha/go.mod h1:v5VGvTxLcCdJJmblbhqYalt/MFHcElDfYoy15CMhaWs=
+github.com/stbenjam/no-sprintf-host-port v0.3.1 h1:AyX7+dxI4IdLBPtDbsGAyqiTSLpCP9hWRrXQDU4Cm/g=
+github.com/stbenjam/no-sprintf-host-port v0.3.1/go.mod h1:ODbZesTCHMVKthBHskvUUexdcNHAQRXk9NpSsL8p/HQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
+github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
-github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
-github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
-github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
-github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
-github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
+github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
+github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=
+github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/teambition/rrule-go v1.8.2 h1:lIjpjvWTj9fFUZCmuoVDrKVOtdiyzbzc93qTmRVe/J8=
github.com/teambition/rrule-go v1.8.2/go.mod h1:Ieq5AbrKGciP1V//Wq8ktsTXwSwJHDD5mD/wLBGl3p4=
-github.com/thanhpk/randstr v1.0.4 h1:IN78qu/bR+My+gHCvMEXhR/i5oriVHcTB/BJJIRTsNo=
-github.com/thanhpk/randstr v1.0.4/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U=
-github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
+github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA=
+github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0=
+github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag=
+github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY=
+github.com/tetafro/godot v1.5.4 h1:u1ww+gqpRLiIA16yF2PV1CV1n/X3zhyezbNXC3E14Sg=
+github.com/tetafro/godot v1.5.4/go.mod h1:eOkMrVQurDui411nBY2FA05EYH01r14LuWY/NrVDVcU=
+github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 h1:9LPGD+jzxMlnk5r6+hJnar67cgpDIz/iyD+rfl5r2Vk=
+github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460=
+github.com/timonwong/loggercheck v0.11.0 h1:jdaMpYBl+Uq9mWPXv1r8jc5fC3gyXx4/WGwTnnNKn4M=
+github.com/timonwong/loggercheck v0.11.0/go.mod h1:HEAWU8djynujaAVX7QI65Myb8qgfcZ1uKbdpg3ZzKl8=
+github.com/tomarrell/wrapcheck/v2 v2.12.0 h1:H/qQ1aNWz/eeIhxKAFvkfIA+N7YDvq6TWVFL27Of9is=
+github.com/tomarrell/wrapcheck/v2 v2.12.0/go.mod h1:AQhQuZd0p7b6rfW+vUwHm5OMCGgp63moQ9Qr/0BpIWo=
+github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw=
+github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw=
+github.com/ultraware/funlen v0.2.0 h1:gCHmCn+d2/1SemTdYMiKLAHFYxTYz7z9VIDRaTGyLkI=
+github.com/ultraware/funlen v0.2.0/go.mod h1:ZE0q4TsJ8T1SQcjmkhN/w+MceuatI6pBFSxxyteHIJA=
+github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSWoFa+g=
+github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8=
+github.com/uudashr/gocognit v1.2.0 h1:3BU9aMr1xbhPlvJLSydKwdLN3tEUUrzPSSM8S4hDYRA=
+github.com/uudashr/gocognit v1.2.0/go.mod h1:k/DdKPI6XBZO1q7HgoV2juESI2/Ofj9AcHPZhBBdrTU=
+github.com/uudashr/iface v1.4.1 h1:J16Xl1wyNX9ofhpHmQ9h9gk5rnv2A6lX/2+APLTo0zU=
+github.com/uudashr/iface v1.4.1/go.mod h1:pbeBPlbuU2qkNDn0mmfrxP2X+wjPMIQAy+r1MBXSXtg=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
@@ -534,15 +804,35 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
+github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk=
+github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ=
+github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
+github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
-github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
-github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
-github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
-github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
+github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
+github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
+github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
+github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
+github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
+github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
+github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
+github.com/xen0n/gosmopolitan v1.3.0 h1:zAZI1zefvo7gcpbCOrPSHJZJYA9ZgLfJqtKzZ5pHqQM=
+github.com/xen0n/gosmopolitan v1.3.0/go.mod h1:rckfr5T6o4lBtM1ga7mLGKZmLxswUoH1zxHgNXOsEt4=
+github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
+github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
+github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM=
+github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk=
+github.com/yeya24/promlinter v0.3.0 h1:JVDbMp08lVCP7Y6NP3qHroGAO6z2yGKQtS5JsjqtoFs=
+github.com/yeya24/promlinter v0.3.0/go.mod h1:cDfJQQYv9uYciW60QT0eeHlFodotkYZlL+YcPQN+mW4=
+github.com/ykadowak/zerologlint v0.1.5 h1:Gy/fMz1dFQN9JZTPjv1hxEk+sRWm05row04Yoolgdiw=
+github.com/ykadowak/zerologlint v0.1.5/go.mod h1:KaUskqF3e/v59oPmdq1U1DnKcuHokl2/K1U4pmIELKg=
+github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.7.7 h1:5m9rrB1sW3JUMToKFQfb+FGt1U7r57IHu5GrYrG2nqU=
github.com/yuin/goldmark v1.7.7/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
@@ -552,218 +842,393 @@ github.com/zclconf/go-cty v1.17.0 h1:seZvECve6XX4tmnvRzWtJNHdscMtYEx5R7bnnVyd/d0
github.com/zclconf/go-cty v1.17.0/go.mod h1:wqFzcImaLTI6A5HfsRwB0nj5n0MRZFwmey8YoFPPs3U=
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo=
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM=
+gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo=
+gitlab.com/bosi/decorder v0.4.2/go.mod h1:muuhHoaJkA9QLcYHq4Mj8FJUwDZ+EirSHRiaTcTf6T8=
+go-simpler.org/assert v0.9.0 h1:PfpmcSvL7yAnWyChSjOz6Sp6m9j5lyK8Ok9pEL31YkQ=
+go-simpler.org/assert v0.9.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28=
+go-simpler.org/musttag v0.14.0 h1:XGySZATqQYSEV3/YTy+iX+aofbZZllJaqwFWs+RTtSo=
+go-simpler.org/musttag v0.14.0/go.mod h1:uP8EymctQjJ4Z1kUnjX0u2l60WfUdQxCwSNKzE1JEOE=
+go-simpler.org/sloglint v0.11.1 h1:xRbPepLT/MHPTCA6TS/wNfZrDzkGvCCqUv4Bdwc3H7s=
+go-simpler.org/sloglint v0.11.1/go.mod h1:2PowwiCOK8mjiF+0KGifVOT8ZsCNiFzvfyJeJOIt8MQ=
go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw=
go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU=
-go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A=
-go.etcd.io/etcd/client/pkg/v3 v3.5.4/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
-go.etcd.io/etcd/client/v3 v3.5.4/go.mod h1:ZaRkVgBZC+L+dLCjTcF1hRXpgZXQPOvnA/Ak/gq3kiY=
-go.mongodb.org/mongo-driver v1.10.0 h1:UtV6N5k14upNp4LTduX0QCufG124fSu25Wz9tu94GLg=
-go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8=
-go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
-go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
-go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
-go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
-go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
-go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
-go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI=
-go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg=
-go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc=
-go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps=
-go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
-go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
-go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
-go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
-go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
+go.augendre.info/arangolint v0.4.0 h1:xSCZjRoS93nXazBSg5d0OGCi9APPLNMmmLrC995tR50=
+go.augendre.info/arangolint v0.4.0/go.mod h1:l+f/b4plABuFISuKnTGD4RioXiCCgghv2xqst/xOvAA=
+go.augendre.info/fatcontext v0.9.0 h1:Gt5jGD4Zcj8CDMVzjOJITlSb9cEch54hjRRlN3qDojE=
+go.augendre.info/fatcontext v0.9.0/go.mod h1:L94brOAT1OOUNue6ph/2HnwxoNlds9aXDF2FcUntbNw=
+go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
+go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
+go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
+go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
+go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
+go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=
+go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=
+go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs=
+go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18=
+go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE=
+go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8=
+go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew=
+go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=
+go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA=
+go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
+go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
+go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
+go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
+go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
+go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
+go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
+go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
+golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
-golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
-golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
-golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
-golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
+golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
+golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
+golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
+golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
-golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM=
-golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
-golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME=
-golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
+golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
+golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
+golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
+golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
+golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
+golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
+golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
+golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
+golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
+golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 h1:qWFG1Dj7TBjOjOvhEOkmyGPVoquqUKnIU0lEVLp8xyk=
+golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358/go.mod h1:4Mzdyp/6jzw9auFDJ3OMF5qksa7UvPnzKqTVGcb04ms=
+golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
+golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
-golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
+golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
+golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
+golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
+golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
-golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=
-golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg=
+golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
+golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
+golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
-golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8=
-golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
+golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
-golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
-golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
-golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
+golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
+golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
+golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
+golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE=
-golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
-golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
+golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
+golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
-golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
-golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
-golang.org/x/telemetry v0.0.0-20251203150158-8fff8a5912fc h1:bH6xUXay0AIFMElXG2rQ4uiE+7ncwtiOdPfYK1NK2XA=
-golang.org/x/telemetry v0.0.0-20251203150158-8fff8a5912fc/go.mod h1:hKdjCMrbv9skySur+Nek8Hd0uJ0GuxJIoIX2payrIdQ=
+golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
+golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
+golang.org/x/telemetry v0.0.0-20260209163413-e7419c687ee4 h1:bTLqdHv7xrGlFbvf5/TXNxy/iUwwdkjhqQTJDjW7aj0=
+golang.org/x/telemetry v0.0.0-20260209163413-e7419c687ee4/go.mod h1:g5NllXBEermZrmR51cJDQxmJUHUOfRAaNyWBM+R+548=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
-golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
-golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
-golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
+golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
+golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
+golang.org/x/term v0.40.0 h1:36e4zGLqU4yhjlmxEaagx2KuYbJq3EwY8K943ZsHcvg=
+golang.org/x/term v0.40.0/go.mod h1:w2P8uVp06p2iyKKuvXIm7N/y0UCRt3UfJTfZ7oOpglM=
+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
-golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
-golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
+golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
+golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
+golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
+golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
-golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
-golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
+golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
+golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
+golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
+golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
+golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200724022722-7017fd6b1305/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.1.1-0.20210205202024-ef80cdb6ec6d/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU=
+golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU=
+golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
+golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
-golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
-golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
+golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
+golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
+golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
+golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
+golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM=
+golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
+golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM=
+golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
+google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
+google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
+google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
+google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
+google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
+google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
+google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
+google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
-google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
+google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
-google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
-google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
+google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
+google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
-google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 h1:pFyd6EwwL2TqFf8emdthzeX+gZE1ElRq3iM8pui4KBY=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
-google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
+google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
+google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 h1:mWPCjDEyshlQYzBpMNHaEof6UX1PmHcaUODUywQ0uac=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
-google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
+google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
+google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
-google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
-google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
-google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
-google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
+google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
+google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
+google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
+google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
+google.golang.org/grpc v1.79.1 h1:zGhSi45ODB9/p3VAawt9a+O/MULLl9dpizzNNpq7flY=
+google.golang.org/grpc v1.79.1/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -772,37 +1237,50 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
-google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
+google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
+google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
-gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
-gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
+gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
+gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
+gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20191026110619-0b21df46bc1d/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
+honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
+honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
+honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
+honnef.co/go/tools v0.7.0 h1:w6WUp1VbkqPEgLz4rkBzH/CSU6HkoqNLp6GstyTx3lU=
+honnef.co/go/tools v0.7.0/go.mod h1:pm29oPxeP3P82ISxZDgIYeOaf9ta6Pi0EWvCFoLG2vc=
+mvdan.cc/gofumpt v0.9.2 h1:zsEMWL8SVKGHNztrx6uZrXdp7AX8r421Vvp23sz7ik4=
+mvdan.cc/gofumpt v0.9.2/go.mod h1:iB7Hn+ai8lPvofHd9ZFGVg2GOr8sBUw1QUWjNbmIL/s=
+mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15 h1:ssMzja7PDPJV8FStj7hq9IKiuiKhgz9ErWw+m68e7DI=
+mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15/go.mod h1:4M5MMXl2kW6fivUT6yRGpLLPNfuGtU2Z0cPvFquGDYU=
+rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
+rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
diff --git a/golang-ci.yaml b/golang-ci.yaml
index d134590b..11f74066 100644
--- a/golang-ci.yaml
+++ b/golang-ci.yaml
@@ -1,97 +1,97 @@
-# Copyright (c) STACKIT
-# This file contains all available configuration options
-# with their default values.
-
-# options for analysis running
+version: "2"
run:
- # default concurrency is a available CPU number
concurrency: 4
-
- # timeout for analysis, e.g. 30s, 5m, default is 1m
- timeout: 5m
-linters-settings:
- goimports:
- # put imports beginning with prefix after 3rd-party packages;
- # it's a comma-separated list of prefixes
- local-prefixes: github.com/freiheit-com/nmww
- depguard:
- rules:
- main:
- list-mode: lax # Everything is allowed unless it is denied
- deny:
- - pkg: "github.com/stretchr/testify"
- desc: Do not use a testing framework
- misspell:
- # Correct spellings using locale preferences for US or UK.
- # Default is to use a neutral variety of English.
- # Setting locale to US will correct the British spelling of 'colour' to 'color'.
- locale: US
- golint:
- min-confidence: 0.8
- gosec:
- excludes:
- # Suppressions: (see https://github.com/securego/gosec#available-rules for details)
- - G104 # "Audit errors not checked" -> which we don't need and is a badly implemented version of errcheck
- - G102 # "Bind to all interfaces" -> since this is normal in k8s
- - G304 # "File path provided as taint input" -> too many false positives
- - G307 # "Deferring unsafe method "Close" on type "io.ReadCloser" -> false positive when calling defer resp.Body.Close()
- nakedret:
- max-func-lines: 0
- revive:
- ignore-generated-header: true
- severity: error
- # https://github.com/mgechev/revive
- rules:
- - name: errorf
- - name: context-as-argument
- - name: error-return
- - name: increment-decrement
- - name: indent-error-flow
- - name: superfluous-else
- - name: unused-parameter
- - name: unreachable-code
- - name: atomic
- - name: empty-lines
- - name: early-return
- gocritic:
- enabled-tags:
- - performance
- - style
- - experimental
- disabled-checks:
- - wrapperFunc
- - typeDefFirst
- - ifElseChain
- - dupImport # https://github.com/go-critic/go-critic/issues/845
+output:
+ formats:
+ text:
+ print-linter-name: true
+ print-issued-lines: true
+ colors: true
+ path: stdout
linters:
enable:
- # https://golangci-lint.run/usage/linters/
- # default linters
- - gosimple
- - govet
- - ineffassign
- - staticcheck
- - typecheck
- - unused
- # additional linters
+ - bodyclose
+ - depguard
- errorlint
+ - forcetypeassert
- gochecknoinits
- gocritic
- - gofmt
- - goimports
- gosec
- misspell
- nakedret
- revive
- - depguard
- - bodyclose
- sqlclosecheck
- wastedassign
- - forcetypeassert
- - errcheck
disable:
- - noctx # false positive: finds errors with http.NewRequest that dont make sense
- - unparam # false positives
-issues:
- exclude-use-default: false
+ - noctx
+ - unparam
+ settings:
+ depguard:
+ rules:
+ main:
+ list-mode: lax
+ allow:
+ - tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview
+ - github.com/hashicorp/terraform-plugin-framework
+ - github.com/hashicorp/terraform-plugin-log
+ - github.com/stackitcloud/stackit-sdk-go
+ deny:
+ - pkg: github.com/stretchr/testify
+ desc: Do not use a testing framework
+ gocritic:
+ disabled-checks:
+ - wrapperFunc
+ - typeDefFirst
+ - ifElseChain
+ - dupImport
+ - hugeParam
+ enabled-tags:
+ - performance
+ - style
+ - experimental
+ gosec:
+ excludes:
+ - G104
+ - G102
+ - G304
+ - G307
+ misspell:
+ locale: US
+ nakedret:
+ max-func-lines: 0
+ revive:
+ severity: error
+ rules:
+ - name: errorf
+ - name: context-as-argument
+ - name: error-return
+ - name: increment-decrement
+ - name: indent-error-flow
+ - name: superfluous-else
+ - name: unused-parameter
+ - name: unreachable-code
+ - name: atomic
+ - name: empty-lines
+ - name: early-return
+ exclusions:
+ paths:
+ - stackit-sdk-generator/
+ - generated/
+ - pkg_gen/
+ generated: lax
+ warn-unused: true
+ # Excluding configuration per-path, per-linter, per-text and per-source.
+ rules:
+ # Exclude some linters from running on tests files.
+ - path: _test\.go
+ linters:
+ - gochecknoinits
+formatters:
+ enable:
+ - gofmt
+ - goimports
+ settings:
+ goimports:
+ local-prefixes:
+ - tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview
\ No newline at end of file
diff --git a/internal/testutil/assert.go b/internal/testutil/assert.go
new file mode 100644
index 00000000..80cb2104
--- /dev/null
+++ b/internal/testutil/assert.go
@@ -0,0 +1,11 @@
+package testutil
+
+import "testing"
+
+func Equal[V comparable](t *testing.T, got, expected V) {
+ t.Helper()
+
+ if expected != got {
+ t.Errorf("assert equal failed:\ngot: %v \nexpected: %v", got, expected)
+ }
+}
diff --git a/stackit/internal/testutil/testutil.go b/internal/testutil/testutil.go.bak
similarity index 73%
rename from stackit/internal/testutil/testutil.go
rename to internal/testutil/testutil.go.bak
index fd7d95ff..2756677f 100644
--- a/stackit/internal/testutil/testutil.go
+++ b/internal/testutil/testutil.go.bak
@@ -1,9 +1,6 @@
-// Copyright (c) STACKIT
-
package testutil
import (
- "encoding/json"
"fmt"
"os"
"path/filepath"
@@ -15,12 +12,13 @@ import (
"github.com/hashicorp/terraform-plugin-testing/config"
"github.com/hashicorp/terraform-plugin-testing/echoprovider"
- "github.com/stackitcloud/terraform-provider-stackit/stackit"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit"
)
const (
// Default location of credentials JSON
- credentialsFilePath = ".stackit/credentials.json" //nolint:gosec // linter false positive
+ // credentialsFilePath = ".stackit/credentials.json" //nolint:gosec // linter false positive
+ serviceAccountFilePath = ".stackit/service_account.json"
)
var (
@@ -29,7 +27,7 @@ var (
// CLI command executed to create a provider server to which the CLI can
// reattach.
TestAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
- "stackit": providerserver.NewProtocol6WithError(stackit.New("test-version")()),
+ "stackitprivatepreview": providerserver.NewProtocol6WithError(stackit.New("test-version")()),
}
// TestEphemeralAccProtoV6ProviderFactories is used to instantiate a provider during
@@ -40,8 +38,8 @@ var (
// See the Terraform acceptance test documentation on ephemeral resources for more information:
// https://developer.hashicorp.com/terraform/plugin/testing/acceptance-tests/ephemeral-resources
TestEphemeralAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
- "stackit": providerserver.NewProtocol6WithError(stackit.New("test-version")()),
- "echo": echoprovider.NewProviderServer(),
+ "stackitprivatepreview": providerserver.NewProtocol6WithError(stackit.New("test-version")()),
+ "echo": echoprovider.NewProviderServer(),
}
// E2ETestsEnabled checks if end-to-end tests should be run.
@@ -52,6 +50,8 @@ var (
// ProjectId is the id of project used for tests
ProjectId = os.Getenv("TF_ACC_PROJECT_ID")
Region = os.Getenv("TF_ACC_REGION")
+ // ServiceAccountFile is the json file of the service account
+ ServiceAccountFile = os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE")
// ServerId is the id of a server used for some tests
ServerId = getenv("TF_ACC_SERVER_ID", "")
// TestProjectParentContainerID is the container id of the parent resource under which projects are created as part of the resource-manager acceptance tests
@@ -97,26 +97,27 @@ var (
func ObservabilityProviderConfig() string {
if ObservabilityCustomEndpoint == "" {
- return `provider "stackit" {
+ return `provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
observability_custom_endpoint = "%s"
}`,
ObservabilityCustomEndpoint,
)
}
+
func CdnProviderConfig() string {
if CdnCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
enable_beta_resources = true
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
cdn_custom_endpoint = "%s"
enable_beta_resources = true
}`,
@@ -126,10 +127,10 @@ func CdnProviderConfig() string {
func DnsProviderConfig() string {
if DnsCustomEndpoint == "" {
- return `provider "stackit" {}`
+ return `provider "stackitprivatepreview" {}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
dns_custom_endpoint = "%s"
}`,
DnsCustomEndpoint,
@@ -139,12 +140,12 @@ func DnsProviderConfig() string {
func IaaSProviderConfig() string {
if IaaSCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
iaas_custom_endpoint = "%s"
}`,
IaaSCustomEndpoint,
@@ -154,13 +155,13 @@ func IaaSProviderConfig() string {
func IaaSProviderConfigWithBetaResourcesEnabled() string {
if IaaSCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
enable_beta_resources = true
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
enable_beta_resources = true
iaas_custom_endpoint = "%s"
}`,
@@ -171,13 +172,13 @@ func IaaSProviderConfigWithBetaResourcesEnabled() string {
func IaaSProviderConfigWithExperiments() string {
if IaaSCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
experiments = [ "routing-tables", "network" ]
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
iaas_custom_endpoint = "%s"
experiments = [ "routing-tables", "network" ]
}`,
@@ -188,12 +189,12 @@ func IaaSProviderConfigWithExperiments() string {
func KMSProviderConfig() string {
if KMSCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
kms_custom_endpoint = "%s"
}`,
KMSCustomEndpoint,
@@ -203,12 +204,12 @@ func KMSProviderConfig() string {
func LoadBalancerProviderConfig() string {
if LoadBalancerCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
loadbalancer_custom_endpoint = "%s"
}`,
LoadBalancerCustomEndpoint,
@@ -218,12 +219,12 @@ func LoadBalancerProviderConfig() string {
func LogMeProviderConfig() string {
if LogMeCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
logme_custom_endpoint = "%s"
}`,
LogMeCustomEndpoint,
@@ -233,12 +234,12 @@ func LogMeProviderConfig() string {
func MariaDBProviderConfig() string {
if MariaDBCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
mariadb_custom_endpoint = "%s"
}`,
MariaDBCustomEndpoint,
@@ -248,13 +249,13 @@ func MariaDBProviderConfig() string {
func ModelServingProviderConfig() string {
if ModelServingCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}
`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
modelserving_custom_endpoint = "%s"
}`,
ModelServingCustomEndpoint,
@@ -264,12 +265,12 @@ func ModelServingProviderConfig() string {
func MongoDBFlexProviderConfig() string {
if MongoDBFlexCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
mongodbflex_custom_endpoint = "%s"
}`,
MongoDBFlexCustomEndpoint,
@@ -279,12 +280,12 @@ func MongoDBFlexProviderConfig() string {
func ObjectStorageProviderConfig() string {
if ObjectStorageCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
objectstorage_custom_endpoint = "%s"
}`,
ObjectStorageCustomEndpoint,
@@ -294,29 +295,32 @@ func ObjectStorageProviderConfig() string {
func OpenSearchProviderConfig() string {
if OpenSearchCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
opensearch_custom_endpoint = "%s"
}`,
OpenSearchCustomEndpoint,
)
}
-func PostgresFlexProviderConfig() string {
+func PostgresFlexProviderConfig(saFile string) string {
if PostgresFlexCustomEndpoint == "" {
- return `
- provider "stackit" {
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
default_region = "eu01"
- }`
+ service_account_key_path = "%s"
+ }`, saFile)
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
+ service_account_key_path = "%s"
postgresflex_custom_endpoint = "%s"
}`,
+ saFile,
PostgresFlexCustomEndpoint,
)
}
@@ -324,12 +328,12 @@ func PostgresFlexProviderConfig() string {
func RabbitMQProviderConfig() string {
if RabbitMQCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
rabbitmq_custom_endpoint = "%s"
}`,
RabbitMQCustomEndpoint,
@@ -339,12 +343,12 @@ func RabbitMQProviderConfig() string {
func RedisProviderConfig() string {
if RedisCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
redis_custom_endpoint = "%s"
}`,
RedisCustomEndpoint,
@@ -352,53 +356,56 @@ func RedisProviderConfig() string {
}
func ResourceManagerProviderConfig() string {
- token := GetTestProjectServiceAccountToken("")
+ key := GetTestProjectServiceAccountJson("")
if ResourceManagerCustomEndpoint == "" || AuthorizationCustomEndpoint == "" {
return fmt.Sprintf(`
- provider "stackit" {
- service_account_token = "%s"
+ provider "stackitprivatepreview" {
+ service_account_key = "%s"
}`,
- token,
+ key,
)
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
resourcemanager_custom_endpoint = "%s"
authorization_custom_endpoint = "%s"
service_account_token = "%s"
}`,
ResourceManagerCustomEndpoint,
AuthorizationCustomEndpoint,
- token,
+ key,
)
}
func SecretsManagerProviderConfig() string {
if SecretsManagerCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
secretsmanager_custom_endpoint = "%s"
}`,
SecretsManagerCustomEndpoint,
)
}
-func SQLServerFlexProviderConfig() string {
+func SQLServerFlexProviderConfig(saFile string) string {
if SQLServerFlexCustomEndpoint == "" {
- return `
- provider "stackit" {
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
default_region = "eu01"
- }`
+ service_account_key_path = "%s"
+ }`, saFile)
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
+ service_account_key_path = "%s"
sqlserverflex_custom_endpoint = "%s"
}`,
+ saFile,
SQLServerFlexCustomEndpoint,
)
}
@@ -406,13 +413,13 @@ func SQLServerFlexProviderConfig() string {
func ServerBackupProviderConfig() string {
if ServerBackupCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
enable_beta_resources = true
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
server_backup_custom_endpoint = "%s"
enable_beta_resources = true
}`,
@@ -423,13 +430,13 @@ func ServerBackupProviderConfig() string {
func ServerUpdateProviderConfig() string {
if ServerUpdateCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
enable_beta_resources = true
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
server_update_custom_endpoint = "%s"
enable_beta_resources = true
}`,
@@ -440,12 +447,12 @@ func ServerUpdateProviderConfig() string {
func SKEProviderConfig() string {
if SKECustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
ske_custom_endpoint = "%s"
}`,
SKECustomEndpoint,
@@ -455,13 +462,13 @@ func SKEProviderConfig() string {
func AuthorizationProviderConfig() string {
if AuthorizationCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
experiments = ["iam"]
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
authorization_custom_endpoint = "%s"
experiments = ["iam"]
}`,
@@ -472,13 +479,13 @@ func AuthorizationProviderConfig() string {
func ServiceAccountProviderConfig() string {
if ServiceAccountCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
enable_beta_resources = true
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
service_account_custom_endpoint = "%s"
enable_beta_resources = true
}`,
@@ -489,13 +496,13 @@ func ServiceAccountProviderConfig() string {
func GitProviderConfig() string {
if GitCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
enable_beta_resources = true
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
git_custom_endpoint = "%s"
enable_beta_resources = true
}`,
@@ -506,12 +513,12 @@ func GitProviderConfig() string {
func ScfProviderConfig() string {
if ScfCustomEndpoint == "" {
return `
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
}`
}
return fmt.Sprintf(`
- provider "stackit" {
+ provider "stackitprivatepreview" {
default_region = "eu01"
scf_custom_endpoint = "%s"
}`,
@@ -526,11 +533,11 @@ func ResourceNameWithDateTime(name string) string {
return fmt.Sprintf("tf-acc-%s-%s", name, dateTimeTrimmed)
}
-func GetTestProjectServiceAccountToken(path string) string {
+func GetTestProjectServiceAccountJson(path string) string {
var err error
- token, tokenSet := os.LookupEnv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN")
+ token, tokenSet := os.LookupEnv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_JSON")
if !tokenSet || token == "" {
- token, err = readTestTokenFromCredentialsFile(path)
+ token, err = readTestServiceAccountJsonFromFile(path)
if err != nil {
return ""
}
@@ -538,11 +545,53 @@ func GetTestProjectServiceAccountToken(path string) string {
return token
}
-func readTestTokenFromCredentialsFile(path string) (string, error) {
+//func GetTestProjectServiceAccountToken(path string) string {
+// var err error
+// token, tokenSet := os.LookupEnv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN")
+// if !tokenSet || token == "" {
+// token, err = readTestTokenFromCredentialsFile(path)
+// if err != nil {
+// return ""
+// }
+// }
+// return token
+//}
+//
+//func readTestTokenFromCredentialsFile(path string) (string, error) {
+// if path == "" {
+// customPath, customPathSet := os.LookupEnv("STACKIT_CREDENTIALS_PATH")
+// if !customPathSet || customPath == "" {
+// path = credentialsFilePath
+// home, err := os.UserHomeDir()
+// if err != nil {
+// return "", fmt.Errorf("getting home directory: %w", err)
+// }
+// path = filepath.Join(home, path)
+// } else {
+// path = customPath
+// }
+// }
+//
+// credentialsRaw, err := os.ReadFile(path)
+// if err != nil {
+// return "", fmt.Errorf("opening file: %w", err)
+// }
+//
+// var credentials struct {
+// TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN string `json:"TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN"`
+// }
+// err = json.Unmarshal(credentialsRaw, &credentials)
+// if err != nil {
+// return "", fmt.Errorf("unmarshalling credentials: %w", err)
+// }
+// return credentials.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN, nil
+//}
+
+func readTestServiceAccountJsonFromFile(path string) (string, error) {
if path == "" {
- customPath, customPathSet := os.LookupEnv("STACKIT_CREDENTIALS_PATH")
+ customPath, customPathSet := os.LookupEnv("STACKIT_SERVICE_ACCOUNT_PATH")
if !customPathSet || customPath == "" {
- path = credentialsFilePath
+ path = serviceAccountFilePath
home, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("getting home directory: %w", err)
@@ -557,15 +606,7 @@ func readTestTokenFromCredentialsFile(path string) (string, error) {
if err != nil {
return "", fmt.Errorf("opening file: %w", err)
}
-
- var credentials struct {
- TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN string `json:"TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN"`
- }
- err = json.Unmarshal(credentialsRaw, &credentials)
- if err != nil {
- return "", fmt.Errorf("unmarshalling credentials: %w", err)
- }
- return credentials.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN, nil
+ return string(credentialsRaw), nil
}
func getenv(key, defaultValue string) string {
diff --git a/stackit/internal/testutil/testutil_test.go b/internal/testutil/testutil_test.go.bak
similarity index 100%
rename from stackit/internal/testutil/testutil_test.go
rename to internal/testutil/testutil_test.go.bak
diff --git a/internal/testutils/activateMocks.go b/internal/testutils/activateMocks.go
new file mode 100644
index 00000000..c8f7dd05
--- /dev/null
+++ b/internal/testutils/activateMocks.go
@@ -0,0 +1,39 @@
+package testutils
+
+import (
+ "fmt"
+ "net/http"
+ "path/filepath"
+ "regexp"
+ "runtime"
+ "strings"
+
+ "github.com/jarcoal/httpmock"
+)
+
+func TestName() string {
+ pc, _, _, _ := runtime.Caller(1)
+ nameFull := runtime.FuncForPC(pc).Name()
+ nameEnd := filepath.Ext(nameFull)
+ name := strings.TrimPrefix(nameEnd, ".")
+ return name
+}
+
+func ActivateEnvironmentHttpMocks() {
+ httpmock.RegisterNoResponder(
+ func(req *http.Request) (*http.Response, error) {
+ return nil, fmt.Errorf("no responder found for %s %s, please check your http mocks", req.Method, req.URL)
+ },
+ )
+
+ httpmock.RegisterRegexpResponder(
+ "GET",
+ regexp.MustCompile(`^https://api\.bap\.microsoft\.com/providers/Microsoft\.BusinessAppPlatform/locations/(europe|unitedstates)/environmentLanguages\?api-version=2023-06-01$`),
+ func(_ *http.Request) (*http.Response, error) {
+ return httpmock.NewStringResponse(
+ http.StatusOK,
+ httpmock.File("../../services/languages/tests/datasource/Validate_Read/get_languages.json").String(),
+ ), nil
+ },
+ )
+}
diff --git a/internal/testutils/functions.go b/internal/testutils/functions.go
new file mode 100644
index 00000000..3e748941
--- /dev/null
+++ b/internal/testutils/functions.go
@@ -0,0 +1,129 @@
+package testutils
+
+import (
+ "bytes"
+ "fmt"
+ "log"
+ "os"
+ "path"
+ "path/filepath"
+ "runtime"
+ "strings"
+ "testing"
+ "text/template"
+)
+
+// GetHomeEnvVariableName Helper function to obtain the home directory on different systems.
+// Based on os.UserHomeDir().
+func GetHomeEnvVariableName() string {
+ env := "HOME"
+ switch runtime.GOOS {
+ case "windows":
+ env = "USERPROFILE"
+ case "plan9":
+ env = "home"
+ }
+ return env
+}
+
+// CreateTemporaryHome create temporary home and initialize the credentials file as well
+func CreateTemporaryHome(createValidCredentialsFile bool, t *testing.T) string {
+ // create a temporary file
+ tempHome, err := os.MkdirTemp("", "tempHome")
+ if err != nil {
+ t.Fatalf("Failed to create temporary home directory: %v", err)
+ }
+
+ // create credentials file in temp directory
+ stackitFolder := path.Join(tempHome, ".stackit")
+ if err := os.Mkdir(stackitFolder, 0o750); err != nil {
+ t.Fatalf("Failed to create stackit folder: %v", err)
+ }
+
+ filePath := path.Join(stackitFolder, "credentials.json")
+ file, err := os.Create(filePath)
+ if err != nil {
+ t.Fatalf("Failed to create credentials file: %v", err)
+ }
+ defer func() {
+ if err := file.Close(); err != nil {
+ t.Fatalf("Error while closing the file: %v", err)
+ }
+ }()
+
+ // Define content, default = invalid token
+ token := "foo_token"
+ if createValidCredentialsFile {
+ token = GetTestProjectServiceAccountJson("")
+ }
+ if _, err = file.WriteString(token); err != nil {
+ t.Fatalf("Error writing to file: %v", err)
+ }
+
+ return tempHome
+}
+
+// SetTemporaryHome Function to overwrite the home folder
+func SetTemporaryHome(tempHomePath string) {
+ env := GetHomeEnvVariableName()
+ if err := os.Setenv(env, tempHomePath); err != nil {
+ fmt.Printf("Error setting temporary home directory %v", err)
+ }
+}
+
+// CleanupTemporaryHome cleanup the temporary home and reset the environment variable
+func CleanupTemporaryHome(tempHomePath string, t *testing.T) {
+ if err := os.RemoveAll(tempHomePath); err != nil {
+ t.Fatalf("Error cleaning up temporary folder: %v", err)
+ }
+ originalHomeDir, err := os.UserHomeDir()
+ if err != nil {
+ t.Fatalf("Failed to restore home directory back to normal: %v", err)
+ }
+ // revert back to original home folder
+ env := GetHomeEnvVariableName()
+ if err := os.Setenv(env, originalHomeDir); err != nil {
+ fmt.Printf("Error resetting temporary home directory %v", err)
+ }
+}
+
+func ucFirst(s string) string {
+ if s == "" {
+ return ""
+ }
+ return strings.ToUpper(s[:1]) + s[1:]
+}
+
+func StringFromTemplateMust(tplFile string, data any) string {
+ res, err := StringFromTemplate(tplFile, data)
+ if err != nil {
+ log.Fatalln(err)
+ }
+ return res
+}
+
+func StringFromTemplate(tplFile string, data any) (string, error) {
+ fn := template.FuncMap{
+ "ucfirst": ucFirst,
+ }
+
+ file := filepath.Base(tplFile)
+
+ tmpl, err := template.New(file).Funcs(fn).ParseFiles(tplFile)
+ if err != nil {
+ return "", err
+ }
+
+ tplBuf := &bytes.Buffer{}
+
+ err = tmpl.Execute(tplBuf, data)
+ if err != nil {
+ return "", err
+ }
+
+ return tplBuf.String(), nil
+}
+
+func ResStr(prefix, resource, name string) string {
+ return fmt.Sprintf("%s_%s.%s", prefix, resource, name)
+}
diff --git a/internal/testutils/helpers.go b/internal/testutils/helpers.go
new file mode 100644
index 00000000..c8d063dc
--- /dev/null
+++ b/internal/testutils/helpers.go
@@ -0,0 +1,465 @@
+package testutils
+
+import (
+ "fmt"
+ "os"
+)
+
+var (
+ CdnCustomEndpoint = os.Getenv("TF_ACC_CDN_CUSTOM_ENDPOINT")
+ DnsCustomEndpoint = os.Getenv("TF_ACC_DNS_CUSTOM_ENDPOINT")
+ GitCustomEndpoint = os.Getenv("TF_ACC_GIT_CUSTOM_ENDPOINT")
+ IaaSCustomEndpoint = os.Getenv("TF_ACC_IAAS_CUSTOM_ENDPOINT")
+ KMSCustomEndpoint = os.Getenv("TF_ACC_KMS_CUSTOM_ENDPOINT")
+ LoadBalancerCustomEndpoint = os.Getenv("TF_ACC_LOADBALANCER_CUSTOM_ENDPOINT")
+ LogMeCustomEndpoint = os.Getenv("TF_ACC_LOGME_CUSTOM_ENDPOINT")
+ MariaDBCustomEndpoint = os.Getenv("TF_ACC_MARIADB_CUSTOM_ENDPOINT")
+ ModelServingCustomEndpoint = os.Getenv("TF_ACC_MODELSERVING_CUSTOM_ENDPOINT")
+ AuthorizationCustomEndpoint = os.Getenv("TF_ACC_authorization_custom_endpoint")
+ MongoDBFlexCustomEndpoint = os.Getenv("TF_ACC_MONGODBFLEX_CUSTOM_ENDPOINT")
+ OpenSearchCustomEndpoint = os.Getenv("TF_ACC_OPENSEARCH_CUSTOM_ENDPOINT")
+ ObservabilityCustomEndpoint = os.Getenv("TF_ACC_OBSERVABILITY_CUSTOM_ENDPOINT")
+ ObjectStorageCustomEndpoint = os.Getenv("TF_ACC_OBJECTSTORAGE_CUSTOM_ENDPOINT")
+ PostgresFlexCustomEndpoint = os.Getenv("TF_ACC_POSTGRESFLEX_CUSTOM_ENDPOINT")
+ RabbitMQCustomEndpoint = os.Getenv("TF_ACC_RABBITMQ_CUSTOM_ENDPOINT")
+ RedisCustomEndpoint = os.Getenv("TF_ACC_REDIS_CUSTOM_ENDPOINT")
+ ResourceManagerCustomEndpoint = os.Getenv("TF_ACC_RESOURCEMANAGER_CUSTOM_ENDPOINT")
+ ScfCustomEndpoint = os.Getenv("TF_ACC_SCF_CUSTOM_ENDPOINT")
+ SecretsManagerCustomEndpoint = os.Getenv("TF_ACC_SECRETSMANAGER_CUSTOM_ENDPOINT")
+ SQLServerFlexCustomEndpoint = os.Getenv("TF_ACC_SQLSERVERFLEX_CUSTOM_ENDPOINT")
+ ServerBackupCustomEndpoint = os.Getenv("TF_ACC_SERVER_BACKUP_CUSTOM_ENDPOINT")
+ ServerUpdateCustomEndpoint = os.Getenv("TF_ACC_SERVER_UPDATE_CUSTOM_ENDPOINT")
+ ServiceAccountCustomEndpoint = os.Getenv("TF_ACC_SERVICE_ACCOUNT_CUSTOM_ENDPOINT")
+ SKECustomEndpoint = os.Getenv("TF_ACC_SKE_CUSTOM_ENDPOINT")
+)
+
+func ObservabilityProviderConfig() string {
+ if ObservabilityCustomEndpoint == "" {
+ return `provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ observability_custom_endpoint = "%s"
+ }`,
+ ObservabilityCustomEndpoint,
+ )
+}
+
+func CdnProviderConfig() string {
+ if CdnCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ enable_beta_resources = true
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ cdn_custom_endpoint = "%s"
+ enable_beta_resources = true
+ }`,
+ CdnCustomEndpoint,
+ )
+}
+
+func DnsProviderConfig() string {
+ if DnsCustomEndpoint == "" {
+ return `provider "stackitprivatepreview" {}`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ dns_custom_endpoint = "%s"
+ }`,
+ DnsCustomEndpoint,
+ )
+}
+
+func IaaSProviderConfig() string {
+ if IaaSCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ iaas_custom_endpoint = "%s"
+ }`,
+ IaaSCustomEndpoint,
+ )
+}
+
+func IaaSProviderConfigWithBetaResourcesEnabled() string {
+ if IaaSCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ enable_beta_resources = true
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ enable_beta_resources = true
+ iaas_custom_endpoint = "%s"
+ }`,
+ IaaSCustomEndpoint,
+ )
+}
+
+func IaaSProviderConfigWithExperiments() string {
+ if IaaSCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ experiments = [ "routing-tables", "network" ]
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ iaas_custom_endpoint = "%s"
+ experiments = [ "routing-tables", "network" ]
+ }`,
+ IaaSCustomEndpoint,
+ )
+}
+
+func KMSProviderConfig() string {
+ if KMSCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ kms_custom_endpoint = "%s"
+ }`,
+ KMSCustomEndpoint,
+ )
+}
+
+func LoadBalancerProviderConfig() string {
+ if LoadBalancerCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ loadbalancer_custom_endpoint = "%s"
+ }`,
+ LoadBalancerCustomEndpoint,
+ )
+}
+
+func LogMeProviderConfig() string {
+ if LogMeCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ logme_custom_endpoint = "%s"
+ }`,
+ LogMeCustomEndpoint,
+ )
+}
+
+func MariaDBProviderConfig() string {
+ if MariaDBCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ mariadb_custom_endpoint = "%s"
+ }`,
+ MariaDBCustomEndpoint,
+ )
+}
+
+func ModelServingProviderConfig() string {
+ if ModelServingCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }
+ `
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ modelserving_custom_endpoint = "%s"
+ }`,
+ ModelServingCustomEndpoint,
+ )
+}
+
+func MongoDBFlexProviderConfig() string {
+ if MongoDBFlexCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ mongodbflex_custom_endpoint = "%s"
+ }`,
+ MongoDBFlexCustomEndpoint,
+ )
+}
+
+func ObjectStorageProviderConfig() string {
+ if ObjectStorageCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ objectstorage_custom_endpoint = "%s"
+ }`,
+ ObjectStorageCustomEndpoint,
+ )
+}
+
+func OpenSearchProviderConfig() string {
+ if OpenSearchCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ opensearch_custom_endpoint = "%s"
+ }`,
+ OpenSearchCustomEndpoint,
+ )
+}
+
+func PostgresFlexProviderConfig(saFile string) string {
+ if PostgresFlexCustomEndpoint == "" {
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ service_account_key_path = "%s"
+ }`, saFile)
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ service_account_key_path = "%s"
+ postgresflex_custom_endpoint = "%s"
+ }`,
+ saFile,
+ PostgresFlexCustomEndpoint,
+ )
+}
+
+func RabbitMQProviderConfig() string {
+ if RabbitMQCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ rabbitmq_custom_endpoint = "%s"
+ }`,
+ RabbitMQCustomEndpoint,
+ )
+}
+
+func RedisProviderConfig() string {
+ if RedisCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ redis_custom_endpoint = "%s"
+ }`,
+ RedisCustomEndpoint,
+ )
+}
+
+func ResourceManagerProviderConfig() string {
+ key := GetTestProjectServiceAccountJson("")
+ if ResourceManagerCustomEndpoint == "" || AuthorizationCustomEndpoint == "" {
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ service_account_key = "%s"
+ }`,
+ key,
+ )
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ resourcemanager_custom_endpoint = "%s"
+ authorization_custom_endpoint = "%s"
+ service_account_token = "%s"
+ }`,
+ ResourceManagerCustomEndpoint,
+ AuthorizationCustomEndpoint,
+ key,
+ )
+}
+
+func SecretsManagerProviderConfig() string {
+ if SecretsManagerCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ secretsmanager_custom_endpoint = "%s"
+ }`,
+ SecretsManagerCustomEndpoint,
+ )
+}
+
+func SQLServerFlexProviderConfig(saFile string) string {
+ if SQLServerFlexCustomEndpoint == "" {
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ service_account_key_path = "%s"
+ }`, saFile)
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ service_account_key_path = "%s"
+ sqlserverflex_custom_endpoint = "%s"
+ }`,
+ saFile,
+ SQLServerFlexCustomEndpoint,
+ )
+}
+
+func ServerBackupProviderConfig() string {
+ if ServerBackupCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ enable_beta_resources = true
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ server_backup_custom_endpoint = "%s"
+ enable_beta_resources = true
+ }`,
+ ServerBackupCustomEndpoint,
+ )
+}
+
+func ServerUpdateProviderConfig() string {
+ if ServerUpdateCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ enable_beta_resources = true
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ server_update_custom_endpoint = "%s"
+ enable_beta_resources = true
+ }`,
+ ServerUpdateCustomEndpoint,
+ )
+}
+
+func SKEProviderConfig() string {
+ if SKECustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ ske_custom_endpoint = "%s"
+ }`,
+ SKECustomEndpoint,
+ )
+}
+
+func AuthorizationProviderConfig() string {
+ if AuthorizationCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ experiments = ["iam"]
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ authorization_custom_endpoint = "%s"
+ experiments = ["iam"]
+ }`,
+ AuthorizationCustomEndpoint,
+ )
+}
+
+func ServiceAccountProviderConfig() string {
+ if ServiceAccountCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ enable_beta_resources = true
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ service_account_custom_endpoint = "%s"
+ enable_beta_resources = true
+ }`,
+ ServiceAccountCustomEndpoint,
+ )
+}
+
+func GitProviderConfig() string {
+ if GitCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ enable_beta_resources = true
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ git_custom_endpoint = "%s"
+ enable_beta_resources = true
+ }`,
+ GitCustomEndpoint,
+ )
+}
+
+func ScfProviderConfig() string {
+ if ScfCustomEndpoint == "" {
+ return `
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ }`
+ }
+ return fmt.Sprintf(`
+ provider "stackitprivatepreview" {
+ default_region = "eu01"
+ scf_custom_endpoint = "%s"
+ }`,
+ ScfCustomEndpoint,
+ )
+}
diff --git a/internal/testutils/testutils.go b/internal/testutils/testutils.go
new file mode 100644
index 00000000..933dab0e
--- /dev/null
+++ b/internal/testutils/testutils.go
@@ -0,0 +1,219 @@
+package testutils
+
+import (
+ "fmt"
+ "log"
+ "log/slog"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+ "time"
+
+ "github.com/hashicorp/terraform-plugin-framework/providerserver"
+ "github.com/hashicorp/terraform-plugin-go/tfprotov6"
+ "github.com/hashicorp/terraform-plugin-testing/config"
+ "github.com/hashicorp/terraform-plugin-testing/echoprovider"
+ "github.com/joho/godotenv"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit"
+)
+
+const (
+ // Default location of credentials JSON
+ // credentialsFilePath = ".stackit/credentials.json" //nolint:gosec // linter false positive
+ serviceAccountFilePath = ".stackit/service_account.json"
+)
+
+var (
+ // TestAccProtoV6ProviderFactories is used to instantiate a provider during
+ // acceptance testing. The factory function will be invoked for every Terraform
+ // CLI command executed to create a provider server to which the CLI can
+ // reattach.
+ TestAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
+ "stackitprivatepreview": providerserver.NewProtocol6WithError(stackit.New("test-version")()),
+ }
+
+ // TestEphemeralAccProtoV6ProviderFactories is used to instantiate a provider during
+ // acceptance testing. The factory function will be invoked for every Terraform
+ // CLI command executed to create a provider server to which the CLI can
+ // reattach.
+ //
+ // See the Terraform acceptance test documentation on ephemeral resources for more information:
+ // https://developer.hashicorp.com/terraform/plugin/testing/acceptance-tests/ephemeral-resources
+ TestEphemeralAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
+ "stackitprivatepreview": providerserver.NewProtocol6WithError(stackit.New("test-version")()),
+ "echo": echoprovider.NewProviderServer(),
+ }
+
+ // E2ETestsEnabled checks if end-to-end tests should be run.
+ // It is enabled when the TF_ACC environment variable is set to "1".
+ E2ETestsEnabled = os.Getenv("TF_ACC") == "1"
+ // OrganizationId is the id of organization used for tests
+ OrganizationId = os.Getenv("TF_ACC_ORGANIZATION_ID")
+ // ProjectId is the id of project used for tests
+ ProjectId = os.Getenv("TF_ACC_PROJECT_ID")
+ Region = os.Getenv("TF_ACC_REGION")
+ // ServiceAccountFile is the json file of the service account
+ ServiceAccountFile = os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE")
+ // ServerId is the id of a server used for some tests
+ ServerId = getenv("TF_ACC_SERVER_ID", "")
+ // TestProjectParentContainerID is the container id of the parent resource under which projects are created as part of the resource-manager acceptance tests
+ TestProjectParentContainerID = os.Getenv("TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID")
+ // TestProjectParentUUID is the uuid of the parent resource under which projects are created as part of the resource-manager acceptance tests
+ TestProjectParentUUID = os.Getenv("TF_ACC_TEST_PROJECT_PARENT_UUID")
+ // TestProjectServiceAccountEmail is the e-mail of a service account with admin permissions on the organization under which projects are created as part of the resource-manager acceptance tests
+ TestProjectServiceAccountEmail = os.Getenv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL")
+ // TestProjectUserEmail is the e-mail of a user for the project created as part of the resource-manager acceptance tests
+ // Default email: acc-test@sa.stackit.cloud
+ TestProjectUserEmail = getenv("TF_ACC_TEST_PROJECT_USER_EMAIL", "acc-test@sa.stackit.cloud")
+ // TestImageLocalFilePath is the local path to an image file used for image acceptance tests
+ TestImageLocalFilePath = getenv("TF_ACC_TEST_IMAGE_LOCAL_FILE_PATH", "default")
+)
+
+func Setup() {
+ root, err := getRoot()
+ if err != nil {
+ log.Fatalln(err)
+ }
+ err = godotenv.Load(fmt.Sprintf("%s/.env", *root))
+ if err != nil {
+ slog.Info("could not find .env file - not loading .env")
+ return
+ }
+ slog.Info("loaded .env file", "path", *root)
+}
+
+func getRoot() (*string, error) {
+ cmd := exec.Command("git", "rev-parse", "--show-toplevel")
+ out, err := cmd.Output()
+ if err != nil {
+ return nil, err
+ }
+ lines := strings.Split(string(out), "\n")
+ return &lines[0], nil
+}
+
+func ResourceNameWithDateTime(name string) string {
+ dateTime := time.Now().Format(time.RFC3339)
+ // Remove timezone to have a smaller datetime
+ dateTimeTrimmed, _, _ := strings.Cut(dateTime, "+")
+ return fmt.Sprintf("tf-acc-%s-%s", name, dateTimeTrimmed)
+}
+
+func GetTestProjectServiceAccountJson(path string) string {
+ var err error
+ token, tokenSet := os.LookupEnv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_JSON")
+ if !tokenSet || token == "" {
+ token, err = readTestServiceAccountJsonFromFile(path)
+ if err != nil {
+ return ""
+ }
+ }
+ return token
+}
+
+// func GetTestProjectServiceAccountToken(path string) string {
+// var err error
+// token, tokenSet := os.LookupEnv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN")
+// if !tokenSet || token == "" {
+// token, err = readTestTokenFromCredentialsFile(path)
+// if err != nil {
+// return ""
+// }
+// }
+// return token
+//}
+//
+// func readTestTokenFromCredentialsFile(path string) (string, error) {
+// if path == "" {
+// customPath, customPathSet := os.LookupEnv("STACKIT_CREDENTIALS_PATH")
+// if !customPathSet || customPath == "" {
+// path = credentialsFilePath
+// home, err := os.UserHomeDir()
+// if err != nil {
+// return "", fmt.Errorf("getting home directory: %w", err)
+// }
+// path = filepath.Join(home, path)
+// } else {
+// path = customPath
+// }
+// }
+//
+// credentialsRaw, err := os.ReadFile(path)
+// if err != nil {
+// return "", fmt.Errorf("opening file: %w", err)
+// }
+//
+// var credentials struct {
+// TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN string `json:"TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN"`
+// }
+// err = json.Unmarshal(credentialsRaw, &credentials)
+// if err != nil {
+// return "", fmt.Errorf("unmarshalling credentials: %w", err)
+// }
+// return credentials.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN, nil
+//}
+
+func readTestServiceAccountJsonFromFile(path string) (string, error) {
+ if path == "" {
+ customPath, customPathSet := os.LookupEnv("STACKIT_SERVICE_ACCOUNT_PATH")
+ if !customPathSet || customPath == "" {
+ path = serviceAccountFilePath
+ home, err := os.UserHomeDir()
+ if err != nil {
+ return "", fmt.Errorf("getting home directory: %w", err)
+ }
+ path = filepath.Join(home, path)
+ } else {
+ path = customPath
+ }
+ }
+
+ credentialsRaw, err := os.ReadFile(path)
+ if err != nil {
+ return "", fmt.Errorf("opening file: %w", err)
+ }
+ return string(credentialsRaw), nil
+}
+
+func getenv(key, defaultValue string) string {
+ val := os.Getenv(key)
+ if val == "" {
+ return defaultValue
+ }
+ return val
+}
+
+// CreateDefaultLocalFile is a helper for local_file_path. No real data is created
+func CreateDefaultLocalFile() os.File {
+ // Define the file name and size
+ fileName := "test-512k.img"
+ size := 512 * 1024 // 512 KB
+
+ // Create the file
+ file, err := os.Create(fileName)
+ if err != nil {
+ panic(err)
+ }
+
+ // Seek to the desired position (512 KB)
+ _, err = file.Seek(int64(size), 0)
+ if err != nil {
+ panic(err)
+ }
+
+ return *file
+}
+
+func ConvertConfigVariable(variable config.Variable) string {
+ tmpByteArray, _ := variable.MarshalJSON()
+ // In case the variable is a string, the quotes should be removed
+ if tmpByteArray[0] == '"' && tmpByteArray[len(tmpByteArray)-1] == '"' {
+ result := string(tmpByteArray[1 : len(tmpByteArray)-1])
+ // Replace escaped quotes which where added MarshalJSON
+ rawString := strings.ReplaceAll(result, `\"`, `"`)
+ return rawString
+ }
+ return string(tmpByteArray)
+}
diff --git a/internal/testutils/testutils_test.go b/internal/testutils/testutils_test.go
new file mode 100644
index 00000000..4e18bd1e
--- /dev/null
+++ b/internal/testutils/testutils_test.go
@@ -0,0 +1,48 @@
+package testutils
+
+import (
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-testing/config"
+)
+
+func TestConvertConfigVariable(t *testing.T) {
+ tests := []struct {
+ name string
+ variable config.Variable
+ want string
+ }{
+ {
+ name: "string",
+ variable: config.StringVariable("test"),
+ want: "test",
+ },
+ {
+ name: "bool: true",
+ variable: config.BoolVariable(true),
+ want: "true",
+ },
+ {
+ name: "bool: false",
+ variable: config.BoolVariable(false),
+ want: "false",
+ },
+ {
+ name: "integer",
+ variable: config.IntegerVariable(10),
+ want: "10",
+ },
+ {
+ name: "quoted string",
+ variable: config.StringVariable(`instance =~ ".*"`),
+ want: `instance =~ ".*"`,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := ConvertConfigVariable(tt.variable); got != tt.want {
+ t.Errorf("ConvertConfigVariable() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
diff --git a/main.go b/main.go
index a059652c..ab603dd6 100644
--- a/main.go
+++ b/main.go
@@ -1,5 +1,3 @@
-// Copyright (c) STACKIT
-
package main
import (
@@ -8,7 +6,8 @@ import (
"log"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
- "github.com/stackitcloud/terraform-provider-stackit/stackit"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit"
)
var (
@@ -21,7 +20,7 @@ func main() {
flag.BoolVar(&debug, "debug", false, "allows debugging the provider")
flag.Parse()
err := providerserver.Serve(context.Background(), stackit.New(version), providerserver.ServeOpts{
- Address: "registry.terraform.io/stackitcloud/stackit",
+ Address: "tfregistry.sysops.stackit.rocks/mhenselin/stackitprivatepreview",
Debug: debug,
})
if err != nil {
diff --git a/pkg/.gitkeep b/pkg/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/pkg/postgresflexalpha/.openapi-generator/VERSION b/pkg/postgresflexalpha/.openapi-generator/VERSION
deleted file mode 100644
index cd802a1e..00000000
--- a/pkg/postgresflexalpha/.openapi-generator/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-6.6.0
\ No newline at end of file
diff --git a/pkg/postgresflexalpha/api_default.go b/pkg/postgresflexalpha/api_default.go
deleted file mode 100644
index ca3987aa..00000000
--- a/pkg/postgresflexalpha/api_default.go
+++ /dev/null
@@ -1,6257 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "bytes"
- "context"
- "fmt"
- "io"
- "net/http"
- "net/url"
- "strings"
-
- "github.com/stackitcloud/stackit-sdk-go/core/config"
- "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
-)
-
-type DefaultApi interface {
- /*
- CreateDatabaseRequest Create Database
- Create database for a user. Note: The name of a valid user must be provided in the 'options' map field using the key 'owner'
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiCreateDatabaseRequestRequest
- */
- CreateDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string) ApiCreateDatabaseRequestRequest
- /*
- CreateDatabaseRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return CreateDatabaseResponse
-
- */
- CreateDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*CreateDatabaseResponse, error)
- /*
- CreateInstanceRequest Create Instance
- Create a new instance of a postgres database instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiCreateInstanceRequestRequest
- */
- CreateInstanceRequest(ctx context.Context, projectId string, region string) ApiCreateInstanceRequestRequest
- /*
- CreateInstanceRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return CreateInstanceResponse
-
- */
- CreateInstanceRequestExecute(ctx context.Context, projectId string, region string) (*CreateInstanceResponse, error)
- /*
- CreateUserRequest Create User
- Create user for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiCreateUserRequestRequest
- */
- CreateUserRequest(ctx context.Context, projectId string, region string, instanceId string) ApiCreateUserRequestRequest
- /*
- CreateUserRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return CreateUserResponse
-
- */
- CreateUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*CreateUserResponse, error)
- /*
- DeleteDatabaseRequest Delete Database
- Delete database for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseId The ID of the database.
- @return ApiDeleteDatabaseRequestRequest
- */
- DeleteDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) ApiDeleteDatabaseRequestRequest
- /*
- DeleteDatabaseRequestExecute executes the request
-
- */
- DeleteDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) error
- /*
- DeleteInstanceRequest Delete Instance
- Delete an available postgres instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiDeleteInstanceRequestRequest
- */
- DeleteInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiDeleteInstanceRequestRequest
- /*
- DeleteInstanceRequestExecute executes the request
-
- */
- DeleteInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error
- /*
- DeleteUserRequest Delete User
- Delete an user from a specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiDeleteUserRequestRequest
- */
- DeleteUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiDeleteUserRequestRequest
- /*
- DeleteUserRequestExecute executes the request
-
- */
- DeleteUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) error
- /*
- GetBackupRequest Get specific backup
- Get information about a specific backup for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param backupId The ID of the backup.
- @return ApiGetBackupRequestRequest
- */
- GetBackupRequest(ctx context.Context, projectId string, region string, instanceId string, backupId int64) ApiGetBackupRequestRequest
- /*
- GetBackupRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param backupId The ID of the backup.
- @return GetBackupResponse
-
- */
- GetBackupRequestExecute(ctx context.Context, projectId string, region string, instanceId string, backupId int64) (*GetBackupResponse, error)
- /*
- GetCollationsRequest Get Collations for an Instance
- Get available collations for an instance
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiGetCollationsRequestRequest
- */
- GetCollationsRequest(ctx context.Context, projectId string, region string, instanceId string) ApiGetCollationsRequestRequest
- /*
- GetCollationsRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return GetCollationsResponse
-
- */
- GetCollationsRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*GetCollationsResponse, error)
- /*
- GetFlavorsRequest Get Flavors
- Get all available flavors for a project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiGetFlavorsRequestRequest
- */
- GetFlavorsRequest(ctx context.Context, projectId string, region string) ApiGetFlavorsRequestRequest
- /*
- GetFlavorsRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return GetFlavorsResponse
-
- */
- GetFlavorsRequestExecute(ctx context.Context, projectId string, region string) (*GetFlavorsResponse, error)
- /*
- GetInstanceRequest Get Specific Instance
- Get information about a specific available instance
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiGetInstanceRequestRequest
- */
- GetInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiGetInstanceRequestRequest
- /*
- GetInstanceRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return GetInstanceResponse
-
- */
- GetInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*GetInstanceResponse, error)
- /*
- GetUserRequest Get User
- Get a specific available user for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiGetUserRequestRequest
- */
- GetUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiGetUserRequestRequest
- /*
- GetUserRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return GetUserResponse
-
- */
- GetUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) (*GetUserResponse, error)
- /*
- GetVersionsRequest Get Versions
- Get available postgres versions for the project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiGetVersionsRequestRequest
- */
- GetVersionsRequest(ctx context.Context, projectId string, region string) ApiGetVersionsRequestRequest
- /*
- GetVersionsRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return GetVersionsResponse
-
- */
- GetVersionsRequestExecute(ctx context.Context, projectId string, region string) (*GetVersionsResponse, error)
- /*
- ListBackupsRequest List backups
- List all backups which are available for a specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListBackupsRequestRequest
- */
- ListBackupsRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListBackupsRequestRequest
- /*
- ListBackupsRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ListBackupResponse
-
- */
- ListBackupsRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListBackupResponse, error)
- /*
- ListDatabasesRequest List Databases
- List available databases for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListDatabasesRequestRequest
- */
- ListDatabasesRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListDatabasesRequestRequest
- /*
- ListDatabasesRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ListDatabasesResponse
-
- */
- ListDatabasesRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListDatabasesResponse, error)
- /*
- ListInstancesRequest List Instances
- List all available instances for your project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiListInstancesRequestRequest
- */
- ListInstancesRequest(ctx context.Context, projectId string, region string) ApiListInstancesRequestRequest
- /*
- ListInstancesRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ListInstancesResponse
-
- */
- ListInstancesRequestExecute(ctx context.Context, projectId string, region string) (*ListInstancesResponse, error)
- /*
- ListRolesRequest List Roles
- List available roles for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListRolesRequestRequest
- */
- ListRolesRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListRolesRequestRequest
- /*
- ListRolesRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ListRolesResponse
-
- */
- ListRolesRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListRolesResponse, error)
- /*
- ListUsersRequest List Users
- List available users for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListUsersRequestRequest
- */
- ListUsersRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListUsersRequestRequest
- /*
- ListUsersRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ListUserResponse
-
- */
- ListUsersRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListUserResponse, error)
- /*
- PointInTimeRecoveryRequest Point in Time Recovery
- Point in Time Recovery
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiPointInTimeRecoveryRequestRequest
- */
- PointInTimeRecoveryRequest(ctx context.Context, projectId string, region string, instanceId string) ApiPointInTimeRecoveryRequestRequest
- /*
- PointInTimeRecoveryRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return RecoveryResponse
-
- */
- PointInTimeRecoveryRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*RecoveryResponse, error)
- /*
- ProtectInstanceRequest Protect Instance
- Toggle the deletion protection for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiProtectInstanceRequestRequest
- */
- ProtectInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiProtectInstanceRequestRequest
- /*
- ProtectInstanceRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ProtectInstanceResponse
-
- */
- ProtectInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ProtectInstanceResponse, error)
- /*
- ResetUserRequest Reset User
- Reset an user from an specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiResetUserRequestRequest
- */
- ResetUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiResetUserRequestRequest
- /*
- ResetUserRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ResetUserResponse
-
- */
- ResetUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) (*ResetUserResponse, error)
- /*
- RestoreInstanceRequest Restore Instance
- Restore an Instance from an existing backup. Instance is not reachable during the process of restore
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param backupId The ID of the backup.
- @return ApiRestoreInstanceRequestRequest
- */
- RestoreInstanceRequest(ctx context.Context, projectId string, region string, instanceId string, backupId int64) ApiRestoreInstanceRequestRequest
- /*
- RestoreInstanceRequestExecute executes the request
-
- */
- RestoreInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string, backupId int64) error
- /*
- UpdateDatabasePartiallyRequest Update Database partially
- Update a database partially in an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseId The ID of the database.
- @return ApiUpdateDatabasePartiallyRequestRequest
- */
- UpdateDatabasePartiallyRequest(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) ApiUpdateDatabasePartiallyRequestRequest
- /*
- UpdateDatabasePartiallyRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseId The ID of the database.
- @return UpdateDatabasePartiallyResponse
-
- */
- UpdateDatabasePartiallyRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) (*UpdateDatabasePartiallyResponse, error)
- /*
- UpdateDatabaseRequest Update Database
- Update a database in an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseId The ID of the database.
- @return ApiUpdateDatabaseRequestRequest
- */
- UpdateDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) ApiUpdateDatabaseRequestRequest
- /*
- UpdateDatabaseRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseId The ID of the database.
- @return UpdateDatabaseResponse
-
- */
- UpdateDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) (*UpdateDatabaseResponse, error)
- /*
- UpdateInstancePartiallyRequest Update Instance Partially
- Update an available instance of a postgres database. No fields are required.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiUpdateInstancePartiallyRequestRequest
- */
- UpdateInstancePartiallyRequest(ctx context.Context, projectId string, region string, instanceId string) ApiUpdateInstancePartiallyRequestRequest
- /*
- UpdateInstancePartiallyRequestExecute executes the request
-
- */
- UpdateInstancePartiallyRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error
- /*
- UpdateInstanceRequest Update Instance
- Updates an available instance of a postgres database
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiUpdateInstanceRequestRequest
- */
- UpdateInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiUpdateInstanceRequestRequest
- /*
- UpdateInstanceRequestExecute executes the request
-
- */
- UpdateInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error
- /*
- UpdateUserPartiallyRequest Update User Partially
- Update an user partially for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiUpdateUserPartiallyRequestRequest
- */
- UpdateUserPartiallyRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiUpdateUserPartiallyRequestRequest
- /*
- UpdateUserPartiallyRequestExecute executes the request
-
- */
- UpdateUserPartiallyRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) error
- /*
- UpdateUserRequest Update User
- Update user for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiUpdateUserRequestRequest
- */
- UpdateUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiUpdateUserRequestRequest
- /*
- UpdateUserRequestExecute executes the request
-
- */
- UpdateUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) error
-}
-
-type ApiCreateDatabaseRequestRequest interface {
- // The request body containing the information for the new database.
- CreateDatabaseRequestPayload(createDatabaseRequestPayload CreateDatabaseRequestPayload) ApiCreateDatabaseRequestRequest
- Execute() (*CreateDatabaseResponse, error)
-}
-
-type ApiCreateInstanceRequestRequest interface {
- // The request body with the parameters for the instance creation. Every parameter is required.
- CreateInstanceRequestPayload(createInstanceRequestPayload CreateInstanceRequestPayload) ApiCreateInstanceRequestRequest
- Execute() (*CreateInstanceResponse, error)
-}
-
-type ApiCreateUserRequestRequest interface {
- // The request body containing the user details.
- CreateUserRequestPayload(createUserRequestPayload CreateUserRequestPayload) ApiCreateUserRequestRequest
- Execute() (*CreateUserResponse, error)
-}
-
-type ApiDeleteDatabaseRequestRequest interface {
- Execute() error
-}
-
-type ApiDeleteInstanceRequestRequest interface {
- Execute() error
-}
-
-type ApiDeleteUserRequestRequest interface {
- Execute() error
-}
-
-type ApiGetBackupRequestRequest interface {
- Execute() (*GetBackupResponse, error)
-}
-
-type ApiGetCollationsRequestRequest interface {
- Execute() (*GetCollationsResponse, error)
-}
-
-type ApiGetFlavorsRequestRequest interface {
- // Number of the page of items list to be returned.
- Page(page int64) ApiGetFlavorsRequestRequest
- // Number of items to be returned on each page.
- Size(size int64) ApiGetFlavorsRequestRequest
- // Sorting of the flavors to be returned on each page.
- Sort(sort FlavorSort) ApiGetFlavorsRequestRequest
- Execute() (*GetFlavorsResponse, error)
-}
-
-type ApiGetInstanceRequestRequest interface {
- Execute() (*GetInstanceResponse, error)
-}
-
-type ApiGetUserRequestRequest interface {
- Execute() (*GetUserResponse, error)
-}
-
-type ApiGetVersionsRequestRequest interface {
- Execute() (*GetVersionsResponse, error)
-}
-
-type ApiListBackupsRequestRequest interface {
- // Number of the page of items list to be returned.
- Page(page int64) ApiListBackupsRequestRequest
- // Number of items to be returned on each page.
- Size(size int64) ApiListBackupsRequestRequest
- // Sorting of the backups to be returned on each page.
- Sort(sort BackupSort) ApiListBackupsRequestRequest
- Execute() (*ListBackupResponse, error)
-}
-
-type ApiListDatabasesRequestRequest interface {
- // Number of the page of items list to be returned.
- Page(page int64) ApiListDatabasesRequestRequest
- // Number of items to be returned on each page.
- Size(size int64) ApiListDatabasesRequestRequest
- // Sorting of the databases to be returned on each page.
- Sort(sort DatabaseSort) ApiListDatabasesRequestRequest
- Execute() (*ListDatabasesResponse, error)
-}
-
-type ApiListInstancesRequestRequest interface {
- // Number of the page of items list to be returned.
- Page(page int64) ApiListInstancesRequestRequest
- // Number of items to be returned on each page.
- Size(size int64) ApiListInstancesRequestRequest
- // Sorting of the items to be returned on each page.
- Sort(sort InstanceSort) ApiListInstancesRequestRequest
- Execute() (*ListInstancesResponse, error)
-}
-
-type ApiListRolesRequestRequest interface {
- Execute() (*ListRolesResponse, error)
-}
-
-type ApiListUsersRequestRequest interface {
- // Number of the page of items list to be returned.
- Page(page int64) ApiListUsersRequestRequest
- // Number of items to be returned on each page.
- Size(size int64) ApiListUsersRequestRequest
- // Sorting of the users to be returned on each page.
- Sort(sort UserSort) ApiListUsersRequestRequest
- Execute() (*ListUserResponse, error)
-}
-
-type ApiPointInTimeRecoveryRequestRequest interface {
- // The request body with the parameters for recover an instance by a point in time into a new instance.
- PointInTimeRecoveryRequestPayload(pointInTimeRecoveryRequestPayload PointInTimeRecoveryRequestPayload) ApiPointInTimeRecoveryRequestRequest
- Execute() (*RecoveryResponse, error)
-}
-
-type ApiProtectInstanceRequestRequest interface {
- // The request body with flag isDeletable. Parameter is required.
- ProtectInstanceRequestPayload(protectInstanceRequestPayload ProtectInstanceRequestPayload) ApiProtectInstanceRequestRequest
- Execute() (*ProtectInstanceResponse, error)
-}
-
-type ApiResetUserRequestRequest interface {
- Execute() (*ResetUserResponse, error)
-}
-
-type ApiRestoreInstanceRequestRequest interface {
- Execute() error
-}
-
-type ApiUpdateDatabasePartiallyRequestRequest interface {
- // The request body containing the information for the database update.
- UpdateDatabasePartiallyRequestPayload(updateDatabasePartiallyRequestPayload UpdateDatabasePartiallyRequestPayload) ApiUpdateDatabasePartiallyRequestRequest
- Execute() (*UpdateDatabasePartiallyResponse, error)
-}
-
-type ApiUpdateDatabaseRequestRequest interface {
- // The request body containing the information for the database update.
- UpdateDatabaseRequestPayload(updateDatabaseRequestPayload UpdateDatabaseRequestPayload) ApiUpdateDatabaseRequestRequest
- Execute() (*UpdateDatabaseResponse, error)
-}
-
-type ApiUpdateInstancePartiallyRequestRequest interface {
- // The request body with the parameters for updating the instance.
- UpdateInstancePartiallyRequestPayload(updateInstancePartiallyRequestPayload UpdateInstancePartiallyRequestPayload) ApiUpdateInstancePartiallyRequestRequest
- Execute() error
-}
-
-type ApiUpdateInstanceRequestRequest interface {
- // The request body with the parameters for updating the instance
- UpdateInstanceRequestPayload(updateInstanceRequestPayload UpdateInstanceRequestPayload) ApiUpdateInstanceRequestRequest
- Execute() error
-}
-
-type ApiUpdateUserPartiallyRequestRequest interface {
- // The Request body containing the new information for the user. If empty request body is send via patch, then login and createdb roles are removed from user.
- UpdateUserPartiallyRequestPayload(updateUserPartiallyRequestPayload UpdateUserPartiallyRequestPayload) ApiUpdateUserPartiallyRequestRequest
- Execute() error
-}
-
-type ApiUpdateUserRequestRequest interface {
- // The Request body containing the updated infos for the user.
- UpdateUserRequestPayload(updateUserRequestPayload UpdateUserRequestPayload) ApiUpdateUserRequestRequest
- Execute() error
-}
-
-// DefaultApiService DefaultApi service
-type DefaultApiService service
-
-type CreateDatabaseRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- createDatabaseRequestPayload *CreateDatabaseRequestPayload
-}
-
-// The request body containing the information for the new database.
-
-func (r CreateDatabaseRequestRequest) CreateDatabaseRequestPayload(createDatabaseRequestPayload CreateDatabaseRequestPayload) ApiCreateDatabaseRequestRequest {
- r.createDatabaseRequestPayload = &createDatabaseRequestPayload
- return r
-}
-
-func (r CreateDatabaseRequestRequest) Execute() (*CreateDatabaseResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *CreateDatabaseResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateDatabaseRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.createDatabaseRequestPayload == nil {
- return localVarReturnValue, fmt.Errorf("createDatabaseRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.createDatabaseRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 409 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-CreateDatabaseRequest: Create Database
-
-Create database for a user. Note: The name of a valid user must be provided in the 'options' map field using the key 'owner'
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiCreateDatabaseRequestRequest
-*/
-func (a *APIClient) CreateDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string) ApiCreateDatabaseRequestRequest {
- return CreateDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) CreateDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*CreateDatabaseResponse, error) {
- r := CreateDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type CreateInstanceRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- createInstanceRequestPayload *CreateInstanceRequestPayload
-}
-
-// The request body with the parameters for the instance creation. Every parameter is required.
-
-func (r CreateInstanceRequestRequest) CreateInstanceRequestPayload(createInstanceRequestPayload CreateInstanceRequestPayload) ApiCreateInstanceRequestRequest {
- r.createInstanceRequestPayload = &createInstanceRequestPayload
- return r
-}
-
-func (r CreateInstanceRequestRequest) Execute() (*CreateInstanceResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *CreateInstanceResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateInstanceRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.createInstanceRequestPayload == nil {
- return localVarReturnValue, fmt.Errorf("createInstanceRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.createInstanceRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-CreateInstanceRequest: Create Instance
-
-Create a new instance of a postgres database instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiCreateInstanceRequestRequest
-*/
-func (a *APIClient) CreateInstanceRequest(ctx context.Context, projectId string, region string) ApiCreateInstanceRequestRequest {
- return CreateInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
-}
-
-func (a *APIClient) CreateInstanceRequestExecute(ctx context.Context, projectId string, region string) (*CreateInstanceResponse, error) {
- r := CreateInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
- return r.Execute()
-}
-
-type CreateUserRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- createUserRequestPayload *CreateUserRequestPayload
-}
-
-// The request body containing the user details.
-
-func (r CreateUserRequestRequest) CreateUserRequestPayload(createUserRequestPayload CreateUserRequestPayload) ApiCreateUserRequestRequest {
- r.createUserRequestPayload = &createUserRequestPayload
- return r
-}
-
-func (r CreateUserRequestRequest) Execute() (*CreateUserResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *CreateUserResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateUserRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.createUserRequestPayload == nil {
- return localVarReturnValue, fmt.Errorf("createUserRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.createUserRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-CreateUserRequest: Create User
-
-Create user for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiCreateUserRequestRequest
-*/
-func (a *APIClient) CreateUserRequest(ctx context.Context, projectId string, region string, instanceId string) ApiCreateUserRequestRequest {
- return CreateUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) CreateUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*CreateUserResponse, error) {
- r := CreateUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type DeleteDatabaseRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- databaseId int64
-}
-
-func (r DeleteDatabaseRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodDelete
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteDatabaseRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"databaseId"+"}", url.PathEscape(ParameterValueToString(r.databaseId, "databaseId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-DeleteDatabaseRequest: Delete Database
-
-Delete database for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseId The ID of the database.
- @return ApiDeleteDatabaseRequestRequest
-*/
-func (a *APIClient) DeleteDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) ApiDeleteDatabaseRequestRequest {
- return DeleteDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseId: databaseId,
- }
-}
-
-func (a *APIClient) DeleteDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) error {
- r := DeleteDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseId: databaseId,
- }
- return r.Execute()
-}
-
-type DeleteInstanceRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
-}
-
-func (r DeleteInstanceRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodDelete
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteInstanceRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 412 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-DeleteInstanceRequest: Delete Instance
-
-Delete an available postgres instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiDeleteInstanceRequestRequest
-*/
-func (a *APIClient) DeleteInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiDeleteInstanceRequestRequest {
- return DeleteInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) DeleteInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error {
- r := DeleteInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type DeleteUserRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- userId int64
-}
-
-func (r DeleteUserRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodDelete
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteUserRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(r.userId, "userId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-DeleteUserRequest: Delete User
-
-Delete an user from a specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiDeleteUserRequestRequest
-*/
-func (a *APIClient) DeleteUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiDeleteUserRequestRequest {
- return DeleteUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
-}
-
-func (a *APIClient) DeleteUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) error {
- r := DeleteUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
- return r.Execute()
-}
-
-type GetBackupRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- backupId int64
-}
-
-func (r GetBackupRequestRequest) Execute() (*GetBackupResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetBackupResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetBackupRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/{backupId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"backupId"+"}", url.PathEscape(ParameterValueToString(r.backupId, "backupId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetBackupRequest: Get specific backup
-
-Get information about a specific backup for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param backupId The ID of the backup.
- @return ApiGetBackupRequestRequest
-*/
-func (a *APIClient) GetBackupRequest(ctx context.Context, projectId string, region string, instanceId string, backupId int64) ApiGetBackupRequestRequest {
- return GetBackupRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- backupId: backupId,
- }
-}
-
-func (a *APIClient) GetBackupRequestExecute(ctx context.Context, projectId string, region string, instanceId string, backupId int64) (*GetBackupResponse, error) {
- r := GetBackupRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- backupId: backupId,
- }
- return r.Execute()
-}
-
-type GetCollationsRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
-}
-
-func (r GetCollationsRequestRequest) Execute() (*GetCollationsResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetCollationsResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetCollationsRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/collations"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetCollationsRequest: Get Collations for an Instance
-
-Get available collations for an instance
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiGetCollationsRequestRequest
-*/
-func (a *APIClient) GetCollationsRequest(ctx context.Context, projectId string, region string, instanceId string) ApiGetCollationsRequestRequest {
- return GetCollationsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) GetCollationsRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*GetCollationsResponse, error) {
- r := GetCollationsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type GetFlavorsRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- page *int64
- size *int64
- sort *FlavorSort
-}
-
-// Number of the page of items list to be returned.
-
-func (r GetFlavorsRequestRequest) Page(page int64) ApiGetFlavorsRequestRequest {
- r.page = &page
- return r
-}
-
-// Number of items to be returned on each page.
-
-func (r GetFlavorsRequestRequest) Size(size int64) ApiGetFlavorsRequestRequest {
- r.size = &size
- return r
-}
-
-// Sorting of the flavors to be returned on each page.
-
-func (r GetFlavorsRequestRequest) Sort(sort FlavorSort) ApiGetFlavorsRequestRequest {
- r.sort = &sort
- return r
-}
-
-func (r GetFlavorsRequestRequest) Execute() (*GetFlavorsResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetFlavorsResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetFlavorsRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/flavors"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- if r.page != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "")
- }
- if r.size != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "size", r.size, "")
- }
- if r.sort != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "")
- }
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetFlavorsRequest: Get Flavors
-
-Get all available flavors for a project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiGetFlavorsRequestRequest
-*/
-func (a *APIClient) GetFlavorsRequest(ctx context.Context, projectId string, region string) ApiGetFlavorsRequestRequest {
- return GetFlavorsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
-}
-
-func (a *APIClient) GetFlavorsRequestExecute(ctx context.Context, projectId string, region string) (*GetFlavorsResponse, error) {
- r := GetFlavorsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
- return r.Execute()
-}
-
-type GetInstanceRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
-}
-
-func (r GetInstanceRequestRequest) Execute() (*GetInstanceResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetInstanceResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetInstanceRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetInstanceRequest: Get Specific Instance
-
-Get information about a specific available instance
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiGetInstanceRequestRequest
-*/
-func (a *APIClient) GetInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiGetInstanceRequestRequest {
- return GetInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) GetInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*GetInstanceResponse, error) {
- r := GetInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type GetUserRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- userId int64
-}
-
-func (r GetUserRequestRequest) Execute() (*GetUserResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetUserResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetUserRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(r.userId, "userId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetUserRequest: Get User
-
-Get a specific available user for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiGetUserRequestRequest
-*/
-func (a *APIClient) GetUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiGetUserRequestRequest {
- return GetUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
-}
-
-func (a *APIClient) GetUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) (*GetUserResponse, error) {
- r := GetUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
- return r.Execute()
-}
-
-type GetVersionsRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
-}
-
-func (r GetVersionsRequestRequest) Execute() (*GetVersionsResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetVersionsResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetVersionsRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/versions"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetVersionsRequest: Get Versions
-
-Get available postgres versions for the project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiGetVersionsRequestRequest
-*/
-func (a *APIClient) GetVersionsRequest(ctx context.Context, projectId string, region string) ApiGetVersionsRequestRequest {
- return GetVersionsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
-}
-
-func (a *APIClient) GetVersionsRequestExecute(ctx context.Context, projectId string, region string) (*GetVersionsResponse, error) {
- r := GetVersionsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
- return r.Execute()
-}
-
-type ListBackupsRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- page *int64
- size *int64
- sort *BackupSort
-}
-
-// Number of the page of items list to be returned.
-
-func (r ListBackupsRequestRequest) Page(page int64) ApiListBackupsRequestRequest {
- r.page = &page
- return r
-}
-
-// Number of items to be returned on each page.
-
-func (r ListBackupsRequestRequest) Size(size int64) ApiListBackupsRequestRequest {
- r.size = &size
- return r
-}
-
-// Sorting of the backups to be returned on each page.
-
-func (r ListBackupsRequestRequest) Sort(sort BackupSort) ApiListBackupsRequestRequest {
- r.sort = &sort
- return r
-}
-
-func (r ListBackupsRequestRequest) Execute() (*ListBackupResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListBackupResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListBackupsRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- if r.page != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "")
- }
- if r.size != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "size", r.size, "")
- }
- if r.sort != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "")
- }
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListBackupsRequest: List backups
-
-List all backups which are available for a specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListBackupsRequestRequest
-*/
-func (a *APIClient) ListBackupsRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListBackupsRequestRequest {
- return ListBackupsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ListBackupsRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListBackupResponse, error) {
- r := ListBackupsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ListDatabasesRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- page *int64
- size *int64
- sort *DatabaseSort
-}
-
-// Number of the page of items list to be returned.
-
-func (r ListDatabasesRequestRequest) Page(page int64) ApiListDatabasesRequestRequest {
- r.page = &page
- return r
-}
-
-// Number of items to be returned on each page.
-
-func (r ListDatabasesRequestRequest) Size(size int64) ApiListDatabasesRequestRequest {
- r.size = &size
- return r
-}
-
-// Sorting of the databases to be returned on each page.
-
-func (r ListDatabasesRequestRequest) Sort(sort DatabaseSort) ApiListDatabasesRequestRequest {
- r.sort = &sort
- return r
-}
-
-func (r ListDatabasesRequestRequest) Execute() (*ListDatabasesResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListDatabasesResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListDatabasesRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- if r.page != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "")
- }
- if r.size != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "size", r.size, "")
- }
- if r.sort != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "")
- }
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListDatabasesRequest: List Databases
-
-List available databases for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListDatabasesRequestRequest
-*/
-func (a *APIClient) ListDatabasesRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListDatabasesRequestRequest {
- return ListDatabasesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ListDatabasesRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListDatabasesResponse, error) {
- r := ListDatabasesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ListInstancesRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- page *int64
- size *int64
- sort *InstanceSort
-}
-
-// Number of the page of items list to be returned.
-
-func (r ListInstancesRequestRequest) Page(page int64) ApiListInstancesRequestRequest {
- r.page = &page
- return r
-}
-
-// Number of items to be returned on each page.
-
-func (r ListInstancesRequestRequest) Size(size int64) ApiListInstancesRequestRequest {
- r.size = &size
- return r
-}
-
-// Sorting of the items to be returned on each page.
-
-func (r ListInstancesRequestRequest) Sort(sort InstanceSort) ApiListInstancesRequestRequest {
- r.sort = &sort
- return r
-}
-
-func (r ListInstancesRequestRequest) Execute() (*ListInstancesResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListInstancesResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListInstancesRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- if r.page != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "")
- }
- if r.size != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "size", r.size, "")
- }
- if r.sort != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "")
- }
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListInstancesRequest: List Instances
-
-List all available instances for your project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiListInstancesRequestRequest
-*/
-func (a *APIClient) ListInstancesRequest(ctx context.Context, projectId string, region string) ApiListInstancesRequestRequest {
- return ListInstancesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
-}
-
-func (a *APIClient) ListInstancesRequestExecute(ctx context.Context, projectId string, region string) (*ListInstancesResponse, error) {
- r := ListInstancesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
- return r.Execute()
-}
-
-type ListRolesRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
-}
-
-func (r ListRolesRequestRequest) Execute() (*ListRolesResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListRolesResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListRolesRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/roles"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListRolesRequest: List Roles
-
-List available roles for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListRolesRequestRequest
-*/
-func (a *APIClient) ListRolesRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListRolesRequestRequest {
- return ListRolesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ListRolesRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListRolesResponse, error) {
- r := ListRolesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ListUsersRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- page *int64
- size *int64
- sort *UserSort
-}
-
-// Number of the page of items list to be returned.
-
-func (r ListUsersRequestRequest) Page(page int64) ApiListUsersRequestRequest {
- r.page = &page
- return r
-}
-
-// Number of items to be returned on each page.
-
-func (r ListUsersRequestRequest) Size(size int64) ApiListUsersRequestRequest {
- r.size = &size
- return r
-}
-
-// Sorting of the users to be returned on each page.
-
-func (r ListUsersRequestRequest) Sort(sort UserSort) ApiListUsersRequestRequest {
- r.sort = &sort
- return r
-}
-
-func (r ListUsersRequestRequest) Execute() (*ListUserResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListUserResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListUsersRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- if r.page != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "")
- }
- if r.size != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "size", r.size, "")
- }
- if r.sort != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "")
- }
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListUsersRequest: List Users
-
-List available users for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListUsersRequestRequest
-*/
-func (a *APIClient) ListUsersRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListUsersRequestRequest {
- return ListUsersRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ListUsersRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListUserResponse, error) {
- r := ListUsersRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type PointInTimeRecoveryRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- pointInTimeRecoveryRequestPayload *PointInTimeRecoveryRequestPayload
-}
-
-// The request body with the parameters for recover an instance by a point in time into a new instance.
-
-func (r PointInTimeRecoveryRequestRequest) PointInTimeRecoveryRequestPayload(pointInTimeRecoveryRequestPayload PointInTimeRecoveryRequestPayload) ApiPointInTimeRecoveryRequestRequest {
- r.pointInTimeRecoveryRequestPayload = &pointInTimeRecoveryRequestPayload
- return r
-}
-
-func (r PointInTimeRecoveryRequestRequest) Execute() (*RecoveryResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *RecoveryResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.PointInTimeRecoveryRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/recoveries"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.pointInTimeRecoveryRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-PointInTimeRecoveryRequest: Point in Time Recovery
-
-Point in Time Recovery
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiPointInTimeRecoveryRequestRequest
-*/
-func (a *APIClient) PointInTimeRecoveryRequest(ctx context.Context, projectId string, region string, instanceId string) ApiPointInTimeRecoveryRequestRequest {
- return PointInTimeRecoveryRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) PointInTimeRecoveryRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*RecoveryResponse, error) {
- r := PointInTimeRecoveryRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ProtectInstanceRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- protectInstanceRequestPayload *ProtectInstanceRequestPayload
-}
-
-// The request body with flag isDeletable. Parameter is required.
-
-func (r ProtectInstanceRequestRequest) ProtectInstanceRequestPayload(protectInstanceRequestPayload ProtectInstanceRequestPayload) ApiProtectInstanceRequestRequest {
- r.protectInstanceRequestPayload = &protectInstanceRequestPayload
- return r
-}
-
-func (r ProtectInstanceRequestRequest) Execute() (*ProtectInstanceResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ProtectInstanceResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ProtectInstanceRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/protections"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.protectInstanceRequestPayload == nil {
- return localVarReturnValue, fmt.Errorf("protectInstanceRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.protectInstanceRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ProtectInstanceRequest: Protect Instance
-
-Toggle the deletion protection for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiProtectInstanceRequestRequest
-*/
-func (a *APIClient) ProtectInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiProtectInstanceRequestRequest {
- return ProtectInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ProtectInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ProtectInstanceResponse, error) {
- r := ProtectInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ResetUserRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- userId int64
-}
-
-func (r ResetUserRequestRequest) Execute() (*ResetUserResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ResetUserResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ResetUserRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}/reset"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(r.userId, "userId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ResetUserRequest: Reset User
-
-Reset an user from an specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiResetUserRequestRequest
-*/
-func (a *APIClient) ResetUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiResetUserRequestRequest {
- return ResetUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
-}
-
-func (a *APIClient) ResetUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) (*ResetUserResponse, error) {
- r := ResetUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
- return r.Execute()
-}
-
-type RestoreInstanceRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- backupId int64
-}
-
-func (r RestoreInstanceRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.RestoreInstanceRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/{backupId}/restores"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"backupId"+"}", url.PathEscape(ParameterValueToString(r.backupId, "backupId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-RestoreInstanceRequest: Restore Instance
-
-Restore an Instance from an existing backup. Instance is not reachable during the process of restore
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param backupId The ID of the backup.
- @return ApiRestoreInstanceRequestRequest
-*/
-func (a *APIClient) RestoreInstanceRequest(ctx context.Context, projectId string, region string, instanceId string, backupId int64) ApiRestoreInstanceRequestRequest {
- return RestoreInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- backupId: backupId,
- }
-}
-
-func (a *APIClient) RestoreInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string, backupId int64) error {
- r := RestoreInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- backupId: backupId,
- }
- return r.Execute()
-}
-
-type UpdateDatabasePartiallyRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- databaseId int64
- updateDatabasePartiallyRequestPayload *UpdateDatabasePartiallyRequestPayload
-}
-
-// The request body containing the information for the database update.
-
-func (r UpdateDatabasePartiallyRequestRequest) UpdateDatabasePartiallyRequestPayload(updateDatabasePartiallyRequestPayload UpdateDatabasePartiallyRequestPayload) ApiUpdateDatabasePartiallyRequestRequest {
- r.updateDatabasePartiallyRequestPayload = &updateDatabasePartiallyRequestPayload
- return r
-}
-
-func (r UpdateDatabasePartiallyRequestRequest) Execute() (*UpdateDatabasePartiallyResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPatch
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *UpdateDatabasePartiallyResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateDatabasePartiallyRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"databaseId"+"}", url.PathEscape(ParameterValueToString(r.databaseId, "databaseId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.updateDatabasePartiallyRequestPayload == nil {
- return localVarReturnValue, fmt.Errorf("updateDatabasePartiallyRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.updateDatabasePartiallyRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-UpdateDatabasePartiallyRequest: Update Database partially
-
-Update a database partially in an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseId The ID of the database.
- @return ApiUpdateDatabasePartiallyRequestRequest
-*/
-func (a *APIClient) UpdateDatabasePartiallyRequest(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) ApiUpdateDatabasePartiallyRequestRequest {
- return UpdateDatabasePartiallyRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseId: databaseId,
- }
-}
-
-func (a *APIClient) UpdateDatabasePartiallyRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) (*UpdateDatabasePartiallyResponse, error) {
- r := UpdateDatabasePartiallyRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseId: databaseId,
- }
- return r.Execute()
-}
-
-type UpdateDatabaseRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- databaseId int64
- updateDatabaseRequestPayload *UpdateDatabaseRequestPayload
-}
-
-// The request body containing the information for the database update.
-
-func (r UpdateDatabaseRequestRequest) UpdateDatabaseRequestPayload(updateDatabaseRequestPayload UpdateDatabaseRequestPayload) ApiUpdateDatabaseRequestRequest {
- r.updateDatabaseRequestPayload = &updateDatabaseRequestPayload
- return r
-}
-
-func (r UpdateDatabaseRequestRequest) Execute() (*UpdateDatabaseResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPut
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *UpdateDatabaseResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateDatabaseRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"databaseId"+"}", url.PathEscape(ParameterValueToString(r.databaseId, "databaseId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.updateDatabaseRequestPayload == nil {
- return localVarReturnValue, fmt.Errorf("updateDatabaseRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.updateDatabaseRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-UpdateDatabaseRequest: Update Database
-
-Update a database in an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseId The ID of the database.
- @return ApiUpdateDatabaseRequestRequest
-*/
-func (a *APIClient) UpdateDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) ApiUpdateDatabaseRequestRequest {
- return UpdateDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseId: databaseId,
- }
-}
-
-func (a *APIClient) UpdateDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseId int64) (*UpdateDatabaseResponse, error) {
- r := UpdateDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseId: databaseId,
- }
- return r.Execute()
-}
-
-type UpdateInstancePartiallyRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- updateInstancePartiallyRequestPayload *UpdateInstancePartiallyRequestPayload
-}
-
-// The request body with the parameters for updating the instance.
-
-func (r UpdateInstancePartiallyRequestRequest) UpdateInstancePartiallyRequestPayload(updateInstancePartiallyRequestPayload UpdateInstancePartiallyRequestPayload) ApiUpdateInstancePartiallyRequestRequest {
- r.updateInstancePartiallyRequestPayload = &updateInstancePartiallyRequestPayload
- return r
-}
-
-func (r UpdateInstancePartiallyRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodPatch
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateInstancePartiallyRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.updateInstancePartiallyRequestPayload == nil {
- return fmt.Errorf("updateInstancePartiallyRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.updateInstancePartiallyRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 412 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-UpdateInstancePartiallyRequest: Update Instance Partially
-
-Update an available instance of a postgres database. No fields are required.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiUpdateInstancePartiallyRequestRequest
-*/
-func (a *APIClient) UpdateInstancePartiallyRequest(ctx context.Context, projectId string, region string, instanceId string) ApiUpdateInstancePartiallyRequestRequest {
- return UpdateInstancePartiallyRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) UpdateInstancePartiallyRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error {
- r := UpdateInstancePartiallyRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type UpdateInstanceRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- updateInstanceRequestPayload *UpdateInstanceRequestPayload
-}
-
-// The request body with the parameters for updating the instance
-
-func (r UpdateInstanceRequestRequest) UpdateInstanceRequestPayload(updateInstanceRequestPayload UpdateInstanceRequestPayload) ApiUpdateInstanceRequestRequest {
- r.updateInstanceRequestPayload = &updateInstanceRequestPayload
- return r
-}
-
-func (r UpdateInstanceRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodPut
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateInstanceRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.updateInstanceRequestPayload == nil {
- return fmt.Errorf("updateInstanceRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.updateInstanceRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 412 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-UpdateInstanceRequest: Update Instance
-
-Updates an available instance of a postgres database
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiUpdateInstanceRequestRequest
-*/
-func (a *APIClient) UpdateInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiUpdateInstanceRequestRequest {
- return UpdateInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) UpdateInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error {
- r := UpdateInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type UpdateUserPartiallyRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- userId int64
- updateUserPartiallyRequestPayload *UpdateUserPartiallyRequestPayload
-}
-
-// The Request body containing the new information for the user. If empty request body is send via patch, then login and createdb roles are removed from user.
-
-func (r UpdateUserPartiallyRequestRequest) UpdateUserPartiallyRequestPayload(updateUserPartiallyRequestPayload UpdateUserPartiallyRequestPayload) ApiUpdateUserPartiallyRequestRequest {
- r.updateUserPartiallyRequestPayload = &updateUserPartiallyRequestPayload
- return r
-}
-
-func (r UpdateUserPartiallyRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodPatch
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateUserPartiallyRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(r.userId, "userId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.updateUserPartiallyRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-UpdateUserPartiallyRequest: Update User Partially
-
-Update an user partially for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiUpdateUserPartiallyRequestRequest
-*/
-func (a *APIClient) UpdateUserPartiallyRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiUpdateUserPartiallyRequestRequest {
- return UpdateUserPartiallyRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
-}
-
-func (a *APIClient) UpdateUserPartiallyRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) error {
- r := UpdateUserPartiallyRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
- return r.Execute()
-}
-
-type UpdateUserRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- userId int64
- updateUserRequestPayload *UpdateUserRequestPayload
-}
-
-// The Request body containing the updated infos for the user.
-
-func (r UpdateUserRequestRequest) UpdateUserRequestPayload(updateUserRequestPayload UpdateUserRequestPayload) ApiUpdateUserRequestRequest {
- r.updateUserRequestPayload = &updateUserRequestPayload
- return r
-}
-
-func (r UpdateUserRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodPut
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateUserRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(r.userId, "userId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.updateUserRequestPayload == nil {
- return fmt.Errorf("updateUserRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.updateUserRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-UpdateUserRequest: Update User
-
-Update user for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiUpdateUserRequestRequest
-*/
-func (a *APIClient) UpdateUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiUpdateUserRequestRequest {
- return UpdateUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
-}
-
-func (a *APIClient) UpdateUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) error {
- r := UpdateUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
- return r.Execute()
-}
diff --git a/pkg/postgresflexalpha/api_default_test.go b/pkg/postgresflexalpha/api_default_test.go
deleted file mode 100644
index 81f31fc1..00000000
--- a/pkg/postgresflexalpha/api_default_test.go
+++ /dev/null
@@ -1,1571 +0,0 @@
-/*
-PostgreSQL Flex API
-
-Testing DefaultApiService
-
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech);
-
-package postgresflexalpha
-
-import (
- "context"
- "encoding/json"
- "net/http"
- "net/http/httptest"
- "net/url"
- "strings"
- "testing"
-
- "github.com/stackitcloud/stackit-sdk-go/core/config"
-)
-
-func Test_postgresflexalpha_DefaultApiService(t *testing.T) {
-
- t.Run("Test DefaultApiService CreateDatabaseRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := CreateDatabaseResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- createDatabaseRequestPayload := CreateDatabaseRequestPayload{}
-
- resp, reqErr := apiClient.CreateDatabaseRequest(context.Background(), projectId, region, instanceId).CreateDatabaseRequestPayload(createDatabaseRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService CreateInstanceRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := CreateInstanceResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- createInstanceRequestPayload := CreateInstanceRequestPayload{}
-
- resp, reqErr := apiClient.CreateInstanceRequest(context.Background(), projectId, region).CreateInstanceRequestPayload(createInstanceRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService CreateUserRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := CreateUserResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- createUserRequestPayload := CreateUserRequestPayload{}
-
- resp, reqErr := apiClient.CreateUserRequest(context.Background(), projectId, region, instanceId).CreateUserRequestPayload(createUserRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService DeleteDatabaseRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- databaseIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"databaseId"+"}", url.PathEscape(ParameterValueToString(databaseIdValue, "databaseId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- databaseId := databaseIdValue
-
- reqErr := apiClient.DeleteDatabaseRequest(context.Background(), projectId, region, instanceId, databaseId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService DeleteInstanceRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- reqErr := apiClient.DeleteInstanceRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService DeleteUserRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- userIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- userId := userIdValue
-
- reqErr := apiClient.DeleteUserRequest(context.Background(), projectId, region, instanceId, userId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService GetBackupRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/{backupId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- backupIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"backupId"+"}", url.PathEscape(ParameterValueToString(backupIdValue, "backupId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetBackupResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- backupId := backupIdValue
-
- resp, reqErr := apiClient.GetBackupRequest(context.Background(), projectId, region, instanceId, backupId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetCollationsRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/collations"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetCollationsResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.GetCollationsRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetFlavorsRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/flavors"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetFlavorsResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
-
- resp, reqErr := apiClient.GetFlavorsRequest(context.Background(), projectId, region).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetInstanceRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetInstanceResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.GetInstanceRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetUserRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- userIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetUserResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- userId := userIdValue
-
- resp, reqErr := apiClient.GetUserRequest(context.Background(), projectId, region, instanceId, userId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetVersionsRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/versions"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetVersionsResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
-
- resp, reqErr := apiClient.GetVersionsRequest(context.Background(), projectId, region).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListBackupsRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListBackupResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.ListBackupsRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListDatabasesRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListDatabasesResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.ListDatabasesRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListInstancesRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListInstancesResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
-
- resp, reqErr := apiClient.ListInstancesRequest(context.Background(), projectId, region).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListRolesRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/roles"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListRolesResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.ListRolesRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListUsersRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListUserResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.ListUsersRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService PointInTimeRecoveryRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/recoveries"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := RecoveryResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.PointInTimeRecoveryRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ProtectInstanceRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/protections"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ProtectInstanceResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- protectInstanceRequestPayload := ProtectInstanceRequestPayload{}
-
- resp, reqErr := apiClient.ProtectInstanceRequest(context.Background(), projectId, region, instanceId).ProtectInstanceRequestPayload(protectInstanceRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ResetUserRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}/reset"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- userIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ResetUserResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- userId := userIdValue
-
- resp, reqErr := apiClient.ResetUserRequest(context.Background(), projectId, region, instanceId, userId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService RestoreInstanceRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/{backupId}/restores"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- backupIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"backupId"+"}", url.PathEscape(ParameterValueToString(backupIdValue, "backupId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- backupId := backupIdValue
-
- reqErr := apiClient.RestoreInstanceRequest(context.Background(), projectId, region, instanceId, backupId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService UpdateDatabasePartiallyRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- databaseIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"databaseId"+"}", url.PathEscape(ParameterValueToString(databaseIdValue, "databaseId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := UpdateDatabasePartiallyResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- databaseId := databaseIdValue
- updateDatabasePartiallyRequestPayload := UpdateDatabasePartiallyRequestPayload{}
-
- resp, reqErr := apiClient.UpdateDatabasePartiallyRequest(context.Background(), projectId, region, instanceId, databaseId).UpdateDatabasePartiallyRequestPayload(updateDatabasePartiallyRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService UpdateDatabaseRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- databaseIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"databaseId"+"}", url.PathEscape(ParameterValueToString(databaseIdValue, "databaseId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := UpdateDatabaseResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- databaseId := databaseIdValue
- updateDatabaseRequestPayload := UpdateDatabaseRequestPayload{}
-
- resp, reqErr := apiClient.UpdateDatabaseRequest(context.Background(), projectId, region, instanceId, databaseId).UpdateDatabaseRequestPayload(updateDatabaseRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService UpdateInstancePartiallyRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- updateInstancePartiallyRequestPayload := UpdateInstancePartiallyRequestPayload{}
-
- reqErr := apiClient.UpdateInstancePartiallyRequest(context.Background(), projectId, region, instanceId).UpdateInstancePartiallyRequestPayload(updateInstancePartiallyRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService UpdateInstanceRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- updateInstanceRequestPayload := UpdateInstanceRequestPayload{}
-
- reqErr := apiClient.UpdateInstanceRequest(context.Background(), projectId, region, instanceId).UpdateInstanceRequestPayload(updateInstanceRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService UpdateUserPartiallyRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- userIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- userId := userIdValue
-
- reqErr := apiClient.UpdateUserPartiallyRequest(context.Background(), projectId, region, instanceId, userId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService UpdateUserRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- userIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for postgresflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- userId := userIdValue
- updateUserRequestPayload := UpdateUserRequestPayload{}
-
- reqErr := apiClient.UpdateUserRequest(context.Background(), projectId, region, instanceId, userId).UpdateUserRequestPayload(updateUserRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
-}
diff --git a/pkg/postgresflexalpha/client.go b/pkg/postgresflexalpha/client.go
deleted file mode 100644
index f5ab16f9..00000000
--- a/pkg/postgresflexalpha/client.go
+++ /dev/null
@@ -1,631 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "bytes"
- "context"
- "encoding/json"
- "encoding/xml"
- "fmt"
- "io"
- "log"
- "mime/multipart"
- "net/http"
- "net/http/httputil"
- "net/url"
- "os"
- "path/filepath"
- "reflect"
- "regexp"
- "strconv"
- "strings"
- "time"
- "unicode/utf8"
-
- "github.com/stackitcloud/stackit-sdk-go/core/auth"
- "github.com/stackitcloud/stackit-sdk-go/core/config"
-)
-
-var (
- jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`)
- xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`)
- queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
- queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]")
-)
-
-// APIClient manages communication with the PostgreSQL Flex API API v3alpha1
-// In most cases there should be only one, shared, APIClient.
-type APIClient struct {
- cfg *config.Configuration
- common service // Reuse a single struct instead of allocating one for each service on the heap.
- defaultApi *DefaultApiService
-}
-
-type service struct {
- client DefaultApi
-}
-
-// NewAPIClient creates a new API client.
-// Optionally receives configuration options
-func NewAPIClient(opts ...config.ConfigurationOption) (*APIClient, error) {
- cfg := NewConfiguration()
-
- for _, option := range opts {
- err := option(cfg)
- if err != nil {
- return nil, fmt.Errorf("configuring the client: %w", err)
- }
- }
-
- err := config.ConfigureRegion(cfg)
- if err != nil {
- return nil, fmt.Errorf("configuring region: %w", err)
- }
-
- if cfg.HTTPClient == nil {
- cfg.HTTPClient = &http.Client{}
- }
-
- authRoundTripper, err := auth.SetupAuth(cfg)
- if err != nil {
- return nil, fmt.Errorf("setting up authentication: %w", err)
- }
-
- roundTripper := authRoundTripper
- if cfg.Middleware != nil {
- roundTripper = config.ChainMiddleware(roundTripper, cfg.Middleware...)
- }
-
- cfg.HTTPClient.Transport = roundTripper
-
- c := &APIClient{}
- c.cfg = cfg
- c.common.client = c
- c.defaultApi = (*DefaultApiService)(&c.common)
-
- return c, nil
-}
-
-func atoi(in string) (int, error) {
- return strconv.Atoi(in)
-}
-
-// selectHeaderContentType select a content type from the available list.
-func selectHeaderContentType(contentTypes []string) string {
- if len(contentTypes) == 0 {
- return ""
- }
- if contains(contentTypes, "application/json") {
- return "application/json"
- }
- return contentTypes[0] // use the first content type specified in 'consumes'
-}
-
-// selectHeaderAccept join all accept types and return
-func selectHeaderAccept(accepts []string) string {
- if len(accepts) == 0 {
- return ""
- }
-
- if contains(accepts, "application/json") {
- return "application/json"
- }
-
- return strings.Join(accepts, ",")
-}
-
-// contains is a case insensitive match, finding needle in a haystack
-func contains(haystack []string, needle string) bool {
- for _, a := range haystack {
- if strings.EqualFold(a, needle) {
- return true
- }
- }
- return false
-}
-
-// Verify optional parameters are of the correct type.
-func typeCheckParameter(obj interface{}, expected string, name string) error {
- // Make sure there is an object.
- if obj == nil {
- return nil
- }
-
- // Check the type is as expected.
- if reflect.TypeOf(obj).String() != expected {
- return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String())
- }
- return nil
-}
-
-func ParameterValueToString(obj interface{}, key string) string {
- if reflect.TypeOf(obj).Kind() != reflect.Ptr {
- return fmt.Sprintf("%v", obj)
- }
- var param, ok = obj.(MappedNullable)
- if !ok {
- return ""
- }
- dataMap, err := param.ToMap()
- if err != nil {
- return ""
- }
- return fmt.Sprintf("%v", dataMap[key])
-}
-
-// parameterAddToHeaderOrQuery adds the provided object to the request header or url query
-// supporting deep object syntax
-func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
- var v = reflect.ValueOf(obj)
- var value = ""
- if v == reflect.ValueOf(nil) {
- value = "null"
- } else {
- switch v.Kind() {
- case reflect.Invalid:
- value = "invalid"
-
- case reflect.Struct:
- if t, ok := obj.(MappedNullable); ok {
- dataMap, err := t.ToMap()
- if err != nil {
- return
- }
- parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, collectionType)
- return
- }
- if t, ok := obj.(time.Time); ok {
- parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339), collectionType)
- return
- }
- value = v.Type().String() + " value"
- case reflect.Slice:
- var indValue = reflect.ValueOf(obj)
- if indValue == reflect.ValueOf(nil) {
- return
- }
- var lenIndValue = indValue.Len()
- for i := 0; i < lenIndValue; i++ {
- var arrayValue = indValue.Index(i)
- parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, arrayValue.Interface(), collectionType)
- }
- return
-
- case reflect.Map:
- var indValue = reflect.ValueOf(obj)
- if indValue == reflect.ValueOf(nil) {
- return
- }
- iter := indValue.MapRange()
- for iter.Next() {
- k, v := iter.Key(), iter.Value()
- parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), collectionType)
- }
- return
-
- case reflect.Interface:
- fallthrough
- case reflect.Ptr:
- parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), collectionType)
- return
-
- case reflect.Int, reflect.Int8, reflect.Int16,
- reflect.Int32, reflect.Int64:
- value = strconv.FormatInt(v.Int(), 10)
- case reflect.Uint, reflect.Uint8, reflect.Uint16,
- reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- value = strconv.FormatUint(v.Uint(), 10)
- case reflect.Float32, reflect.Float64:
- value = strconv.FormatFloat(v.Float(), 'g', -1, 32)
- case reflect.Bool:
- value = strconv.FormatBool(v.Bool())
- case reflect.String:
- value = v.String()
- default:
- value = v.Type().String() + " value"
- }
- }
-
- switch valuesMap := headerOrQueryParams.(type) {
- case url.Values:
- if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" {
- valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix)+","+value)
- } else {
- valuesMap.Add(keyPrefix, value)
- }
- break
- case map[string]string:
- valuesMap[keyPrefix] = value
- break
- }
-}
-
-// helper for converting interface{} parameters to json strings
-func parameterToJson(obj interface{}) (string, error) {
- jsonBuf, err := json.Marshal(obj)
- if err != nil {
- return "", err
- }
- return string(jsonBuf), err
-}
-
-// callAPI do the request.
-func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
- if c.cfg.Debug {
- dump, err := httputil.DumpRequestOut(request, true)
- if err != nil {
- return nil, err
- }
- log.Printf("\n%s\n", string(dump))
- }
-
- resp, err := c.cfg.HTTPClient.Do(request)
- if err != nil {
- return resp, err
- }
-
- if c.cfg.Debug {
- dump, err := httputil.DumpResponse(resp, true)
- if err != nil {
- return resp, err
- }
- log.Printf("\n%s\n", string(dump))
- }
- return resp, err
-}
-
-// Allow modification of underlying config for alternate implementations and testing
-// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
-func (c *APIClient) GetConfig() *config.Configuration {
- return c.cfg
-}
-
-type formFile struct {
- fileBytes []byte
- fileName string
- formFileName string
-}
-
-// prepareRequest build the request
-func (c *APIClient) prepareRequest(
- ctx context.Context,
- path string, method string,
- postBody interface{},
- headerParams map[string]string,
- queryParams url.Values,
- formParams url.Values,
- formFiles []formFile) (localVarRequest *http.Request, err error) {
-
- var body *bytes.Buffer
-
- // Detect postBody type and post.
- if !IsNil(postBody) {
- contentType := headerParams["Content-Type"]
- if contentType == "" {
- contentType = detectContentType(postBody)
- headerParams["Content-Type"] = contentType
- }
-
- body, err = setBody(postBody, contentType)
- if err != nil {
- return nil, err
- }
- }
-
- // add form parameters and file if available.
- if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) {
- if body != nil {
- return nil, fmt.Errorf("cannot specify postBody and multipart form at the same time.")
- }
- body = &bytes.Buffer{}
- w := multipart.NewWriter(body)
-
- for k, v := range formParams {
- for _, iv := range v {
- if strings.HasPrefix(k, "@") { // file
- err = addFile(w, k[1:], iv)
- if err != nil {
- return nil, err
- }
- } else { // form value
- w.WriteField(k, iv)
- }
- }
- }
- for _, formFile := range formFiles {
- if len(formFile.fileBytes) > 0 && formFile.fileName != "" {
- w.Boundary()
- part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName))
- if err != nil {
- return nil, err
- }
- _, err = part.Write(formFile.fileBytes)
- if err != nil {
- return nil, err
- }
- }
- }
-
- // Set the Boundary in the Content-Type
- headerParams["Content-Type"] = w.FormDataContentType()
-
- // Set Content-Length
- headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
- w.Close()
- }
-
- if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 {
- if body != nil {
- return nil, fmt.Errorf("cannot specify postBody and x-www-form-urlencoded form at the same time.")
- }
- body = &bytes.Buffer{}
- body.WriteString(formParams.Encode())
- // Set Content-Length
- headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
- }
-
- // Setup path and query parameters
- url, err := url.Parse(path)
- if err != nil {
- return nil, err
- }
-
- // Override request host, if applicable
- if c.cfg.Host != "" {
- url.Host = c.cfg.Host
- }
-
- // Override request scheme, if applicable
- if c.cfg.Scheme != "" {
- url.Scheme = c.cfg.Scheme
- }
-
- // Adding Query Param
- query := url.Query()
- for k, v := range queryParams {
- for _, iv := range v {
- query.Add(k, iv)
- }
- }
-
- // Encode the parameters.
- url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string {
- pieces := strings.Split(s, "=")
- pieces[0] = queryDescape.Replace(pieces[0])
- return strings.Join(pieces, "=")
- })
-
- // Generate a new request
- if body != nil {
- localVarRequest, err = http.NewRequest(method, url.String(), body)
- } else {
- localVarRequest, err = http.NewRequest(method, url.String(), nil)
- }
- if err != nil {
- return nil, err
- }
-
- // add header parameters, if any
- if len(headerParams) > 0 {
- headers := http.Header{}
- for h, v := range headerParams {
- headers[h] = []string{v}
- }
- localVarRequest.Header = headers
- }
-
- // Add the user agent to the request.
- localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
-
- if ctx != nil {
- // add context to the request
- localVarRequest = localVarRequest.WithContext(ctx)
-
- // Walk through any authentication.
-
- }
-
- for header, value := range c.cfg.DefaultHeader {
- localVarRequest.Header.Add(header, value)
- }
- return localVarRequest, nil
-}
-
-func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
- if len(b) == 0 {
- return nil
- }
- if s, ok := v.(*string); ok {
- *s = string(b)
- return nil
- }
- if f, ok := v.(*os.File); ok {
- f, err = os.CreateTemp("", "HttpClientFile")
- if err != nil {
- return
- }
- _, err = f.Write(b)
- if err != nil {
- return
- }
- _, err = f.Seek(0, io.SeekStart)
- return
- }
- if f, ok := v.(**os.File); ok {
- *f, err = os.CreateTemp("", "HttpClientFile")
- if err != nil {
- return
- }
- _, err = (*f).Write(b)
- if err != nil {
- return
- }
- _, err = (*f).Seek(0, io.SeekStart)
- return
- }
- if xmlCheck.MatchString(contentType) {
- if err = xml.Unmarshal(b, v); err != nil {
- return err
- }
- return nil
- }
- if jsonCheck.MatchString(contentType) {
- if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas
- if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined
- if err = unmarshalObj.UnmarshalJSON(b); err != nil {
- return err
- }
- } else {
- return fmt.Errorf("unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined")
- }
- } else if err = json.Unmarshal(b, v); err != nil { // simple model
- return err
- }
- return nil
- }
- return fmt.Errorf("undefined response type")
-}
-
-// Add a file to the multipart request
-func addFile(w *multipart.Writer, fieldName, path string) error {
- file, err := os.Open(filepath.Clean(path))
- if err != nil {
- return err
- }
- err = file.Close()
- if err != nil {
- return err
- }
-
- part, err := w.CreateFormFile(fieldName, filepath.Base(path))
- if err != nil {
- return err
- }
- _, err = io.Copy(part, file)
-
- return err
-}
-
-// A wrapper for strict JSON decoding
-func newStrictDecoder(data []byte) *json.Decoder {
- dec := json.NewDecoder(bytes.NewBuffer(data))
- dec.DisallowUnknownFields()
- return dec
-}
-
-// Set request body from an interface{}
-func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
- if bodyBuf == nil {
- bodyBuf = &bytes.Buffer{}
- }
-
- if reader, ok := body.(io.Reader); ok {
- _, err = bodyBuf.ReadFrom(reader)
- } else if fp, ok := body.(*os.File); ok {
- _, err = bodyBuf.ReadFrom(fp)
- } else if b, ok := body.([]byte); ok {
- _, err = bodyBuf.Write(b)
- } else if s, ok := body.(string); ok {
- _, err = bodyBuf.WriteString(s)
- } else if s, ok := body.(*string); ok {
- _, err = bodyBuf.WriteString(*s)
- } else if jsonCheck.MatchString(contentType) {
- err = json.NewEncoder(bodyBuf).Encode(body)
- } else if xmlCheck.MatchString(contentType) {
- err = xml.NewEncoder(bodyBuf).Encode(body)
- }
-
- if err != nil {
- return nil, err
- }
-
- if bodyBuf.Len() == 0 {
- err = fmt.Errorf("invalid body type %s", contentType)
- return nil, err
- }
- return bodyBuf, nil
-}
-
-// detectContentType method is used to figure out `Request.Body` content type for request header
-func detectContentType(body interface{}) string {
- contentType := "text/plain; charset=utf-8"
- kind := reflect.TypeOf(body).Kind()
-
- switch kind {
- case reflect.Struct, reflect.Map, reflect.Ptr:
- contentType = "application/json; charset=utf-8"
- case reflect.String:
- contentType = "text/plain; charset=utf-8"
- default:
- if b, ok := body.([]byte); ok {
- contentType = http.DetectContentType(b)
- } else if kind == reflect.Slice {
- contentType = "application/json; charset=utf-8"
- }
- }
-
- return contentType
-}
-
-// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go
-type cacheControl map[string]string
-
-func parseCacheControl(headers http.Header) cacheControl {
- cc := cacheControl{}
- ccHeader := headers.Get("Cache-Control")
- for _, part := range strings.Split(ccHeader, ",") {
- part = strings.Trim(part, " ")
- if part == "" {
- continue
- }
- if strings.ContainsRune(part, '=') {
- keyval := strings.Split(part, "=")
- cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",")
- } else {
- cc[part] = ""
- }
- }
- return cc
-}
-
-// CacheExpires helper function to determine remaining time before repeating a request.
-func CacheExpires(r *http.Response) time.Time {
- // Figure out when the cache expires.
- var expires time.Time
- now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
- if err != nil {
- return time.Now()
- }
- respCacheControl := parseCacheControl(r.Header)
-
- if maxAge, ok := respCacheControl["max-age"]; ok {
- lifetime, err := time.ParseDuration(maxAge + "s")
- if err != nil {
- expires = now
- } else {
- expires = now.Add(lifetime)
- }
- } else {
- expiresHeader := r.Header.Get("Expires")
- if expiresHeader != "" {
- expires, err = time.Parse(time.RFC1123, expiresHeader)
- if err != nil {
- expires = now
- }
- }
- }
- return expires
-}
-
-func strlen(s string) int {
- return utf8.RuneCountInString(s)
-}
diff --git a/pkg/postgresflexalpha/configuration.go b/pkg/postgresflexalpha/configuration.go
deleted file mode 100644
index 3ef4635d..00000000
--- a/pkg/postgresflexalpha/configuration.go
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "github.com/stackitcloud/stackit-sdk-go/core/config"
-)
-
-// NewConfiguration returns a new Configuration object
-func NewConfiguration() *config.Configuration {
- cfg := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "stackit-sdk-go/postgresflexalpha",
- Debug: false,
- Servers: config.ServerConfigurations{
- {
- URL: "https://postgres-flex-service.api.{region}stackit.cloud",
- Description: "No description provided",
- Variables: map[string]config.ServerVariable{
- "region": {
- Description: "No description provided",
- DefaultValue: "eu01.",
- EnumValues: []string{
- "eu01.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- return cfg
-}
diff --git a/pkg/postgresflexalpha/model_backup_sort.go b/pkg/postgresflexalpha/model_backup_sort.go
deleted file mode 100644
index 9eba78ee..00000000
--- a/pkg/postgresflexalpha/model_backup_sort.go
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// BackupSort the model 'BackupSort'
-type BackupSort string
-
-// List of backup.sort
-const (
- BACKUPSORT_COMPLETION_TIME_DESC BackupSort = "completion_time.desc"
- BACKUPSORT_COMPLETION_TIME_ASC BackupSort = "completion_time.asc"
- BACKUPSORT_END_TIME_DESC BackupSort = "end_time.desc"
- BACKUPSORT_END_TIME_ASC BackupSort = "end_time.asc"
- BACKUPSORT_INDEX_DESC BackupSort = "index.desc"
- BACKUPSORT_INDEX_ASC BackupSort = "index.asc"
- BACKUPSORT_NAME_DESC BackupSort = "name.desc"
- BACKUPSORT_NAME_ASC BackupSort = "name.asc"
- BACKUPSORT_RETAINED_UNTIL_DESC BackupSort = "retained_until.desc"
- BACKUPSORT_RETAINED_UNTIL_ASC BackupSort = "retained_until.asc"
- BACKUPSORT_SIZE_DESC BackupSort = "size.desc"
- BACKUPSORT_SIZE_ASC BackupSort = "size.asc"
- BACKUPSORT_TYPE_DESC BackupSort = "type.desc"
- BACKUPSORT_TYPE_ASC BackupSort = "type.asc"
-)
-
-// All allowed values of BackupSort enum
-var AllowedBackupSortEnumValues = []BackupSort{
- "completion_time.desc",
- "completion_time.asc",
- "end_time.desc",
- "end_time.asc",
- "index.desc",
- "index.asc",
- "name.desc",
- "name.asc",
- "retained_until.desc",
- "retained_until.asc",
- "size.desc",
- "size.asc",
- "type.desc",
- "type.asc",
-}
-
-func (v *BackupSort) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := BackupSort(value)
- for _, existing := range AllowedBackupSortEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid BackupSort", value)
-}
-
-// NewBackupSortFromValue returns a pointer to a valid BackupSort
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewBackupSortFromValue(v string) (*BackupSort, error) {
- ev := BackupSort(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for BackupSort: valid values are %v", v, AllowedBackupSortEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v BackupSort) IsValid() bool {
- for _, existing := range AllowedBackupSortEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to backup.sort value
-func (v BackupSort) Ptr() *BackupSort {
- return &v
-}
-
-type NullableBackupSort struct {
- value *BackupSort
- isSet bool
-}
-
-func (v NullableBackupSort) Get() *BackupSort {
- return v.value
-}
-
-func (v *NullableBackupSort) Set(val *BackupSort) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableBackupSort) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableBackupSort) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableBackupSort(val *BackupSort) *NullableBackupSort {
- return &NullableBackupSort{value: val, isSet: true}
-}
-
-func (v NullableBackupSort) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableBackupSort) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_backup_sort_test.go b/pkg/postgresflexalpha/model_backup_sort_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_backup_sort_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_create_database_request_payload.go b/pkg/postgresflexalpha/model_create_database_request_payload.go
deleted file mode 100644
index 48083fd8..00000000
--- a/pkg/postgresflexalpha/model_create_database_request_payload.go
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateDatabaseRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateDatabaseRequestPayload{}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type CreateDatabaseRequestPayloadGetNameAttributeType = *string
-
-func getCreateDatabaseRequestPayloadGetNameAttributeTypeOk(arg CreateDatabaseRequestPayloadGetNameAttributeType) (ret CreateDatabaseRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateDatabaseRequestPayloadGetNameAttributeType(arg *CreateDatabaseRequestPayloadGetNameAttributeType, val CreateDatabaseRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type CreateDatabaseRequestPayloadGetNameArgType = string
-type CreateDatabaseRequestPayloadGetNameRetType = string
-
-/*
- types and functions for owner
-*/
-
-// isNotNullableString
-type CreateDatabaseRequestPayloadGetOwnerAttributeType = *string
-
-func getCreateDatabaseRequestPayloadGetOwnerAttributeTypeOk(arg CreateDatabaseRequestPayloadGetOwnerAttributeType) (ret CreateDatabaseRequestPayloadGetOwnerRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateDatabaseRequestPayloadGetOwnerAttributeType(arg *CreateDatabaseRequestPayloadGetOwnerAttributeType, val CreateDatabaseRequestPayloadGetOwnerRetType) {
- *arg = &val
-}
-
-type CreateDatabaseRequestPayloadGetOwnerArgType = string
-type CreateDatabaseRequestPayloadGetOwnerRetType = string
-
-// CreateDatabaseRequestPayload struct for CreateDatabaseRequestPayload
-type CreateDatabaseRequestPayload struct {
- // The name of the database.
- // REQUIRED
- Name CreateDatabaseRequestPayloadGetNameAttributeType `json:"name" required:"true"`
- // The owner of the database.
- Owner CreateDatabaseRequestPayloadGetOwnerAttributeType `json:"owner,omitempty"`
-}
-
-type _CreateDatabaseRequestPayload CreateDatabaseRequestPayload
-
-// NewCreateDatabaseRequestPayload instantiates a new CreateDatabaseRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateDatabaseRequestPayload(name CreateDatabaseRequestPayloadGetNameArgType) *CreateDatabaseRequestPayload {
- this := CreateDatabaseRequestPayload{}
- setCreateDatabaseRequestPayloadGetNameAttributeType(&this.Name, name)
- return &this
-}
-
-// NewCreateDatabaseRequestPayloadWithDefaults instantiates a new CreateDatabaseRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateDatabaseRequestPayloadWithDefaults() *CreateDatabaseRequestPayload {
- this := CreateDatabaseRequestPayload{}
- return &this
-}
-
-// GetName returns the Name field value
-func (o *CreateDatabaseRequestPayload) GetName() (ret CreateDatabaseRequestPayloadGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *CreateDatabaseRequestPayload) GetNameOk() (ret CreateDatabaseRequestPayloadGetNameRetType, ok bool) {
- return getCreateDatabaseRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *CreateDatabaseRequestPayload) SetName(v CreateDatabaseRequestPayloadGetNameRetType) {
- setCreateDatabaseRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetOwner returns the Owner field value if set, zero value otherwise.
-func (o *CreateDatabaseRequestPayload) GetOwner() (res CreateDatabaseRequestPayloadGetOwnerRetType) {
- res, _ = o.GetOwnerOk()
- return
-}
-
-// GetOwnerOk returns a tuple with the Owner field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *CreateDatabaseRequestPayload) GetOwnerOk() (ret CreateDatabaseRequestPayloadGetOwnerRetType, ok bool) {
- return getCreateDatabaseRequestPayloadGetOwnerAttributeTypeOk(o.Owner)
-}
-
-// HasOwner returns a boolean if a field has been set.
-func (o *CreateDatabaseRequestPayload) HasOwner() bool {
- _, ok := o.GetOwnerOk()
- return ok
-}
-
-// SetOwner gets a reference to the given string and assigns it to the Owner field.
-func (o *CreateDatabaseRequestPayload) SetOwner(v CreateDatabaseRequestPayloadGetOwnerRetType) {
- setCreateDatabaseRequestPayloadGetOwnerAttributeType(&o.Owner, v)
-}
-
-func (o CreateDatabaseRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateDatabaseRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getCreateDatabaseRequestPayloadGetOwnerAttributeTypeOk(o.Owner); ok {
- toSerialize["Owner"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateDatabaseRequestPayload struct {
- value *CreateDatabaseRequestPayload
- isSet bool
-}
-
-func (v NullableCreateDatabaseRequestPayload) Get() *CreateDatabaseRequestPayload {
- return v.value
-}
-
-func (v *NullableCreateDatabaseRequestPayload) Set(val *CreateDatabaseRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateDatabaseRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateDatabaseRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateDatabaseRequestPayload(val *CreateDatabaseRequestPayload) *NullableCreateDatabaseRequestPayload {
- return &NullableCreateDatabaseRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableCreateDatabaseRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateDatabaseRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_create_database_request_payload_test.go b/pkg/postgresflexalpha/model_create_database_request_payload_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_create_database_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_create_database_response.go b/pkg/postgresflexalpha/model_create_database_response.go
deleted file mode 100644
index fc450876..00000000
--- a/pkg/postgresflexalpha/model_create_database_response.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateDatabaseResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateDatabaseResponse{}
-
-/*
- types and functions for id
-*/
-
-// isLong
-type CreateDatabaseResponseGetIdAttributeType = *int64
-type CreateDatabaseResponseGetIdArgType = int64
-type CreateDatabaseResponseGetIdRetType = int64
-
-func getCreateDatabaseResponseGetIdAttributeTypeOk(arg CreateDatabaseResponseGetIdAttributeType) (ret CreateDatabaseResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateDatabaseResponseGetIdAttributeType(arg *CreateDatabaseResponseGetIdAttributeType, val CreateDatabaseResponseGetIdRetType) {
- *arg = &val
-}
-
-// CreateDatabaseResponse struct for CreateDatabaseResponse
-type CreateDatabaseResponse struct {
- // The id of the database.
- // REQUIRED
- Id CreateDatabaseResponseGetIdAttributeType `json:"id" required:"true"`
-}
-
-type _CreateDatabaseResponse CreateDatabaseResponse
-
-// NewCreateDatabaseResponse instantiates a new CreateDatabaseResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateDatabaseResponse(id CreateDatabaseResponseGetIdArgType) *CreateDatabaseResponse {
- this := CreateDatabaseResponse{}
- setCreateDatabaseResponseGetIdAttributeType(&this.Id, id)
- return &this
-}
-
-// NewCreateDatabaseResponseWithDefaults instantiates a new CreateDatabaseResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateDatabaseResponseWithDefaults() *CreateDatabaseResponse {
- this := CreateDatabaseResponse{}
- return &this
-}
-
-// GetId returns the Id field value
-func (o *CreateDatabaseResponse) GetId() (ret CreateDatabaseResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *CreateDatabaseResponse) GetIdOk() (ret CreateDatabaseResponseGetIdRetType, ok bool) {
- return getCreateDatabaseResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *CreateDatabaseResponse) SetId(v CreateDatabaseResponseGetIdRetType) {
- setCreateDatabaseResponseGetIdAttributeType(&o.Id, v)
-}
-
-func (o CreateDatabaseResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateDatabaseResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateDatabaseResponse struct {
- value *CreateDatabaseResponse
- isSet bool
-}
-
-func (v NullableCreateDatabaseResponse) Get() *CreateDatabaseResponse {
- return v.value
-}
-
-func (v *NullableCreateDatabaseResponse) Set(val *CreateDatabaseResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateDatabaseResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateDatabaseResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateDatabaseResponse(val *CreateDatabaseResponse) *NullableCreateDatabaseResponse {
- return &NullableCreateDatabaseResponse{value: val, isSet: true}
-}
-
-func (v NullableCreateDatabaseResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateDatabaseResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_create_database_response_test.go b/pkg/postgresflexalpha/model_create_database_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_create_database_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_create_instance_request_payload.go b/pkg/postgresflexalpha/model_create_instance_request_payload.go
deleted file mode 100644
index 8ddd24a0..00000000
--- a/pkg/postgresflexalpha/model_create_instance_request_payload.go
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateInstanceRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateInstanceRequestPayload{}
-
-/*
- types and functions for acl
-*/
-
-// isArray
-type CreateInstanceRequestPayloadGetAclAttributeType = *[]string
-type CreateInstanceRequestPayloadGetAclArgType = []string
-type CreateInstanceRequestPayloadGetAclRetType = []string
-
-func getCreateInstanceRequestPayloadGetAclAttributeTypeOk(arg CreateInstanceRequestPayloadGetAclAttributeType) (ret CreateInstanceRequestPayloadGetAclRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetAclAttributeType(arg *CreateInstanceRequestPayloadGetAclAttributeType, val CreateInstanceRequestPayloadGetAclRetType) {
- *arg = &val
-}
-
-/*
- types and functions for backupSchedule
-*/
-
-// isNotNullableString
-type CreateInstanceRequestPayloadGetBackupScheduleAttributeType = *string
-
-func getCreateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(arg CreateInstanceRequestPayloadGetBackupScheduleAttributeType) (ret CreateInstanceRequestPayloadGetBackupScheduleRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetBackupScheduleAttributeType(arg *CreateInstanceRequestPayloadGetBackupScheduleAttributeType, val CreateInstanceRequestPayloadGetBackupScheduleRetType) {
- *arg = &val
-}
-
-type CreateInstanceRequestPayloadGetBackupScheduleArgType = string
-type CreateInstanceRequestPayloadGetBackupScheduleRetType = string
-
-/*
- types and functions for encryption
-*/
-
-// isModel
-type CreateInstanceRequestPayloadGetEncryptionAttributeType = *InstanceEncryption
-type CreateInstanceRequestPayloadGetEncryptionArgType = InstanceEncryption
-type CreateInstanceRequestPayloadGetEncryptionRetType = InstanceEncryption
-
-func getCreateInstanceRequestPayloadGetEncryptionAttributeTypeOk(arg CreateInstanceRequestPayloadGetEncryptionAttributeType) (ret CreateInstanceRequestPayloadGetEncryptionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetEncryptionAttributeType(arg *CreateInstanceRequestPayloadGetEncryptionAttributeType, val CreateInstanceRequestPayloadGetEncryptionRetType) {
- *arg = &val
-}
-
-/*
- types and functions for flavorId
-*/
-
-// isNotNullableString
-type CreateInstanceRequestPayloadGetFlavorIdAttributeType = *string
-
-func getCreateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(arg CreateInstanceRequestPayloadGetFlavorIdAttributeType) (ret CreateInstanceRequestPayloadGetFlavorIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetFlavorIdAttributeType(arg *CreateInstanceRequestPayloadGetFlavorIdAttributeType, val CreateInstanceRequestPayloadGetFlavorIdRetType) {
- *arg = &val
-}
-
-type CreateInstanceRequestPayloadGetFlavorIdArgType = string
-type CreateInstanceRequestPayloadGetFlavorIdRetType = string
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type CreateInstanceRequestPayloadGetNameAttributeType = *string
-
-func getCreateInstanceRequestPayloadGetNameAttributeTypeOk(arg CreateInstanceRequestPayloadGetNameAttributeType) (ret CreateInstanceRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetNameAttributeType(arg *CreateInstanceRequestPayloadGetNameAttributeType, val CreateInstanceRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type CreateInstanceRequestPayloadGetNameArgType = string
-type CreateInstanceRequestPayloadGetNameRetType = string
-
-/*
- types and functions for network
-*/
-
-// isModel
-type CreateInstanceRequestPayloadGetNetworkAttributeType = *InstanceNetwork
-type CreateInstanceRequestPayloadGetNetworkArgType = InstanceNetwork
-type CreateInstanceRequestPayloadGetNetworkRetType = InstanceNetwork
-
-func getCreateInstanceRequestPayloadGetNetworkAttributeTypeOk(arg CreateInstanceRequestPayloadGetNetworkAttributeType) (ret CreateInstanceRequestPayloadGetNetworkRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetNetworkAttributeType(arg *CreateInstanceRequestPayloadGetNetworkAttributeType, val CreateInstanceRequestPayloadGetNetworkRetType) {
- *arg = &val
-}
-
-/*
- types and functions for replicas
-*/
-
-// isEnumRef
-type CreateInstanceRequestPayloadGetReplicasAttributeType = *Replicas
-type CreateInstanceRequestPayloadGetReplicasArgType = Replicas
-type CreateInstanceRequestPayloadGetReplicasRetType = Replicas
-
-func getCreateInstanceRequestPayloadGetReplicasAttributeTypeOk(arg CreateInstanceRequestPayloadGetReplicasAttributeType) (ret CreateInstanceRequestPayloadGetReplicasRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetReplicasAttributeType(arg *CreateInstanceRequestPayloadGetReplicasAttributeType, val CreateInstanceRequestPayloadGetReplicasRetType) {
- *arg = &val
-}
-
-/*
- types and functions for retentionDays
-*/
-
-// isInteger
-type CreateInstanceRequestPayloadGetRetentionDaysAttributeType = *int64
-type CreateInstanceRequestPayloadGetRetentionDaysArgType = int64
-type CreateInstanceRequestPayloadGetRetentionDaysRetType = int64
-
-func getCreateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(arg CreateInstanceRequestPayloadGetRetentionDaysAttributeType) (ret CreateInstanceRequestPayloadGetRetentionDaysRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetRetentionDaysAttributeType(arg *CreateInstanceRequestPayloadGetRetentionDaysAttributeType, val CreateInstanceRequestPayloadGetRetentionDaysRetType) {
- *arg = &val
-}
-
-/*
- types and functions for storage
-*/
-
-// isModel
-type CreateInstanceRequestPayloadGetStorageAttributeType = *StorageCreate
-type CreateInstanceRequestPayloadGetStorageArgType = StorageCreate
-type CreateInstanceRequestPayloadGetStorageRetType = StorageCreate
-
-func getCreateInstanceRequestPayloadGetStorageAttributeTypeOk(arg CreateInstanceRequestPayloadGetStorageAttributeType) (ret CreateInstanceRequestPayloadGetStorageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetStorageAttributeType(arg *CreateInstanceRequestPayloadGetStorageAttributeType, val CreateInstanceRequestPayloadGetStorageRetType) {
- *arg = &val
-}
-
-/*
- types and functions for version
-*/
-
-// isNotNullableString
-type CreateInstanceRequestPayloadGetVersionAttributeType = *string
-
-func getCreateInstanceRequestPayloadGetVersionAttributeTypeOk(arg CreateInstanceRequestPayloadGetVersionAttributeType) (ret CreateInstanceRequestPayloadGetVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetVersionAttributeType(arg *CreateInstanceRequestPayloadGetVersionAttributeType, val CreateInstanceRequestPayloadGetVersionRetType) {
- *arg = &val
-}
-
-type CreateInstanceRequestPayloadGetVersionArgType = string
-type CreateInstanceRequestPayloadGetVersionRetType = string
-
-// CreateInstanceRequestPayload struct for CreateInstanceRequestPayload
-type CreateInstanceRequestPayload struct {
- // List of IPV4 cidr.
- // REQUIRED
- Acl CreateInstanceRequestPayloadGetAclAttributeType `json:"acl" required:"true"`
- // The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.
- // REQUIRED
- BackupSchedule CreateInstanceRequestPayloadGetBackupScheduleAttributeType `json:"backupSchedule" required:"true"`
- Encryption CreateInstanceRequestPayloadGetEncryptionAttributeType `json:"encryption,omitempty"`
- // The id of the instance flavor.
- // REQUIRED
- FlavorId CreateInstanceRequestPayloadGetFlavorIdAttributeType `json:"flavorId" required:"true"`
- // The name of the instance.
- // REQUIRED
- Name CreateInstanceRequestPayloadGetNameAttributeType `json:"name" required:"true"`
- Network CreateInstanceRequestPayloadGetNetworkAttributeType `json:"network,omitempty"`
- // REQUIRED
- Replicas CreateInstanceRequestPayloadGetReplicasAttributeType `json:"replicas" required:"true"`
- // How long backups are retained. The value can only be between 32 and 365 days.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- RetentionDays CreateInstanceRequestPayloadGetRetentionDaysAttributeType `json:"retentionDays" required:"true"`
- // REQUIRED
- Storage CreateInstanceRequestPayloadGetStorageAttributeType `json:"storage" required:"true"`
- // The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters.
- // REQUIRED
- Version CreateInstanceRequestPayloadGetVersionAttributeType `json:"version" required:"true"`
-}
-
-type _CreateInstanceRequestPayload CreateInstanceRequestPayload
-
-// NewCreateInstanceRequestPayload instantiates a new CreateInstanceRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateInstanceRequestPayload(acl CreateInstanceRequestPayloadGetAclArgType, backupSchedule CreateInstanceRequestPayloadGetBackupScheduleArgType, flavorId CreateInstanceRequestPayloadGetFlavorIdArgType, name CreateInstanceRequestPayloadGetNameArgType, replicas CreateInstanceRequestPayloadGetReplicasArgType, retentionDays CreateInstanceRequestPayloadGetRetentionDaysArgType, storage CreateInstanceRequestPayloadGetStorageArgType, version CreateInstanceRequestPayloadGetVersionArgType) *CreateInstanceRequestPayload {
- this := CreateInstanceRequestPayload{}
- setCreateInstanceRequestPayloadGetAclAttributeType(&this.Acl, acl)
- setCreateInstanceRequestPayloadGetBackupScheduleAttributeType(&this.BackupSchedule, backupSchedule)
- setCreateInstanceRequestPayloadGetFlavorIdAttributeType(&this.FlavorId, flavorId)
- setCreateInstanceRequestPayloadGetNameAttributeType(&this.Name, name)
- setCreateInstanceRequestPayloadGetReplicasAttributeType(&this.Replicas, replicas)
- setCreateInstanceRequestPayloadGetRetentionDaysAttributeType(&this.RetentionDays, retentionDays)
- setCreateInstanceRequestPayloadGetStorageAttributeType(&this.Storage, storage)
- setCreateInstanceRequestPayloadGetVersionAttributeType(&this.Version, version)
- return &this
-}
-
-// NewCreateInstanceRequestPayloadWithDefaults instantiates a new CreateInstanceRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateInstanceRequestPayloadWithDefaults() *CreateInstanceRequestPayload {
- this := CreateInstanceRequestPayload{}
- return &this
-}
-
-// GetAcl returns the Acl field value
-func (o *CreateInstanceRequestPayload) GetAcl() (ret CreateInstanceRequestPayloadGetAclRetType) {
- ret, _ = o.GetAclOk()
- return ret
-}
-
-// GetAclOk returns a tuple with the Acl field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetAclOk() (ret CreateInstanceRequestPayloadGetAclRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetAclAttributeTypeOk(o.Acl)
-}
-
-// SetAcl sets field value
-func (o *CreateInstanceRequestPayload) SetAcl(v CreateInstanceRequestPayloadGetAclRetType) {
- setCreateInstanceRequestPayloadGetAclAttributeType(&o.Acl, v)
-}
-
-// GetBackupSchedule returns the BackupSchedule field value
-func (o *CreateInstanceRequestPayload) GetBackupSchedule() (ret CreateInstanceRequestPayloadGetBackupScheduleRetType) {
- ret, _ = o.GetBackupScheduleOk()
- return ret
-}
-
-// GetBackupScheduleOk returns a tuple with the BackupSchedule field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetBackupScheduleOk() (ret CreateInstanceRequestPayloadGetBackupScheduleRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule)
-}
-
-// SetBackupSchedule sets field value
-func (o *CreateInstanceRequestPayload) SetBackupSchedule(v CreateInstanceRequestPayloadGetBackupScheduleRetType) {
- setCreateInstanceRequestPayloadGetBackupScheduleAttributeType(&o.BackupSchedule, v)
-}
-
-// GetEncryption returns the Encryption field value if set, zero value otherwise.
-func (o *CreateInstanceRequestPayload) GetEncryption() (res CreateInstanceRequestPayloadGetEncryptionRetType) {
- res, _ = o.GetEncryptionOk()
- return
-}
-
-// GetEncryptionOk returns a tuple with the Encryption field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetEncryptionOk() (ret CreateInstanceRequestPayloadGetEncryptionRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetEncryptionAttributeTypeOk(o.Encryption)
-}
-
-// HasEncryption returns a boolean if a field has been set.
-func (o *CreateInstanceRequestPayload) HasEncryption() bool {
- _, ok := o.GetEncryptionOk()
- return ok
-}
-
-// SetEncryption gets a reference to the given InstanceEncryption and assigns it to the Encryption field.
-func (o *CreateInstanceRequestPayload) SetEncryption(v CreateInstanceRequestPayloadGetEncryptionRetType) {
- setCreateInstanceRequestPayloadGetEncryptionAttributeType(&o.Encryption, v)
-}
-
-// GetFlavorId returns the FlavorId field value
-func (o *CreateInstanceRequestPayload) GetFlavorId() (ret CreateInstanceRequestPayloadGetFlavorIdRetType) {
- ret, _ = o.GetFlavorIdOk()
- return ret
-}
-
-// GetFlavorIdOk returns a tuple with the FlavorId field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetFlavorIdOk() (ret CreateInstanceRequestPayloadGetFlavorIdRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId)
-}
-
-// SetFlavorId sets field value
-func (o *CreateInstanceRequestPayload) SetFlavorId(v CreateInstanceRequestPayloadGetFlavorIdRetType) {
- setCreateInstanceRequestPayloadGetFlavorIdAttributeType(&o.FlavorId, v)
-}
-
-// GetName returns the Name field value
-func (o *CreateInstanceRequestPayload) GetName() (ret CreateInstanceRequestPayloadGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetNameOk() (ret CreateInstanceRequestPayloadGetNameRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *CreateInstanceRequestPayload) SetName(v CreateInstanceRequestPayloadGetNameRetType) {
- setCreateInstanceRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetNetwork returns the Network field value if set, zero value otherwise.
-func (o *CreateInstanceRequestPayload) GetNetwork() (res CreateInstanceRequestPayloadGetNetworkRetType) {
- res, _ = o.GetNetworkOk()
- return
-}
-
-// GetNetworkOk returns a tuple with the Network field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetNetworkOk() (ret CreateInstanceRequestPayloadGetNetworkRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetNetworkAttributeTypeOk(o.Network)
-}
-
-// HasNetwork returns a boolean if a field has been set.
-func (o *CreateInstanceRequestPayload) HasNetwork() bool {
- _, ok := o.GetNetworkOk()
- return ok
-}
-
-// SetNetwork gets a reference to the given InstanceNetwork and assigns it to the Network field.
-func (o *CreateInstanceRequestPayload) SetNetwork(v CreateInstanceRequestPayloadGetNetworkRetType) {
- setCreateInstanceRequestPayloadGetNetworkAttributeType(&o.Network, v)
-}
-
-// GetReplicas returns the Replicas field value
-func (o *CreateInstanceRequestPayload) GetReplicas() (ret CreateInstanceRequestPayloadGetReplicasRetType) {
- ret, _ = o.GetReplicasOk()
- return ret
-}
-
-// GetReplicasOk returns a tuple with the Replicas field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetReplicasOk() (ret CreateInstanceRequestPayloadGetReplicasRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetReplicasAttributeTypeOk(o.Replicas)
-}
-
-// SetReplicas sets field value
-func (o *CreateInstanceRequestPayload) SetReplicas(v CreateInstanceRequestPayloadGetReplicasRetType) {
- setCreateInstanceRequestPayloadGetReplicasAttributeType(&o.Replicas, v)
-}
-
-// GetRetentionDays returns the RetentionDays field value
-func (o *CreateInstanceRequestPayload) GetRetentionDays() (ret CreateInstanceRequestPayloadGetRetentionDaysRetType) {
- ret, _ = o.GetRetentionDaysOk()
- return ret
-}
-
-// GetRetentionDaysOk returns a tuple with the RetentionDays field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetRetentionDaysOk() (ret CreateInstanceRequestPayloadGetRetentionDaysRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays)
-}
-
-// SetRetentionDays sets field value
-func (o *CreateInstanceRequestPayload) SetRetentionDays(v CreateInstanceRequestPayloadGetRetentionDaysRetType) {
- setCreateInstanceRequestPayloadGetRetentionDaysAttributeType(&o.RetentionDays, v)
-}
-
-// GetStorage returns the Storage field value
-func (o *CreateInstanceRequestPayload) GetStorage() (ret CreateInstanceRequestPayloadGetStorageRetType) {
- ret, _ = o.GetStorageOk()
- return ret
-}
-
-// GetStorageOk returns a tuple with the Storage field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetStorageOk() (ret CreateInstanceRequestPayloadGetStorageRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetStorageAttributeTypeOk(o.Storage)
-}
-
-// SetStorage sets field value
-func (o *CreateInstanceRequestPayload) SetStorage(v CreateInstanceRequestPayloadGetStorageRetType) {
- setCreateInstanceRequestPayloadGetStorageAttributeType(&o.Storage, v)
-}
-
-// GetVersion returns the Version field value
-func (o *CreateInstanceRequestPayload) GetVersion() (ret CreateInstanceRequestPayloadGetVersionRetType) {
- ret, _ = o.GetVersionOk()
- return ret
-}
-
-// GetVersionOk returns a tuple with the Version field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetVersionOk() (ret CreateInstanceRequestPayloadGetVersionRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetVersionAttributeTypeOk(o.Version)
-}
-
-// SetVersion sets field value
-func (o *CreateInstanceRequestPayload) SetVersion(v CreateInstanceRequestPayloadGetVersionRetType) {
- setCreateInstanceRequestPayloadGetVersionAttributeType(&o.Version, v)
-}
-
-func (o CreateInstanceRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateInstanceRequestPayloadGetAclAttributeTypeOk(o.Acl); ok {
- toSerialize["Acl"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule); ok {
- toSerialize["BackupSchedule"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetEncryptionAttributeTypeOk(o.Encryption); ok {
- toSerialize["Encryption"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId); ok {
- toSerialize["FlavorId"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetNetworkAttributeTypeOk(o.Network); ok {
- toSerialize["Network"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetReplicasAttributeTypeOk(o.Replicas); ok {
- toSerialize["Replicas"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays); ok {
- toSerialize["RetentionDays"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetStorageAttributeTypeOk(o.Storage); ok {
- toSerialize["Storage"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetVersionAttributeTypeOk(o.Version); ok {
- toSerialize["Version"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateInstanceRequestPayload struct {
- value *CreateInstanceRequestPayload
- isSet bool
-}
-
-func (v NullableCreateInstanceRequestPayload) Get() *CreateInstanceRequestPayload {
- return v.value
-}
-
-func (v *NullableCreateInstanceRequestPayload) Set(val *CreateInstanceRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateInstanceRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateInstanceRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateInstanceRequestPayload(val *CreateInstanceRequestPayload) *NullableCreateInstanceRequestPayload {
- return &NullableCreateInstanceRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableCreateInstanceRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateInstanceRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_create_instance_request_payload_test.go b/pkg/postgresflexalpha/model_create_instance_request_payload_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_create_instance_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_create_instance_response.go b/pkg/postgresflexalpha/model_create_instance_response.go
deleted file mode 100644
index def4f984..00000000
--- a/pkg/postgresflexalpha/model_create_instance_response.go
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateInstanceResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateInstanceResponse{}
-
-/*
- types and functions for id
-*/
-
-// isNotNullableString
-type CreateInstanceResponseGetIdAttributeType = *string
-
-func getCreateInstanceResponseGetIdAttributeTypeOk(arg CreateInstanceResponseGetIdAttributeType) (ret CreateInstanceResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceResponseGetIdAttributeType(arg *CreateInstanceResponseGetIdAttributeType, val CreateInstanceResponseGetIdRetType) {
- *arg = &val
-}
-
-type CreateInstanceResponseGetIdArgType = string
-type CreateInstanceResponseGetIdRetType = string
-
-// CreateInstanceResponse struct for CreateInstanceResponse
-type CreateInstanceResponse struct {
- // The ID of the instance.
- // REQUIRED
- Id CreateInstanceResponseGetIdAttributeType `json:"id" required:"true"`
-}
-
-type _CreateInstanceResponse CreateInstanceResponse
-
-// NewCreateInstanceResponse instantiates a new CreateInstanceResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateInstanceResponse(id CreateInstanceResponseGetIdArgType) *CreateInstanceResponse {
- this := CreateInstanceResponse{}
- setCreateInstanceResponseGetIdAttributeType(&this.Id, id)
- return &this
-}
-
-// NewCreateInstanceResponseWithDefaults instantiates a new CreateInstanceResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateInstanceResponseWithDefaults() *CreateInstanceResponse {
- this := CreateInstanceResponse{}
- return &this
-}
-
-// GetId returns the Id field value
-func (o *CreateInstanceResponse) GetId() (ret CreateInstanceResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceResponse) GetIdOk() (ret CreateInstanceResponseGetIdRetType, ok bool) {
- return getCreateInstanceResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *CreateInstanceResponse) SetId(v CreateInstanceResponseGetIdRetType) {
- setCreateInstanceResponseGetIdAttributeType(&o.Id, v)
-}
-
-func (o CreateInstanceResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateInstanceResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateInstanceResponse struct {
- value *CreateInstanceResponse
- isSet bool
-}
-
-func (v NullableCreateInstanceResponse) Get() *CreateInstanceResponse {
- return v.value
-}
-
-func (v *NullableCreateInstanceResponse) Set(val *CreateInstanceResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateInstanceResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateInstanceResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateInstanceResponse(val *CreateInstanceResponse) *NullableCreateInstanceResponse {
- return &NullableCreateInstanceResponse{value: val, isSet: true}
-}
-
-func (v NullableCreateInstanceResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateInstanceResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_create_instance_response_test.go b/pkg/postgresflexalpha/model_create_instance_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_create_instance_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_create_user_request_payload.go b/pkg/postgresflexalpha/model_create_user_request_payload.go
deleted file mode 100644
index b1a1c92b..00000000
--- a/pkg/postgresflexalpha/model_create_user_request_payload.go
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateUserRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateUserRequestPayload{}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type CreateUserRequestPayloadGetNameAttributeType = *string
-
-func getCreateUserRequestPayloadGetNameAttributeTypeOk(arg CreateUserRequestPayloadGetNameAttributeType) (ret CreateUserRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserRequestPayloadGetNameAttributeType(arg *CreateUserRequestPayloadGetNameAttributeType, val CreateUserRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type CreateUserRequestPayloadGetNameArgType = string
-type CreateUserRequestPayloadGetNameRetType = string
-
-/*
- types and functions for roles
-*/
-
-// isArray
-type CreateUserRequestPayloadGetRolesAttributeType = *[]UserRole
-type CreateUserRequestPayloadGetRolesArgType = []UserRole
-type CreateUserRequestPayloadGetRolesRetType = []UserRole
-
-func getCreateUserRequestPayloadGetRolesAttributeTypeOk(arg CreateUserRequestPayloadGetRolesAttributeType) (ret CreateUserRequestPayloadGetRolesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserRequestPayloadGetRolesAttributeType(arg *CreateUserRequestPayloadGetRolesAttributeType, val CreateUserRequestPayloadGetRolesRetType) {
- *arg = &val
-}
-
-// CreateUserRequestPayload struct for CreateUserRequestPayload
-type CreateUserRequestPayload struct {
- // The name of the user.
- // REQUIRED
- Name CreateUserRequestPayloadGetNameAttributeType `json:"name" required:"true"`
- // A list containing the user roles for the instance.
- Roles CreateUserRequestPayloadGetRolesAttributeType `json:"roles,omitempty"`
-}
-
-type _CreateUserRequestPayload CreateUserRequestPayload
-
-// NewCreateUserRequestPayload instantiates a new CreateUserRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateUserRequestPayload(name CreateUserRequestPayloadGetNameArgType) *CreateUserRequestPayload {
- this := CreateUserRequestPayload{}
- setCreateUserRequestPayloadGetNameAttributeType(&this.Name, name)
- return &this
-}
-
-// NewCreateUserRequestPayloadWithDefaults instantiates a new CreateUserRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateUserRequestPayloadWithDefaults() *CreateUserRequestPayload {
- this := CreateUserRequestPayload{}
- return &this
-}
-
-// GetName returns the Name field value
-func (o *CreateUserRequestPayload) GetName() (ret CreateUserRequestPayloadGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserRequestPayload) GetNameOk() (ret CreateUserRequestPayloadGetNameRetType, ok bool) {
- return getCreateUserRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *CreateUserRequestPayload) SetName(v CreateUserRequestPayloadGetNameRetType) {
- setCreateUserRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetRoles returns the Roles field value if set, zero value otherwise.
-func (o *CreateUserRequestPayload) GetRoles() (res CreateUserRequestPayloadGetRolesRetType) {
- res, _ = o.GetRolesOk()
- return
-}
-
-// GetRolesOk returns a tuple with the Roles field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *CreateUserRequestPayload) GetRolesOk() (ret CreateUserRequestPayloadGetRolesRetType, ok bool) {
- return getCreateUserRequestPayloadGetRolesAttributeTypeOk(o.Roles)
-}
-
-// HasRoles returns a boolean if a field has been set.
-func (o *CreateUserRequestPayload) HasRoles() bool {
- _, ok := o.GetRolesOk()
- return ok
-}
-
-// SetRoles gets a reference to the given []UserRole and assigns it to the Roles field.
-func (o *CreateUserRequestPayload) SetRoles(v CreateUserRequestPayloadGetRolesRetType) {
- setCreateUserRequestPayloadGetRolesAttributeType(&o.Roles, v)
-}
-
-func (o CreateUserRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateUserRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getCreateUserRequestPayloadGetRolesAttributeTypeOk(o.Roles); ok {
- toSerialize["Roles"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateUserRequestPayload struct {
- value *CreateUserRequestPayload
- isSet bool
-}
-
-func (v NullableCreateUserRequestPayload) Get() *CreateUserRequestPayload {
- return v.value
-}
-
-func (v *NullableCreateUserRequestPayload) Set(val *CreateUserRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateUserRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateUserRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateUserRequestPayload(val *CreateUserRequestPayload) *NullableCreateUserRequestPayload {
- return &NullableCreateUserRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableCreateUserRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateUserRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_create_user_request_payload_test.go b/pkg/postgresflexalpha/model_create_user_request_payload_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_create_user_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_create_user_response.go b/pkg/postgresflexalpha/model_create_user_response.go
deleted file mode 100644
index 66367782..00000000
--- a/pkg/postgresflexalpha/model_create_user_response.go
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateUserResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateUserResponse{}
-
-/*
- types and functions for connectionString
-*/
-
-// isNotNullableString
-type CreateUserResponseGetConnectionStringAttributeType = *string
-
-func getCreateUserResponseGetConnectionStringAttributeTypeOk(arg CreateUserResponseGetConnectionStringAttributeType) (ret CreateUserResponseGetConnectionStringRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetConnectionStringAttributeType(arg *CreateUserResponseGetConnectionStringAttributeType, val CreateUserResponseGetConnectionStringRetType) {
- *arg = &val
-}
-
-type CreateUserResponseGetConnectionStringArgType = string
-type CreateUserResponseGetConnectionStringRetType = string
-
-/*
- types and functions for id
-*/
-
-// isLong
-type CreateUserResponseGetIdAttributeType = *int64
-type CreateUserResponseGetIdArgType = int64
-type CreateUserResponseGetIdRetType = int64
-
-func getCreateUserResponseGetIdAttributeTypeOk(arg CreateUserResponseGetIdAttributeType) (ret CreateUserResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetIdAttributeType(arg *CreateUserResponseGetIdAttributeType, val CreateUserResponseGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type CreateUserResponseGetNameAttributeType = *string
-
-func getCreateUserResponseGetNameAttributeTypeOk(arg CreateUserResponseGetNameAttributeType) (ret CreateUserResponseGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetNameAttributeType(arg *CreateUserResponseGetNameAttributeType, val CreateUserResponseGetNameRetType) {
- *arg = &val
-}
-
-type CreateUserResponseGetNameArgType = string
-type CreateUserResponseGetNameRetType = string
-
-/*
- types and functions for password
-*/
-
-// isNotNullableString
-type CreateUserResponseGetPasswordAttributeType = *string
-
-func getCreateUserResponseGetPasswordAttributeTypeOk(arg CreateUserResponseGetPasswordAttributeType) (ret CreateUserResponseGetPasswordRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetPasswordAttributeType(arg *CreateUserResponseGetPasswordAttributeType, val CreateUserResponseGetPasswordRetType) {
- *arg = &val
-}
-
-type CreateUserResponseGetPasswordArgType = string
-type CreateUserResponseGetPasswordRetType = string
-
-/*
- types and functions for status
-*/
-
-// isNotNullableString
-type CreateUserResponseGetStatusAttributeType = *string
-
-func getCreateUserResponseGetStatusAttributeTypeOk(arg CreateUserResponseGetStatusAttributeType) (ret CreateUserResponseGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetStatusAttributeType(arg *CreateUserResponseGetStatusAttributeType, val CreateUserResponseGetStatusRetType) {
- *arg = &val
-}
-
-type CreateUserResponseGetStatusArgType = string
-type CreateUserResponseGetStatusRetType = string
-
-// CreateUserResponse struct for CreateUserResponse
-type CreateUserResponse struct {
- // The connection string for the user to the instance.
- // REQUIRED
- ConnectionString CreateUserResponseGetConnectionStringAttributeType `json:"connectionString" required:"true"`
- // The ID of the user.
- // REQUIRED
- Id CreateUserResponseGetIdAttributeType `json:"id" required:"true"`
- // The name of the user.
- // REQUIRED
- Name CreateUserResponseGetNameAttributeType `json:"name" required:"true"`
- // The password for the user.
- // REQUIRED
- Password CreateUserResponseGetPasswordAttributeType `json:"password" required:"true"`
- // The current status of the user.
- // REQUIRED
- Status CreateUserResponseGetStatusAttributeType `json:"status" required:"true"`
-}
-
-type _CreateUserResponse CreateUserResponse
-
-// NewCreateUserResponse instantiates a new CreateUserResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateUserResponse(connectionString CreateUserResponseGetConnectionStringArgType, id CreateUserResponseGetIdArgType, name CreateUserResponseGetNameArgType, password CreateUserResponseGetPasswordArgType, status CreateUserResponseGetStatusArgType) *CreateUserResponse {
- this := CreateUserResponse{}
- setCreateUserResponseGetConnectionStringAttributeType(&this.ConnectionString, connectionString)
- setCreateUserResponseGetIdAttributeType(&this.Id, id)
- setCreateUserResponseGetNameAttributeType(&this.Name, name)
- setCreateUserResponseGetPasswordAttributeType(&this.Password, password)
- setCreateUserResponseGetStatusAttributeType(&this.Status, status)
- return &this
-}
-
-// NewCreateUserResponseWithDefaults instantiates a new CreateUserResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateUserResponseWithDefaults() *CreateUserResponse {
- this := CreateUserResponse{}
- return &this
-}
-
-// GetConnectionString returns the ConnectionString field value
-func (o *CreateUserResponse) GetConnectionString() (ret CreateUserResponseGetConnectionStringRetType) {
- ret, _ = o.GetConnectionStringOk()
- return ret
-}
-
-// GetConnectionStringOk returns a tuple with the ConnectionString field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetConnectionStringOk() (ret CreateUserResponseGetConnectionStringRetType, ok bool) {
- return getCreateUserResponseGetConnectionStringAttributeTypeOk(o.ConnectionString)
-}
-
-// SetConnectionString sets field value
-func (o *CreateUserResponse) SetConnectionString(v CreateUserResponseGetConnectionStringRetType) {
- setCreateUserResponseGetConnectionStringAttributeType(&o.ConnectionString, v)
-}
-
-// GetId returns the Id field value
-func (o *CreateUserResponse) GetId() (ret CreateUserResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetIdOk() (ret CreateUserResponseGetIdRetType, ok bool) {
- return getCreateUserResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *CreateUserResponse) SetId(v CreateUserResponseGetIdRetType) {
- setCreateUserResponseGetIdAttributeType(&o.Id, v)
-}
-
-// GetName returns the Name field value
-func (o *CreateUserResponse) GetName() (ret CreateUserResponseGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetNameOk() (ret CreateUserResponseGetNameRetType, ok bool) {
- return getCreateUserResponseGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *CreateUserResponse) SetName(v CreateUserResponseGetNameRetType) {
- setCreateUserResponseGetNameAttributeType(&o.Name, v)
-}
-
-// GetPassword returns the Password field value
-func (o *CreateUserResponse) GetPassword() (ret CreateUserResponseGetPasswordRetType) {
- ret, _ = o.GetPasswordOk()
- return ret
-}
-
-// GetPasswordOk returns a tuple with the Password field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetPasswordOk() (ret CreateUserResponseGetPasswordRetType, ok bool) {
- return getCreateUserResponseGetPasswordAttributeTypeOk(o.Password)
-}
-
-// SetPassword sets field value
-func (o *CreateUserResponse) SetPassword(v CreateUserResponseGetPasswordRetType) {
- setCreateUserResponseGetPasswordAttributeType(&o.Password, v)
-}
-
-// GetStatus returns the Status field value
-func (o *CreateUserResponse) GetStatus() (ret CreateUserResponseGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetStatusOk() (ret CreateUserResponseGetStatusRetType, ok bool) {
- return getCreateUserResponseGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *CreateUserResponse) SetStatus(v CreateUserResponseGetStatusRetType) {
- setCreateUserResponseGetStatusAttributeType(&o.Status, v)
-}
-
-func (o CreateUserResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateUserResponseGetConnectionStringAttributeTypeOk(o.ConnectionString); ok {
- toSerialize["ConnectionString"] = val
- }
- if val, ok := getCreateUserResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getCreateUserResponseGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getCreateUserResponseGetPasswordAttributeTypeOk(o.Password); ok {
- toSerialize["Password"] = val
- }
- if val, ok := getCreateUserResponseGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateUserResponse struct {
- value *CreateUserResponse
- isSet bool
-}
-
-func (v NullableCreateUserResponse) Get() *CreateUserResponse {
- return v.value
-}
-
-func (v *NullableCreateUserResponse) Set(val *CreateUserResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateUserResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateUserResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateUserResponse(val *CreateUserResponse) *NullableCreateUserResponse {
- return &NullableCreateUserResponse{value: val, isSet: true}
-}
-
-func (v NullableCreateUserResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateUserResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_create_user_response_test.go b/pkg/postgresflexalpha/model_create_user_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_create_user_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_database_roles.go b/pkg/postgresflexalpha/model_database_roles.go
deleted file mode 100644
index 39d89310..00000000
--- a/pkg/postgresflexalpha/model_database_roles.go
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the DatabaseRoles type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &DatabaseRoles{}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type DatabaseRolesGetNameAttributeType = *string
-
-func getDatabaseRolesGetNameAttributeTypeOk(arg DatabaseRolesGetNameAttributeType) (ret DatabaseRolesGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setDatabaseRolesGetNameAttributeType(arg *DatabaseRolesGetNameAttributeType, val DatabaseRolesGetNameRetType) {
- *arg = &val
-}
-
-type DatabaseRolesGetNameArgType = string
-type DatabaseRolesGetNameRetType = string
-
-/*
- types and functions for roles
-*/
-
-// isArray
-type DatabaseRolesGetRolesAttributeType = *[]string
-type DatabaseRolesGetRolesArgType = []string
-type DatabaseRolesGetRolesRetType = []string
-
-func getDatabaseRolesGetRolesAttributeTypeOk(arg DatabaseRolesGetRolesAttributeType) (ret DatabaseRolesGetRolesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setDatabaseRolesGetRolesAttributeType(arg *DatabaseRolesGetRolesAttributeType, val DatabaseRolesGetRolesRetType) {
- *arg = &val
-}
-
-// DatabaseRoles The name and the roles for a database for a user.
-type DatabaseRoles struct {
- // The name of the database.
- // REQUIRED
- Name DatabaseRolesGetNameAttributeType `json:"name" required:"true"`
- // The name and the roles for a database
- // REQUIRED
- Roles DatabaseRolesGetRolesAttributeType `json:"roles" required:"true"`
-}
-
-type _DatabaseRoles DatabaseRoles
-
-// NewDatabaseRoles instantiates a new DatabaseRoles object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewDatabaseRoles(name DatabaseRolesGetNameArgType, roles DatabaseRolesGetRolesArgType) *DatabaseRoles {
- this := DatabaseRoles{}
- setDatabaseRolesGetNameAttributeType(&this.Name, name)
- setDatabaseRolesGetRolesAttributeType(&this.Roles, roles)
- return &this
-}
-
-// NewDatabaseRolesWithDefaults instantiates a new DatabaseRoles object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewDatabaseRolesWithDefaults() *DatabaseRoles {
- this := DatabaseRoles{}
- return &this
-}
-
-// GetName returns the Name field value
-func (o *DatabaseRoles) GetName() (ret DatabaseRolesGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *DatabaseRoles) GetNameOk() (ret DatabaseRolesGetNameRetType, ok bool) {
- return getDatabaseRolesGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *DatabaseRoles) SetName(v DatabaseRolesGetNameRetType) {
- setDatabaseRolesGetNameAttributeType(&o.Name, v)
-}
-
-// GetRoles returns the Roles field value
-func (o *DatabaseRoles) GetRoles() (ret DatabaseRolesGetRolesRetType) {
- ret, _ = o.GetRolesOk()
- return ret
-}
-
-// GetRolesOk returns a tuple with the Roles field value
-// and a boolean to check if the value has been set.
-func (o *DatabaseRoles) GetRolesOk() (ret DatabaseRolesGetRolesRetType, ok bool) {
- return getDatabaseRolesGetRolesAttributeTypeOk(o.Roles)
-}
-
-// SetRoles sets field value
-func (o *DatabaseRoles) SetRoles(v DatabaseRolesGetRolesRetType) {
- setDatabaseRolesGetRolesAttributeType(&o.Roles, v)
-}
-
-func (o DatabaseRoles) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getDatabaseRolesGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getDatabaseRolesGetRolesAttributeTypeOk(o.Roles); ok {
- toSerialize["Roles"] = val
- }
- return toSerialize, nil
-}
-
-type NullableDatabaseRoles struct {
- value *DatabaseRoles
- isSet bool
-}
-
-func (v NullableDatabaseRoles) Get() *DatabaseRoles {
- return v.value
-}
-
-func (v *NullableDatabaseRoles) Set(val *DatabaseRoles) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableDatabaseRoles) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableDatabaseRoles) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableDatabaseRoles(val *DatabaseRoles) *NullableDatabaseRoles {
- return &NullableDatabaseRoles{value: val, isSet: true}
-}
-
-func (v NullableDatabaseRoles) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableDatabaseRoles) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_database_roles_test.go b/pkg/postgresflexalpha/model_database_roles_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_database_roles_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_database_sort.go b/pkg/postgresflexalpha/model_database_sort.go
deleted file mode 100644
index 29f4c390..00000000
--- a/pkg/postgresflexalpha/model_database_sort.go
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// DatabaseSort the model 'DatabaseSort'
-type DatabaseSort string
-
-// List of database.sort
-const (
- DATABASESORT_CREATED_AT_DESC DatabaseSort = "created_at.desc"
- DATABASESORT_CREATED_AT_ASC DatabaseSort = "created_at.asc"
- DATABASESORT_DATABASE_ID_DESC DatabaseSort = "database_id.desc"
- DATABASESORT_DATABASE_ID_ASC DatabaseSort = "database_id.asc"
- DATABASESORT_DATABASE_NAME_DESC DatabaseSort = "database_name.desc"
- DATABASESORT_DATABASE_NAME_ASC DatabaseSort = "database_name.asc"
- DATABASESORT_DATABASE_OWNER_DESC DatabaseSort = "database_owner.desc"
- DATABASESORT_DATABASE_OWNER_ASC DatabaseSort = "database_owner.asc"
- DATABASESORT_INDEX_ASC DatabaseSort = "index.asc"
- DATABASESORT_INDEX_DESC DatabaseSort = "index.desc"
-)
-
-// All allowed values of DatabaseSort enum
-var AllowedDatabaseSortEnumValues = []DatabaseSort{
- "created_at.desc",
- "created_at.asc",
- "database_id.desc",
- "database_id.asc",
- "database_name.desc",
- "database_name.asc",
- "database_owner.desc",
- "database_owner.asc",
- "index.asc",
- "index.desc",
-}
-
-func (v *DatabaseSort) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := DatabaseSort(value)
- for _, existing := range AllowedDatabaseSortEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid DatabaseSort", value)
-}
-
-// NewDatabaseSortFromValue returns a pointer to a valid DatabaseSort
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewDatabaseSortFromValue(v string) (*DatabaseSort, error) {
- ev := DatabaseSort(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for DatabaseSort: valid values are %v", v, AllowedDatabaseSortEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v DatabaseSort) IsValid() bool {
- for _, existing := range AllowedDatabaseSortEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to database.sort value
-func (v DatabaseSort) Ptr() *DatabaseSort {
- return &v
-}
-
-type NullableDatabaseSort struct {
- value *DatabaseSort
- isSet bool
-}
-
-func (v NullableDatabaseSort) Get() *DatabaseSort {
- return v.value
-}
-
-func (v *NullableDatabaseSort) Set(val *DatabaseSort) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableDatabaseSort) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableDatabaseSort) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableDatabaseSort(val *DatabaseSort) *NullableDatabaseSort {
- return &NullableDatabaseSort{value: val, isSet: true}
-}
-
-func (v NullableDatabaseSort) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableDatabaseSort) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_database_sort_test.go b/pkg/postgresflexalpha/model_database_sort_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_database_sort_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_error.go b/pkg/postgresflexalpha/model_error.go
deleted file mode 100644
index a9722ada..00000000
--- a/pkg/postgresflexalpha/model_error.go
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the Error type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &Error{}
-
-/*
- types and functions for code
-*/
-
-// isInteger
-type ErrorGetCodeAttributeType = *int64
-type ErrorGetCodeArgType = int64
-type ErrorGetCodeRetType = int64
-
-func getErrorGetCodeAttributeTypeOk(arg ErrorGetCodeAttributeType) (ret ErrorGetCodeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setErrorGetCodeAttributeType(arg *ErrorGetCodeAttributeType, val ErrorGetCodeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for message
-*/
-
-// isNotNullableString
-type ErrorGetMessageAttributeType = *string
-
-func getErrorGetMessageAttributeTypeOk(arg ErrorGetMessageAttributeType) (ret ErrorGetMessageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setErrorGetMessageAttributeType(arg *ErrorGetMessageAttributeType, val ErrorGetMessageRetType) {
- *arg = &val
-}
-
-type ErrorGetMessageArgType = string
-type ErrorGetMessageRetType = string
-
-/*
- types and functions for traceId
-*/
-
-// isNotNullableString
-type ErrorGetTraceIdAttributeType = *string
-
-func getErrorGetTraceIdAttributeTypeOk(arg ErrorGetTraceIdAttributeType) (ret ErrorGetTraceIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setErrorGetTraceIdAttributeType(arg *ErrorGetTraceIdAttributeType, val ErrorGetTraceIdRetType) {
- *arg = &val
-}
-
-type ErrorGetTraceIdArgType = string
-type ErrorGetTraceIdRetType = string
-
-/*
- types and functions for type
-*/
-
-// isNotNullableString
-type ErrorGetTypeAttributeType = *string
-
-func getErrorGetTypeAttributeTypeOk(arg ErrorGetTypeAttributeType) (ret ErrorGetTypeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setErrorGetTypeAttributeType(arg *ErrorGetTypeAttributeType, val ErrorGetTypeRetType) {
- *arg = &val
-}
-
-type ErrorGetTypeArgType = string
-type ErrorGetTypeRetType = string
-
-// Error struct for Error
-type Error struct {
- // The http error code of the error.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- Code ErrorGetCodeAttributeType `json:"code" required:"true"`
- // More detailed information about the error.
- // REQUIRED
- Message ErrorGetMessageAttributeType `json:"message" required:"true"`
- // The trace id of the request.
- // REQUIRED
- TraceId ErrorGetTraceIdAttributeType `json:"traceId" required:"true"`
- // Describes in which state the api was when the error happened.
- // REQUIRED
- Type ErrorGetTypeAttributeType `json:"type" required:"true"`
-}
-
-type _Error Error
-
-// NewError instantiates a new Error object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewError(code ErrorGetCodeArgType, message ErrorGetMessageArgType, traceId ErrorGetTraceIdArgType, types ErrorGetTypeArgType) *Error {
- this := Error{}
- setErrorGetCodeAttributeType(&this.Code, code)
- setErrorGetMessageAttributeType(&this.Message, message)
- setErrorGetTraceIdAttributeType(&this.TraceId, traceId)
- setErrorGetTypeAttributeType(&this.Type, types)
- return &this
-}
-
-// NewErrorWithDefaults instantiates a new Error object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewErrorWithDefaults() *Error {
- this := Error{}
- return &this
-}
-
-// GetCode returns the Code field value
-func (o *Error) GetCode() (ret ErrorGetCodeRetType) {
- ret, _ = o.GetCodeOk()
- return ret
-}
-
-// GetCodeOk returns a tuple with the Code field value
-// and a boolean to check if the value has been set.
-func (o *Error) GetCodeOk() (ret ErrorGetCodeRetType, ok bool) {
- return getErrorGetCodeAttributeTypeOk(o.Code)
-}
-
-// SetCode sets field value
-func (o *Error) SetCode(v ErrorGetCodeRetType) {
- setErrorGetCodeAttributeType(&o.Code, v)
-}
-
-// GetMessage returns the Message field value
-func (o *Error) GetMessage() (ret ErrorGetMessageRetType) {
- ret, _ = o.GetMessageOk()
- return ret
-}
-
-// GetMessageOk returns a tuple with the Message field value
-// and a boolean to check if the value has been set.
-func (o *Error) GetMessageOk() (ret ErrorGetMessageRetType, ok bool) {
- return getErrorGetMessageAttributeTypeOk(o.Message)
-}
-
-// SetMessage sets field value
-func (o *Error) SetMessage(v ErrorGetMessageRetType) {
- setErrorGetMessageAttributeType(&o.Message, v)
-}
-
-// GetTraceId returns the TraceId field value
-func (o *Error) GetTraceId() (ret ErrorGetTraceIdRetType) {
- ret, _ = o.GetTraceIdOk()
- return ret
-}
-
-// GetTraceIdOk returns a tuple with the TraceId field value
-// and a boolean to check if the value has been set.
-func (o *Error) GetTraceIdOk() (ret ErrorGetTraceIdRetType, ok bool) {
- return getErrorGetTraceIdAttributeTypeOk(o.TraceId)
-}
-
-// SetTraceId sets field value
-func (o *Error) SetTraceId(v ErrorGetTraceIdRetType) {
- setErrorGetTraceIdAttributeType(&o.TraceId, v)
-}
-
-// GetType returns the Type field value
-func (o *Error) GetType() (ret ErrorGetTypeRetType) {
- ret, _ = o.GetTypeOk()
- return ret
-}
-
-// GetTypeOk returns a tuple with the Type field value
-// and a boolean to check if the value has been set.
-func (o *Error) GetTypeOk() (ret ErrorGetTypeRetType, ok bool) {
- return getErrorGetTypeAttributeTypeOk(o.Type)
-}
-
-// SetType sets field value
-func (o *Error) SetType(v ErrorGetTypeRetType) {
- setErrorGetTypeAttributeType(&o.Type, v)
-}
-
-func (o Error) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getErrorGetCodeAttributeTypeOk(o.Code); ok {
- toSerialize["Code"] = val
- }
- if val, ok := getErrorGetMessageAttributeTypeOk(o.Message); ok {
- toSerialize["Message"] = val
- }
- if val, ok := getErrorGetTraceIdAttributeTypeOk(o.TraceId); ok {
- toSerialize["TraceId"] = val
- }
- if val, ok := getErrorGetTypeAttributeTypeOk(o.Type); ok {
- toSerialize["Type"] = val
- }
- return toSerialize, nil
-}
-
-type NullableError struct {
- value *Error
- isSet bool
-}
-
-func (v NullableError) Get() *Error {
- return v.value
-}
-
-func (v *NullableError) Set(val *Error) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableError) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableError) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableError(val *Error) *NullableError {
- return &NullableError{value: val, isSet: true}
-}
-
-func (v NullableError) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableError) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_error_test.go b/pkg/postgresflexalpha/model_error_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_error_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_flavor_sort.go b/pkg/postgresflexalpha/model_flavor_sort.go
deleted file mode 100644
index aadbef23..00000000
--- a/pkg/postgresflexalpha/model_flavor_sort.go
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// FlavorSort the model 'FlavorSort'
-type FlavorSort string
-
-// List of flavor.sort
-const (
- FLAVORSORT_INDEX_DESC FlavorSort = "index.desc"
- FLAVORSORT_INDEX_ASC FlavorSort = "index.asc"
- FLAVORSORT_CPU_DESC FlavorSort = "cpu.desc"
- FLAVORSORT_CPU_ASC FlavorSort = "cpu.asc"
- FLAVORSORT_FLAVOR_DESCRIPTION_ASC FlavorSort = "flavor_description.asc"
- FLAVORSORT_FLAVOR_DESCRIPTION_DESC FlavorSort = "flavor_description.desc"
- FLAVORSORT_ID_DESC FlavorSort = "id.desc"
- FLAVORSORT_ID_ASC FlavorSort = "id.asc"
- FLAVORSORT_SIZE_MAX_DESC FlavorSort = "size_max.desc"
- FLAVORSORT_SIZE_MAX_ASC FlavorSort = "size_max.asc"
- FLAVORSORT_RAM_DESC FlavorSort = "ram.desc"
- FLAVORSORT_RAM_ASC FlavorSort = "ram.asc"
- FLAVORSORT_SIZE_MIN_DESC FlavorSort = "size_min.desc"
- FLAVORSORT_SIZE_MIN_ASC FlavorSort = "size_min.asc"
- FLAVORSORT_STORAGE_CLASS_ASC FlavorSort = "storage_class.asc"
- FLAVORSORT_STORAGE_CLASS_DESC FlavorSort = "storage_class.desc"
- FLAVORSORT_NODE_TYPE_ASC FlavorSort = "node_type.asc"
- FLAVORSORT_NODE_TYPE_DESC FlavorSort = "node_type.desc"
-)
-
-// All allowed values of FlavorSort enum
-var AllowedFlavorSortEnumValues = []FlavorSort{
- "index.desc",
- "index.asc",
- "cpu.desc",
- "cpu.asc",
- "flavor_description.asc",
- "flavor_description.desc",
- "id.desc",
- "id.asc",
- "size_max.desc",
- "size_max.asc",
- "ram.desc",
- "ram.asc",
- "size_min.desc",
- "size_min.asc",
- "storage_class.asc",
- "storage_class.desc",
- "node_type.asc",
- "node_type.desc",
-}
-
-func (v *FlavorSort) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := FlavorSort(value)
- for _, existing := range AllowedFlavorSortEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid FlavorSort", value)
-}
-
-// NewFlavorSortFromValue returns a pointer to a valid FlavorSort
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewFlavorSortFromValue(v string) (*FlavorSort, error) {
- ev := FlavorSort(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for FlavorSort: valid values are %v", v, AllowedFlavorSortEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v FlavorSort) IsValid() bool {
- for _, existing := range AllowedFlavorSortEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to flavor.sort value
-func (v FlavorSort) Ptr() *FlavorSort {
- return &v
-}
-
-type NullableFlavorSort struct {
- value *FlavorSort
- isSet bool
-}
-
-func (v NullableFlavorSort) Get() *FlavorSort {
- return v.value
-}
-
-func (v *NullableFlavorSort) Set(val *FlavorSort) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableFlavorSort) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableFlavorSort) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableFlavorSort(val *FlavorSort) *NullableFlavorSort {
- return &NullableFlavorSort{value: val, isSet: true}
-}
-
-func (v NullableFlavorSort) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableFlavorSort) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_flavor_sort_test.go b/pkg/postgresflexalpha/model_flavor_sort_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_flavor_sort_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_flavor_storage_classes_storage_class.go b/pkg/postgresflexalpha/model_flavor_storage_classes_storage_class.go
deleted file mode 100644
index 0ae4bbec..00000000
--- a/pkg/postgresflexalpha/model_flavor_storage_classes_storage_class.go
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the FlavorStorageClassesStorageClass type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &FlavorStorageClassesStorageClass{}
-
-/*
- types and functions for class
-*/
-
-// isNotNullableString
-type FlavorStorageClassesStorageClassGetClassAttributeType = *string
-
-func getFlavorStorageClassesStorageClassGetClassAttributeTypeOk(arg FlavorStorageClassesStorageClassGetClassAttributeType) (ret FlavorStorageClassesStorageClassGetClassRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setFlavorStorageClassesStorageClassGetClassAttributeType(arg *FlavorStorageClassesStorageClassGetClassAttributeType, val FlavorStorageClassesStorageClassGetClassRetType) {
- *arg = &val
-}
-
-type FlavorStorageClassesStorageClassGetClassArgType = string
-type FlavorStorageClassesStorageClassGetClassRetType = string
-
-/*
- types and functions for maxIoPerSec
-*/
-
-// isInteger
-type FlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType = *int64
-type FlavorStorageClassesStorageClassGetMaxIoPerSecArgType = int64
-type FlavorStorageClassesStorageClassGetMaxIoPerSecRetType = int64
-
-func getFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeTypeOk(arg FlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType) (ret FlavorStorageClassesStorageClassGetMaxIoPerSecRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType(arg *FlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType, val FlavorStorageClassesStorageClassGetMaxIoPerSecRetType) {
- *arg = &val
-}
-
-/*
- types and functions for maxThroughInMb
-*/
-
-// isInteger
-type FlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType = *int64
-type FlavorStorageClassesStorageClassGetMaxThroughInMbArgType = int64
-type FlavorStorageClassesStorageClassGetMaxThroughInMbRetType = int64
-
-func getFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeTypeOk(arg FlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType) (ret FlavorStorageClassesStorageClassGetMaxThroughInMbRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType(arg *FlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType, val FlavorStorageClassesStorageClassGetMaxThroughInMbRetType) {
- *arg = &val
-}
-
-// FlavorStorageClassesStorageClass a storageClass defines how efficient the storage can work
-type FlavorStorageClassesStorageClass struct {
- // REQUIRED
- Class FlavorStorageClassesStorageClassGetClassAttributeType `json:"class" required:"true"`
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- MaxIoPerSec FlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType `json:"maxIoPerSec" required:"true"`
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- MaxThroughInMb FlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType `json:"maxThroughInMb" required:"true"`
-}
-
-type _FlavorStorageClassesStorageClass FlavorStorageClassesStorageClass
-
-// NewFlavorStorageClassesStorageClass instantiates a new FlavorStorageClassesStorageClass object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewFlavorStorageClassesStorageClass(class FlavorStorageClassesStorageClassGetClassArgType, maxIoPerSec FlavorStorageClassesStorageClassGetMaxIoPerSecArgType, maxThroughInMb FlavorStorageClassesStorageClassGetMaxThroughInMbArgType) *FlavorStorageClassesStorageClass {
- this := FlavorStorageClassesStorageClass{}
- setFlavorStorageClassesStorageClassGetClassAttributeType(&this.Class, class)
- setFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType(&this.MaxIoPerSec, maxIoPerSec)
- setFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType(&this.MaxThroughInMb, maxThroughInMb)
- return &this
-}
-
-// NewFlavorStorageClassesStorageClassWithDefaults instantiates a new FlavorStorageClassesStorageClass object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewFlavorStorageClassesStorageClassWithDefaults() *FlavorStorageClassesStorageClass {
- this := FlavorStorageClassesStorageClass{}
- return &this
-}
-
-// GetClass returns the Class field value
-func (o *FlavorStorageClassesStorageClass) GetClass() (ret FlavorStorageClassesStorageClassGetClassRetType) {
- ret, _ = o.GetClassOk()
- return ret
-}
-
-// GetClassOk returns a tuple with the Class field value
-// and a boolean to check if the value has been set.
-func (o *FlavorStorageClassesStorageClass) GetClassOk() (ret FlavorStorageClassesStorageClassGetClassRetType, ok bool) {
- return getFlavorStorageClassesStorageClassGetClassAttributeTypeOk(o.Class)
-}
-
-// SetClass sets field value
-func (o *FlavorStorageClassesStorageClass) SetClass(v FlavorStorageClassesStorageClassGetClassRetType) {
- setFlavorStorageClassesStorageClassGetClassAttributeType(&o.Class, v)
-}
-
-// GetMaxIoPerSec returns the MaxIoPerSec field value
-func (o *FlavorStorageClassesStorageClass) GetMaxIoPerSec() (ret FlavorStorageClassesStorageClassGetMaxIoPerSecRetType) {
- ret, _ = o.GetMaxIoPerSecOk()
- return ret
-}
-
-// GetMaxIoPerSecOk returns a tuple with the MaxIoPerSec field value
-// and a boolean to check if the value has been set.
-func (o *FlavorStorageClassesStorageClass) GetMaxIoPerSecOk() (ret FlavorStorageClassesStorageClassGetMaxIoPerSecRetType, ok bool) {
- return getFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeTypeOk(o.MaxIoPerSec)
-}
-
-// SetMaxIoPerSec sets field value
-func (o *FlavorStorageClassesStorageClass) SetMaxIoPerSec(v FlavorStorageClassesStorageClassGetMaxIoPerSecRetType) {
- setFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType(&o.MaxIoPerSec, v)
-}
-
-// GetMaxThroughInMb returns the MaxThroughInMb field value
-func (o *FlavorStorageClassesStorageClass) GetMaxThroughInMb() (ret FlavorStorageClassesStorageClassGetMaxThroughInMbRetType) {
- ret, _ = o.GetMaxThroughInMbOk()
- return ret
-}
-
-// GetMaxThroughInMbOk returns a tuple with the MaxThroughInMb field value
-// and a boolean to check if the value has been set.
-func (o *FlavorStorageClassesStorageClass) GetMaxThroughInMbOk() (ret FlavorStorageClassesStorageClassGetMaxThroughInMbRetType, ok bool) {
- return getFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeTypeOk(o.MaxThroughInMb)
-}
-
-// SetMaxThroughInMb sets field value
-func (o *FlavorStorageClassesStorageClass) SetMaxThroughInMb(v FlavorStorageClassesStorageClassGetMaxThroughInMbRetType) {
- setFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType(&o.MaxThroughInMb, v)
-}
-
-func (o FlavorStorageClassesStorageClass) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getFlavorStorageClassesStorageClassGetClassAttributeTypeOk(o.Class); ok {
- toSerialize["Class"] = val
- }
- if val, ok := getFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeTypeOk(o.MaxIoPerSec); ok {
- toSerialize["MaxIoPerSec"] = val
- }
- if val, ok := getFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeTypeOk(o.MaxThroughInMb); ok {
- toSerialize["MaxThroughInMb"] = val
- }
- return toSerialize, nil
-}
-
-type NullableFlavorStorageClassesStorageClass struct {
- value *FlavorStorageClassesStorageClass
- isSet bool
-}
-
-func (v NullableFlavorStorageClassesStorageClass) Get() *FlavorStorageClassesStorageClass {
- return v.value
-}
-
-func (v *NullableFlavorStorageClassesStorageClass) Set(val *FlavorStorageClassesStorageClass) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableFlavorStorageClassesStorageClass) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableFlavorStorageClassesStorageClass) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableFlavorStorageClassesStorageClass(val *FlavorStorageClassesStorageClass) *NullableFlavorStorageClassesStorageClass {
- return &NullableFlavorStorageClassesStorageClass{value: val, isSet: true}
-}
-
-func (v NullableFlavorStorageClassesStorageClass) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableFlavorStorageClassesStorageClass) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_flavor_storage_classes_storage_class_test.go b/pkg/postgresflexalpha/model_flavor_storage_classes_storage_class_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_flavor_storage_classes_storage_class_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_get_backup_response.go b/pkg/postgresflexalpha/model_get_backup_response.go
deleted file mode 100644
index 9432ade1..00000000
--- a/pkg/postgresflexalpha/model_get_backup_response.go
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetBackupResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetBackupResponse{}
-
-/*
- types and functions for completionTime
-*/
-
-// isNotNullableString
-type GetBackupResponseGetCompletionTimeAttributeType = *string
-
-func getGetBackupResponseGetCompletionTimeAttributeTypeOk(arg GetBackupResponseGetCompletionTimeAttributeType) (ret GetBackupResponseGetCompletionTimeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetCompletionTimeAttributeType(arg *GetBackupResponseGetCompletionTimeAttributeType, val GetBackupResponseGetCompletionTimeRetType) {
- *arg = &val
-}
-
-type GetBackupResponseGetCompletionTimeArgType = string
-type GetBackupResponseGetCompletionTimeRetType = string
-
-/*
- types and functions for id
-*/
-
-// isLong
-type GetBackupResponseGetIdAttributeType = *int64
-type GetBackupResponseGetIdArgType = int64
-type GetBackupResponseGetIdRetType = int64
-
-func getGetBackupResponseGetIdAttributeTypeOk(arg GetBackupResponseGetIdAttributeType) (ret GetBackupResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetIdAttributeType(arg *GetBackupResponseGetIdAttributeType, val GetBackupResponseGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type GetBackupResponseGetNameAttributeType = *string
-
-func getGetBackupResponseGetNameAttributeTypeOk(arg GetBackupResponseGetNameAttributeType) (ret GetBackupResponseGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetNameAttributeType(arg *GetBackupResponseGetNameAttributeType, val GetBackupResponseGetNameRetType) {
- *arg = &val
-}
-
-type GetBackupResponseGetNameArgType = string
-type GetBackupResponseGetNameRetType = string
-
-/*
- types and functions for retainedUntil
-*/
-
-// isNotNullableString
-type GetBackupResponseGetRetainedUntilAttributeType = *string
-
-func getGetBackupResponseGetRetainedUntilAttributeTypeOk(arg GetBackupResponseGetRetainedUntilAttributeType) (ret GetBackupResponseGetRetainedUntilRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetRetainedUntilAttributeType(arg *GetBackupResponseGetRetainedUntilAttributeType, val GetBackupResponseGetRetainedUntilRetType) {
- *arg = &val
-}
-
-type GetBackupResponseGetRetainedUntilArgType = string
-type GetBackupResponseGetRetainedUntilRetType = string
-
-/*
- types and functions for size
-*/
-
-// isLong
-type GetBackupResponseGetSizeAttributeType = *int64
-type GetBackupResponseGetSizeArgType = int64
-type GetBackupResponseGetSizeRetType = int64
-
-func getGetBackupResponseGetSizeAttributeTypeOk(arg GetBackupResponseGetSizeAttributeType) (ret GetBackupResponseGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetSizeAttributeType(arg *GetBackupResponseGetSizeAttributeType, val GetBackupResponseGetSizeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for type
-*/
-
-// isNotNullableString
-type GetBackupResponseGetTypeAttributeType = *string
-
-func getGetBackupResponseGetTypeAttributeTypeOk(arg GetBackupResponseGetTypeAttributeType) (ret GetBackupResponseGetTypeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetTypeAttributeType(arg *GetBackupResponseGetTypeAttributeType, val GetBackupResponseGetTypeRetType) {
- *arg = &val
-}
-
-type GetBackupResponseGetTypeArgType = string
-type GetBackupResponseGetTypeRetType = string
-
-// GetBackupResponse struct for GetBackupResponse
-type GetBackupResponse struct {
- // The time when the backup was completed in RFC3339 format.
- // REQUIRED
- CompletionTime GetBackupResponseGetCompletionTimeAttributeType `json:"completionTime" required:"true"`
- // The ID of the backup.
- // REQUIRED
- Id GetBackupResponseGetIdAttributeType `json:"id" required:"true"`
- // The name of the backup.
- // REQUIRED
- Name GetBackupResponseGetNameAttributeType `json:"name" required:"true"`
- // The time until the backup will be retained.
- // REQUIRED
- RetainedUntil GetBackupResponseGetRetainedUntilAttributeType `json:"retainedUntil" required:"true"`
- // The size of the backup in bytes.
- // REQUIRED
- Size GetBackupResponseGetSizeAttributeType `json:"size" required:"true"`
- // The type of the backup, which can be automated or manual triggered.
- // REQUIRED
- Type GetBackupResponseGetTypeAttributeType `json:"type" required:"true"`
-}
-
-type _GetBackupResponse GetBackupResponse
-
-// NewGetBackupResponse instantiates a new GetBackupResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetBackupResponse(completionTime GetBackupResponseGetCompletionTimeArgType, id GetBackupResponseGetIdArgType, name GetBackupResponseGetNameArgType, retainedUntil GetBackupResponseGetRetainedUntilArgType, size GetBackupResponseGetSizeArgType, types GetBackupResponseGetTypeArgType) *GetBackupResponse {
- this := GetBackupResponse{}
- setGetBackupResponseGetCompletionTimeAttributeType(&this.CompletionTime, completionTime)
- setGetBackupResponseGetIdAttributeType(&this.Id, id)
- setGetBackupResponseGetNameAttributeType(&this.Name, name)
- setGetBackupResponseGetRetainedUntilAttributeType(&this.RetainedUntil, retainedUntil)
- setGetBackupResponseGetSizeAttributeType(&this.Size, size)
- setGetBackupResponseGetTypeAttributeType(&this.Type, types)
- return &this
-}
-
-// NewGetBackupResponseWithDefaults instantiates a new GetBackupResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetBackupResponseWithDefaults() *GetBackupResponse {
- this := GetBackupResponse{}
- return &this
-}
-
-// GetCompletionTime returns the CompletionTime field value
-func (o *GetBackupResponse) GetCompletionTime() (ret GetBackupResponseGetCompletionTimeRetType) {
- ret, _ = o.GetCompletionTimeOk()
- return ret
-}
-
-// GetCompletionTimeOk returns a tuple with the CompletionTime field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetCompletionTimeOk() (ret GetBackupResponseGetCompletionTimeRetType, ok bool) {
- return getGetBackupResponseGetCompletionTimeAttributeTypeOk(o.CompletionTime)
-}
-
-// SetCompletionTime sets field value
-func (o *GetBackupResponse) SetCompletionTime(v GetBackupResponseGetCompletionTimeRetType) {
- setGetBackupResponseGetCompletionTimeAttributeType(&o.CompletionTime, v)
-}
-
-// GetId returns the Id field value
-func (o *GetBackupResponse) GetId() (ret GetBackupResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetIdOk() (ret GetBackupResponseGetIdRetType, ok bool) {
- return getGetBackupResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *GetBackupResponse) SetId(v GetBackupResponseGetIdRetType) {
- setGetBackupResponseGetIdAttributeType(&o.Id, v)
-}
-
-// GetName returns the Name field value
-func (o *GetBackupResponse) GetName() (ret GetBackupResponseGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetNameOk() (ret GetBackupResponseGetNameRetType, ok bool) {
- return getGetBackupResponseGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *GetBackupResponse) SetName(v GetBackupResponseGetNameRetType) {
- setGetBackupResponseGetNameAttributeType(&o.Name, v)
-}
-
-// GetRetainedUntil returns the RetainedUntil field value
-func (o *GetBackupResponse) GetRetainedUntil() (ret GetBackupResponseGetRetainedUntilRetType) {
- ret, _ = o.GetRetainedUntilOk()
- return ret
-}
-
-// GetRetainedUntilOk returns a tuple with the RetainedUntil field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetRetainedUntilOk() (ret GetBackupResponseGetRetainedUntilRetType, ok bool) {
- return getGetBackupResponseGetRetainedUntilAttributeTypeOk(o.RetainedUntil)
-}
-
-// SetRetainedUntil sets field value
-func (o *GetBackupResponse) SetRetainedUntil(v GetBackupResponseGetRetainedUntilRetType) {
- setGetBackupResponseGetRetainedUntilAttributeType(&o.RetainedUntil, v)
-}
-
-// GetSize returns the Size field value
-func (o *GetBackupResponse) GetSize() (ret GetBackupResponseGetSizeRetType) {
- ret, _ = o.GetSizeOk()
- return ret
-}
-
-// GetSizeOk returns a tuple with the Size field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetSizeOk() (ret GetBackupResponseGetSizeRetType, ok bool) {
- return getGetBackupResponseGetSizeAttributeTypeOk(o.Size)
-}
-
-// SetSize sets field value
-func (o *GetBackupResponse) SetSize(v GetBackupResponseGetSizeRetType) {
- setGetBackupResponseGetSizeAttributeType(&o.Size, v)
-}
-
-// GetType returns the Type field value
-func (o *GetBackupResponse) GetType() (ret GetBackupResponseGetTypeRetType) {
- ret, _ = o.GetTypeOk()
- return ret
-}
-
-// GetTypeOk returns a tuple with the Type field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetTypeOk() (ret GetBackupResponseGetTypeRetType, ok bool) {
- return getGetBackupResponseGetTypeAttributeTypeOk(o.Type)
-}
-
-// SetType sets field value
-func (o *GetBackupResponse) SetType(v GetBackupResponseGetTypeRetType) {
- setGetBackupResponseGetTypeAttributeType(&o.Type, v)
-}
-
-func (o GetBackupResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetBackupResponseGetCompletionTimeAttributeTypeOk(o.CompletionTime); ok {
- toSerialize["CompletionTime"] = val
- }
- if val, ok := getGetBackupResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getGetBackupResponseGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getGetBackupResponseGetRetainedUntilAttributeTypeOk(o.RetainedUntil); ok {
- toSerialize["RetainedUntil"] = val
- }
- if val, ok := getGetBackupResponseGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- if val, ok := getGetBackupResponseGetTypeAttributeTypeOk(o.Type); ok {
- toSerialize["Type"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetBackupResponse struct {
- value *GetBackupResponse
- isSet bool
-}
-
-func (v NullableGetBackupResponse) Get() *GetBackupResponse {
- return v.value
-}
-
-func (v *NullableGetBackupResponse) Set(val *GetBackupResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetBackupResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetBackupResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetBackupResponse(val *GetBackupResponse) *NullableGetBackupResponse {
- return &NullableGetBackupResponse{value: val, isSet: true}
-}
-
-func (v NullableGetBackupResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetBackupResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_get_backup_response_test.go b/pkg/postgresflexalpha/model_get_backup_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_get_backup_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_get_collations_response.go b/pkg/postgresflexalpha/model_get_collations_response.go
deleted file mode 100644
index cc2750db..00000000
--- a/pkg/postgresflexalpha/model_get_collations_response.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetCollationsResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetCollationsResponse{}
-
-/*
- types and functions for collations
-*/
-
-// isArray
-type GetCollationsResponseGetCollationsAttributeType = *[]string
-type GetCollationsResponseGetCollationsArgType = []string
-type GetCollationsResponseGetCollationsRetType = []string
-
-func getGetCollationsResponseGetCollationsAttributeTypeOk(arg GetCollationsResponseGetCollationsAttributeType) (ret GetCollationsResponseGetCollationsRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetCollationsResponseGetCollationsAttributeType(arg *GetCollationsResponseGetCollationsAttributeType, val GetCollationsResponseGetCollationsRetType) {
- *arg = &val
-}
-
-// GetCollationsResponse struct for GetCollationsResponse
-type GetCollationsResponse struct {
- // List of collations available for the instance.
- // REQUIRED
- Collations GetCollationsResponseGetCollationsAttributeType `json:"collations" required:"true"`
-}
-
-type _GetCollationsResponse GetCollationsResponse
-
-// NewGetCollationsResponse instantiates a new GetCollationsResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetCollationsResponse(collations GetCollationsResponseGetCollationsArgType) *GetCollationsResponse {
- this := GetCollationsResponse{}
- setGetCollationsResponseGetCollationsAttributeType(&this.Collations, collations)
- return &this
-}
-
-// NewGetCollationsResponseWithDefaults instantiates a new GetCollationsResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetCollationsResponseWithDefaults() *GetCollationsResponse {
- this := GetCollationsResponse{}
- return &this
-}
-
-// GetCollations returns the Collations field value
-func (o *GetCollationsResponse) GetCollations() (ret GetCollationsResponseGetCollationsRetType) {
- ret, _ = o.GetCollationsOk()
- return ret
-}
-
-// GetCollationsOk returns a tuple with the Collations field value
-// and a boolean to check if the value has been set.
-func (o *GetCollationsResponse) GetCollationsOk() (ret GetCollationsResponseGetCollationsRetType, ok bool) {
- return getGetCollationsResponseGetCollationsAttributeTypeOk(o.Collations)
-}
-
-// SetCollations sets field value
-func (o *GetCollationsResponse) SetCollations(v GetCollationsResponseGetCollationsRetType) {
- setGetCollationsResponseGetCollationsAttributeType(&o.Collations, v)
-}
-
-func (o GetCollationsResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetCollationsResponseGetCollationsAttributeTypeOk(o.Collations); ok {
- toSerialize["Collations"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetCollationsResponse struct {
- value *GetCollationsResponse
- isSet bool
-}
-
-func (v NullableGetCollationsResponse) Get() *GetCollationsResponse {
- return v.value
-}
-
-func (v *NullableGetCollationsResponse) Set(val *GetCollationsResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetCollationsResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetCollationsResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetCollationsResponse(val *GetCollationsResponse) *NullableGetCollationsResponse {
- return &NullableGetCollationsResponse{value: val, isSet: true}
-}
-
-func (v NullableGetCollationsResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetCollationsResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_get_collations_response_test.go b/pkg/postgresflexalpha/model_get_collations_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_get_collations_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_get_flavors_response.go b/pkg/postgresflexalpha/model_get_flavors_response.go
deleted file mode 100644
index 685c6bd5..00000000
--- a/pkg/postgresflexalpha/model_get_flavors_response.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetFlavorsResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetFlavorsResponse{}
-
-/*
- types and functions for flavors
-*/
-
-// isArray
-type GetFlavorsResponseGetFlavorsAttributeType = *[]ListFlavors
-type GetFlavorsResponseGetFlavorsArgType = []ListFlavors
-type GetFlavorsResponseGetFlavorsRetType = []ListFlavors
-
-func getGetFlavorsResponseGetFlavorsAttributeTypeOk(arg GetFlavorsResponseGetFlavorsAttributeType) (ret GetFlavorsResponseGetFlavorsRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetFlavorsResponseGetFlavorsAttributeType(arg *GetFlavorsResponseGetFlavorsAttributeType, val GetFlavorsResponseGetFlavorsRetType) {
- *arg = &val
-}
-
-/*
- types and functions for pagination
-*/
-
-// isModel
-type GetFlavorsResponseGetPaginationAttributeType = *Pagination
-type GetFlavorsResponseGetPaginationArgType = Pagination
-type GetFlavorsResponseGetPaginationRetType = Pagination
-
-func getGetFlavorsResponseGetPaginationAttributeTypeOk(arg GetFlavorsResponseGetPaginationAttributeType) (ret GetFlavorsResponseGetPaginationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetFlavorsResponseGetPaginationAttributeType(arg *GetFlavorsResponseGetPaginationAttributeType, val GetFlavorsResponseGetPaginationRetType) {
- *arg = &val
-}
-
-// GetFlavorsResponse struct for GetFlavorsResponse
-type GetFlavorsResponse struct {
- // List of flavors available for the project.
- // REQUIRED
- Flavors GetFlavorsResponseGetFlavorsAttributeType `json:"flavors" required:"true"`
- // REQUIRED
- Pagination GetFlavorsResponseGetPaginationAttributeType `json:"pagination" required:"true"`
-}
-
-type _GetFlavorsResponse GetFlavorsResponse
-
-// NewGetFlavorsResponse instantiates a new GetFlavorsResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetFlavorsResponse(flavors GetFlavorsResponseGetFlavorsArgType, pagination GetFlavorsResponseGetPaginationArgType) *GetFlavorsResponse {
- this := GetFlavorsResponse{}
- setGetFlavorsResponseGetFlavorsAttributeType(&this.Flavors, flavors)
- setGetFlavorsResponseGetPaginationAttributeType(&this.Pagination, pagination)
- return &this
-}
-
-// NewGetFlavorsResponseWithDefaults instantiates a new GetFlavorsResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetFlavorsResponseWithDefaults() *GetFlavorsResponse {
- this := GetFlavorsResponse{}
- return &this
-}
-
-// GetFlavors returns the Flavors field value
-func (o *GetFlavorsResponse) GetFlavors() (ret GetFlavorsResponseGetFlavorsRetType) {
- ret, _ = o.GetFlavorsOk()
- return ret
-}
-
-// GetFlavorsOk returns a tuple with the Flavors field value
-// and a boolean to check if the value has been set.
-func (o *GetFlavorsResponse) GetFlavorsOk() (ret GetFlavorsResponseGetFlavorsRetType, ok bool) {
- return getGetFlavorsResponseGetFlavorsAttributeTypeOk(o.Flavors)
-}
-
-// SetFlavors sets field value
-func (o *GetFlavorsResponse) SetFlavors(v GetFlavorsResponseGetFlavorsRetType) {
- setGetFlavorsResponseGetFlavorsAttributeType(&o.Flavors, v)
-}
-
-// GetPagination returns the Pagination field value
-func (o *GetFlavorsResponse) GetPagination() (ret GetFlavorsResponseGetPaginationRetType) {
- ret, _ = o.GetPaginationOk()
- return ret
-}
-
-// GetPaginationOk returns a tuple with the Pagination field value
-// and a boolean to check if the value has been set.
-func (o *GetFlavorsResponse) GetPaginationOk() (ret GetFlavorsResponseGetPaginationRetType, ok bool) {
- return getGetFlavorsResponseGetPaginationAttributeTypeOk(o.Pagination)
-}
-
-// SetPagination sets field value
-func (o *GetFlavorsResponse) SetPagination(v GetFlavorsResponseGetPaginationRetType) {
- setGetFlavorsResponseGetPaginationAttributeType(&o.Pagination, v)
-}
-
-func (o GetFlavorsResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetFlavorsResponseGetFlavorsAttributeTypeOk(o.Flavors); ok {
- toSerialize["Flavors"] = val
- }
- if val, ok := getGetFlavorsResponseGetPaginationAttributeTypeOk(o.Pagination); ok {
- toSerialize["Pagination"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetFlavorsResponse struct {
- value *GetFlavorsResponse
- isSet bool
-}
-
-func (v NullableGetFlavorsResponse) Get() *GetFlavorsResponse {
- return v.value
-}
-
-func (v *NullableGetFlavorsResponse) Set(val *GetFlavorsResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetFlavorsResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetFlavorsResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetFlavorsResponse(val *GetFlavorsResponse) *NullableGetFlavorsResponse {
- return &NullableGetFlavorsResponse{value: val, isSet: true}
-}
-
-func (v NullableGetFlavorsResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetFlavorsResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_get_flavors_response_test.go b/pkg/postgresflexalpha/model_get_flavors_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_get_flavors_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_get_instance_response.go b/pkg/postgresflexalpha/model_get_instance_response.go
deleted file mode 100644
index f30ec04b..00000000
--- a/pkg/postgresflexalpha/model_get_instance_response.go
+++ /dev/null
@@ -1,569 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetInstanceResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetInstanceResponse{}
-
-/*
- types and functions for acl
-*/
-
-// isArray
-type GetInstanceResponseGetAclAttributeType = *[]string
-type GetInstanceResponseGetAclArgType = []string
-type GetInstanceResponseGetAclRetType = []string
-
-func getGetInstanceResponseGetAclAttributeTypeOk(arg GetInstanceResponseGetAclAttributeType) (ret GetInstanceResponseGetAclRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetAclAttributeType(arg *GetInstanceResponseGetAclAttributeType, val GetInstanceResponseGetAclRetType) {
- *arg = &val
-}
-
-/*
- types and functions for backupSchedule
-*/
-
-// isNotNullableString
-type GetInstanceResponseGetBackupScheduleAttributeType = *string
-
-func getGetInstanceResponseGetBackupScheduleAttributeTypeOk(arg GetInstanceResponseGetBackupScheduleAttributeType) (ret GetInstanceResponseGetBackupScheduleRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetBackupScheduleAttributeType(arg *GetInstanceResponseGetBackupScheduleAttributeType, val GetInstanceResponseGetBackupScheduleRetType) {
- *arg = &val
-}
-
-type GetInstanceResponseGetBackupScheduleArgType = string
-type GetInstanceResponseGetBackupScheduleRetType = string
-
-/*
- types and functions for flavorId
-*/
-
-// isNotNullableString
-type GetInstanceResponseGetFlavorIdAttributeType = *string
-
-func getGetInstanceResponseGetFlavorIdAttributeTypeOk(arg GetInstanceResponseGetFlavorIdAttributeType) (ret GetInstanceResponseGetFlavorIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetFlavorIdAttributeType(arg *GetInstanceResponseGetFlavorIdAttributeType, val GetInstanceResponseGetFlavorIdRetType) {
- *arg = &val
-}
-
-type GetInstanceResponseGetFlavorIdArgType = string
-type GetInstanceResponseGetFlavorIdRetType = string
-
-/*
- types and functions for id
-*/
-
-// isNotNullableString
-type GetInstanceResponseGetIdAttributeType = *string
-
-func getGetInstanceResponseGetIdAttributeTypeOk(arg GetInstanceResponseGetIdAttributeType) (ret GetInstanceResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetIdAttributeType(arg *GetInstanceResponseGetIdAttributeType, val GetInstanceResponseGetIdRetType) {
- *arg = &val
-}
-
-type GetInstanceResponseGetIdArgType = string
-type GetInstanceResponseGetIdRetType = string
-
-/*
- types and functions for isDeletable
-*/
-
-// isBoolean
-type GetInstanceResponsegetIsDeletableAttributeType = *bool
-type GetInstanceResponsegetIsDeletableArgType = bool
-type GetInstanceResponsegetIsDeletableRetType = bool
-
-func getGetInstanceResponsegetIsDeletableAttributeTypeOk(arg GetInstanceResponsegetIsDeletableAttributeType) (ret GetInstanceResponsegetIsDeletableRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponsegetIsDeletableAttributeType(arg *GetInstanceResponsegetIsDeletableAttributeType, val GetInstanceResponsegetIsDeletableRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type GetInstanceResponseGetNameAttributeType = *string
-
-func getGetInstanceResponseGetNameAttributeTypeOk(arg GetInstanceResponseGetNameAttributeType) (ret GetInstanceResponseGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetNameAttributeType(arg *GetInstanceResponseGetNameAttributeType, val GetInstanceResponseGetNameRetType) {
- *arg = &val
-}
-
-type GetInstanceResponseGetNameArgType = string
-type GetInstanceResponseGetNameRetType = string
-
-/*
- types and functions for replicas
-*/
-
-// isEnumRef
-type GetInstanceResponseGetReplicasAttributeType = *Replicas
-type GetInstanceResponseGetReplicasArgType = Replicas
-type GetInstanceResponseGetReplicasRetType = Replicas
-
-func getGetInstanceResponseGetReplicasAttributeTypeOk(arg GetInstanceResponseGetReplicasAttributeType) (ret GetInstanceResponseGetReplicasRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetReplicasAttributeType(arg *GetInstanceResponseGetReplicasAttributeType, val GetInstanceResponseGetReplicasRetType) {
- *arg = &val
-}
-
-/*
- types and functions for retentionDays
-*/
-
-// isInteger
-type GetInstanceResponseGetRetentionDaysAttributeType = *int64
-type GetInstanceResponseGetRetentionDaysArgType = int64
-type GetInstanceResponseGetRetentionDaysRetType = int64
-
-func getGetInstanceResponseGetRetentionDaysAttributeTypeOk(arg GetInstanceResponseGetRetentionDaysAttributeType) (ret GetInstanceResponseGetRetentionDaysRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetRetentionDaysAttributeType(arg *GetInstanceResponseGetRetentionDaysAttributeType, val GetInstanceResponseGetRetentionDaysRetType) {
- *arg = &val
-}
-
-/*
- types and functions for status
-*/
-
-// isEnumRef
-type GetInstanceResponseGetStatusAttributeType = *Status
-type GetInstanceResponseGetStatusArgType = Status
-type GetInstanceResponseGetStatusRetType = Status
-
-func getGetInstanceResponseGetStatusAttributeTypeOk(arg GetInstanceResponseGetStatusAttributeType) (ret GetInstanceResponseGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetStatusAttributeType(arg *GetInstanceResponseGetStatusAttributeType, val GetInstanceResponseGetStatusRetType) {
- *arg = &val
-}
-
-/*
- types and functions for storage
-*/
-
-// isModel
-type GetInstanceResponseGetStorageAttributeType = *Storage
-type GetInstanceResponseGetStorageArgType = Storage
-type GetInstanceResponseGetStorageRetType = Storage
-
-func getGetInstanceResponseGetStorageAttributeTypeOk(arg GetInstanceResponseGetStorageAttributeType) (ret GetInstanceResponseGetStorageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetStorageAttributeType(arg *GetInstanceResponseGetStorageAttributeType, val GetInstanceResponseGetStorageRetType) {
- *arg = &val
-}
-
-/*
- types and functions for version
-*/
-
-// isNotNullableString
-type GetInstanceResponseGetVersionAttributeType = *string
-
-func getGetInstanceResponseGetVersionAttributeTypeOk(arg GetInstanceResponseGetVersionAttributeType) (ret GetInstanceResponseGetVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetVersionAttributeType(arg *GetInstanceResponseGetVersionAttributeType, val GetInstanceResponseGetVersionRetType) {
- *arg = &val
-}
-
-type GetInstanceResponseGetVersionArgType = string
-type GetInstanceResponseGetVersionRetType = string
-
-// GetInstanceResponse struct for GetInstanceResponse
-type GetInstanceResponse struct {
- // List of IPV4 cidr.
- // REQUIRED
- Acl GetInstanceResponseGetAclAttributeType `json:"acl" required:"true"`
- // The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.
- // REQUIRED
- BackupSchedule GetInstanceResponseGetBackupScheduleAttributeType `json:"backupSchedule" required:"true"`
- // The id of the instance flavor.
- // REQUIRED
- FlavorId GetInstanceResponseGetFlavorIdAttributeType `json:"flavorId" required:"true"`
- // The ID of the instance.
- // REQUIRED
- Id GetInstanceResponseGetIdAttributeType `json:"id" required:"true"`
- // Whether the instance can be deleted or not.
- // REQUIRED
- IsDeletable GetInstanceResponsegetIsDeletableAttributeType `json:"isDeletable" required:"true"`
- // The name of the instance.
- // REQUIRED
- Name GetInstanceResponseGetNameAttributeType `json:"name" required:"true"`
- // REQUIRED
- Replicas GetInstanceResponseGetReplicasAttributeType `json:"replicas" required:"true"`
- // How long backups are retained. The value can only be between 32 and 365 days.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- RetentionDays GetInstanceResponseGetRetentionDaysAttributeType `json:"retentionDays" required:"true"`
- // REQUIRED
- Status GetInstanceResponseGetStatusAttributeType `json:"status" required:"true"`
- // REQUIRED
- Storage GetInstanceResponseGetStorageAttributeType `json:"storage" required:"true"`
- // The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters.
- // REQUIRED
- Version GetInstanceResponseGetVersionAttributeType `json:"version" required:"true"`
-}
-
-type _GetInstanceResponse GetInstanceResponse
-
-// NewGetInstanceResponse instantiates a new GetInstanceResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetInstanceResponse(acl GetInstanceResponseGetAclArgType, backupSchedule GetInstanceResponseGetBackupScheduleArgType, flavorId GetInstanceResponseGetFlavorIdArgType, id GetInstanceResponseGetIdArgType, isDeletable GetInstanceResponsegetIsDeletableArgType, name GetInstanceResponseGetNameArgType, replicas GetInstanceResponseGetReplicasArgType, retentionDays GetInstanceResponseGetRetentionDaysArgType, status GetInstanceResponseGetStatusArgType, storage GetInstanceResponseGetStorageArgType, version GetInstanceResponseGetVersionArgType) *GetInstanceResponse {
- this := GetInstanceResponse{}
- setGetInstanceResponseGetAclAttributeType(&this.Acl, acl)
- setGetInstanceResponseGetBackupScheduleAttributeType(&this.BackupSchedule, backupSchedule)
- setGetInstanceResponseGetFlavorIdAttributeType(&this.FlavorId, flavorId)
- setGetInstanceResponseGetIdAttributeType(&this.Id, id)
- setGetInstanceResponsegetIsDeletableAttributeType(&this.IsDeletable, isDeletable)
- setGetInstanceResponseGetNameAttributeType(&this.Name, name)
- setGetInstanceResponseGetReplicasAttributeType(&this.Replicas, replicas)
- setGetInstanceResponseGetRetentionDaysAttributeType(&this.RetentionDays, retentionDays)
- setGetInstanceResponseGetStatusAttributeType(&this.Status, status)
- setGetInstanceResponseGetStorageAttributeType(&this.Storage, storage)
- setGetInstanceResponseGetVersionAttributeType(&this.Version, version)
- return &this
-}
-
-// NewGetInstanceResponseWithDefaults instantiates a new GetInstanceResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetInstanceResponseWithDefaults() *GetInstanceResponse {
- this := GetInstanceResponse{}
- return &this
-}
-
-// GetAcl returns the Acl field value
-func (o *GetInstanceResponse) GetAcl() (ret GetInstanceResponseGetAclRetType) {
- ret, _ = o.GetAclOk()
- return ret
-}
-
-// GetAclOk returns a tuple with the Acl field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetAclOk() (ret GetInstanceResponseGetAclRetType, ok bool) {
- return getGetInstanceResponseGetAclAttributeTypeOk(o.Acl)
-}
-
-// SetAcl sets field value
-func (o *GetInstanceResponse) SetAcl(v GetInstanceResponseGetAclRetType) {
- setGetInstanceResponseGetAclAttributeType(&o.Acl, v)
-}
-
-// GetBackupSchedule returns the BackupSchedule field value
-func (o *GetInstanceResponse) GetBackupSchedule() (ret GetInstanceResponseGetBackupScheduleRetType) {
- ret, _ = o.GetBackupScheduleOk()
- return ret
-}
-
-// GetBackupScheduleOk returns a tuple with the BackupSchedule field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetBackupScheduleOk() (ret GetInstanceResponseGetBackupScheduleRetType, ok bool) {
- return getGetInstanceResponseGetBackupScheduleAttributeTypeOk(o.BackupSchedule)
-}
-
-// SetBackupSchedule sets field value
-func (o *GetInstanceResponse) SetBackupSchedule(v GetInstanceResponseGetBackupScheduleRetType) {
- setGetInstanceResponseGetBackupScheduleAttributeType(&o.BackupSchedule, v)
-}
-
-// GetFlavorId returns the FlavorId field value
-func (o *GetInstanceResponse) GetFlavorId() (ret GetInstanceResponseGetFlavorIdRetType) {
- ret, _ = o.GetFlavorIdOk()
- return ret
-}
-
-// GetFlavorIdOk returns a tuple with the FlavorId field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetFlavorIdOk() (ret GetInstanceResponseGetFlavorIdRetType, ok bool) {
- return getGetInstanceResponseGetFlavorIdAttributeTypeOk(o.FlavorId)
-}
-
-// SetFlavorId sets field value
-func (o *GetInstanceResponse) SetFlavorId(v GetInstanceResponseGetFlavorIdRetType) {
- setGetInstanceResponseGetFlavorIdAttributeType(&o.FlavorId, v)
-}
-
-// GetId returns the Id field value
-func (o *GetInstanceResponse) GetId() (ret GetInstanceResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetIdOk() (ret GetInstanceResponseGetIdRetType, ok bool) {
- return getGetInstanceResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *GetInstanceResponse) SetId(v GetInstanceResponseGetIdRetType) {
- setGetInstanceResponseGetIdAttributeType(&o.Id, v)
-}
-
-// GetIsDeletable returns the IsDeletable field value
-func (o *GetInstanceResponse) GetIsDeletable() (ret GetInstanceResponsegetIsDeletableRetType) {
- ret, _ = o.GetIsDeletableOk()
- return ret
-}
-
-// GetIsDeletableOk returns a tuple with the IsDeletable field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetIsDeletableOk() (ret GetInstanceResponsegetIsDeletableRetType, ok bool) {
- return getGetInstanceResponsegetIsDeletableAttributeTypeOk(o.IsDeletable)
-}
-
-// SetIsDeletable sets field value
-func (o *GetInstanceResponse) SetIsDeletable(v GetInstanceResponsegetIsDeletableRetType) {
- setGetInstanceResponsegetIsDeletableAttributeType(&o.IsDeletable, v)
-}
-
-// GetName returns the Name field value
-func (o *GetInstanceResponse) GetName() (ret GetInstanceResponseGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetNameOk() (ret GetInstanceResponseGetNameRetType, ok bool) {
- return getGetInstanceResponseGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *GetInstanceResponse) SetName(v GetInstanceResponseGetNameRetType) {
- setGetInstanceResponseGetNameAttributeType(&o.Name, v)
-}
-
-// GetReplicas returns the Replicas field value
-func (o *GetInstanceResponse) GetReplicas() (ret GetInstanceResponseGetReplicasRetType) {
- ret, _ = o.GetReplicasOk()
- return ret
-}
-
-// GetReplicasOk returns a tuple with the Replicas field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetReplicasOk() (ret GetInstanceResponseGetReplicasRetType, ok bool) {
- return getGetInstanceResponseGetReplicasAttributeTypeOk(o.Replicas)
-}
-
-// SetReplicas sets field value
-func (o *GetInstanceResponse) SetReplicas(v GetInstanceResponseGetReplicasRetType) {
- setGetInstanceResponseGetReplicasAttributeType(&o.Replicas, v)
-}
-
-// GetRetentionDays returns the RetentionDays field value
-func (o *GetInstanceResponse) GetRetentionDays() (ret GetInstanceResponseGetRetentionDaysRetType) {
- ret, _ = o.GetRetentionDaysOk()
- return ret
-}
-
-// GetRetentionDaysOk returns a tuple with the RetentionDays field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetRetentionDaysOk() (ret GetInstanceResponseGetRetentionDaysRetType, ok bool) {
- return getGetInstanceResponseGetRetentionDaysAttributeTypeOk(o.RetentionDays)
-}
-
-// SetRetentionDays sets field value
-func (o *GetInstanceResponse) SetRetentionDays(v GetInstanceResponseGetRetentionDaysRetType) {
- setGetInstanceResponseGetRetentionDaysAttributeType(&o.RetentionDays, v)
-}
-
-// GetStatus returns the Status field value
-func (o *GetInstanceResponse) GetStatus() (ret GetInstanceResponseGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetStatusOk() (ret GetInstanceResponseGetStatusRetType, ok bool) {
- return getGetInstanceResponseGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *GetInstanceResponse) SetStatus(v GetInstanceResponseGetStatusRetType) {
- setGetInstanceResponseGetStatusAttributeType(&o.Status, v)
-}
-
-// GetStorage returns the Storage field value
-func (o *GetInstanceResponse) GetStorage() (ret GetInstanceResponseGetStorageRetType) {
- ret, _ = o.GetStorageOk()
- return ret
-}
-
-// GetStorageOk returns a tuple with the Storage field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetStorageOk() (ret GetInstanceResponseGetStorageRetType, ok bool) {
- return getGetInstanceResponseGetStorageAttributeTypeOk(o.Storage)
-}
-
-// SetStorage sets field value
-func (o *GetInstanceResponse) SetStorage(v GetInstanceResponseGetStorageRetType) {
- setGetInstanceResponseGetStorageAttributeType(&o.Storage, v)
-}
-
-// GetVersion returns the Version field value
-func (o *GetInstanceResponse) GetVersion() (ret GetInstanceResponseGetVersionRetType) {
- ret, _ = o.GetVersionOk()
- return ret
-}
-
-// GetVersionOk returns a tuple with the Version field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetVersionOk() (ret GetInstanceResponseGetVersionRetType, ok bool) {
- return getGetInstanceResponseGetVersionAttributeTypeOk(o.Version)
-}
-
-// SetVersion sets field value
-func (o *GetInstanceResponse) SetVersion(v GetInstanceResponseGetVersionRetType) {
- setGetInstanceResponseGetVersionAttributeType(&o.Version, v)
-}
-
-func (o GetInstanceResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetInstanceResponseGetAclAttributeTypeOk(o.Acl); ok {
- toSerialize["Acl"] = val
- }
- if val, ok := getGetInstanceResponseGetBackupScheduleAttributeTypeOk(o.BackupSchedule); ok {
- toSerialize["BackupSchedule"] = val
- }
- if val, ok := getGetInstanceResponseGetFlavorIdAttributeTypeOk(o.FlavorId); ok {
- toSerialize["FlavorId"] = val
- }
- if val, ok := getGetInstanceResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getGetInstanceResponsegetIsDeletableAttributeTypeOk(o.IsDeletable); ok {
- toSerialize["IsDeletable"] = val
- }
- if val, ok := getGetInstanceResponseGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getGetInstanceResponseGetReplicasAttributeTypeOk(o.Replicas); ok {
- toSerialize["Replicas"] = val
- }
- if val, ok := getGetInstanceResponseGetRetentionDaysAttributeTypeOk(o.RetentionDays); ok {
- toSerialize["RetentionDays"] = val
- }
- if val, ok := getGetInstanceResponseGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- if val, ok := getGetInstanceResponseGetStorageAttributeTypeOk(o.Storage); ok {
- toSerialize["Storage"] = val
- }
- if val, ok := getGetInstanceResponseGetVersionAttributeTypeOk(o.Version); ok {
- toSerialize["Version"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetInstanceResponse struct {
- value *GetInstanceResponse
- isSet bool
-}
-
-func (v NullableGetInstanceResponse) Get() *GetInstanceResponse {
- return v.value
-}
-
-func (v *NullableGetInstanceResponse) Set(val *GetInstanceResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetInstanceResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetInstanceResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetInstanceResponse(val *GetInstanceResponse) *NullableGetInstanceResponse {
- return &NullableGetInstanceResponse{value: val, isSet: true}
-}
-
-func (v NullableGetInstanceResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetInstanceResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_get_instance_response_test.go b/pkg/postgresflexalpha/model_get_instance_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_get_instance_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_get_user_response.go b/pkg/postgresflexalpha/model_get_user_response.go
deleted file mode 100644
index f2ca7808..00000000
--- a/pkg/postgresflexalpha/model_get_user_response.go
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetUserResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetUserResponse{}
-
-/*
- types and functions for connectionString
-*/
-
-// isNotNullableString
-type GetUserResponseGetConnectionStringAttributeType = *string
-
-func getGetUserResponseGetConnectionStringAttributeTypeOk(arg GetUserResponseGetConnectionStringAttributeType) (ret GetUserResponseGetConnectionStringRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetConnectionStringAttributeType(arg *GetUserResponseGetConnectionStringAttributeType, val GetUserResponseGetConnectionStringRetType) {
- *arg = &val
-}
-
-type GetUserResponseGetConnectionStringArgType = string
-type GetUserResponseGetConnectionStringRetType = string
-
-/*
- types and functions for host
-*/
-
-// isNotNullableString
-type GetUserResponseGetHostAttributeType = *string
-
-func getGetUserResponseGetHostAttributeTypeOk(arg GetUserResponseGetHostAttributeType) (ret GetUserResponseGetHostRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetHostAttributeType(arg *GetUserResponseGetHostAttributeType, val GetUserResponseGetHostRetType) {
- *arg = &val
-}
-
-type GetUserResponseGetHostArgType = string
-type GetUserResponseGetHostRetType = string
-
-/*
- types and functions for id
-*/
-
-// isLong
-type GetUserResponseGetIdAttributeType = *int64
-type GetUserResponseGetIdArgType = int64
-type GetUserResponseGetIdRetType = int64
-
-func getGetUserResponseGetIdAttributeTypeOk(arg GetUserResponseGetIdAttributeType) (ret GetUserResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetIdAttributeType(arg *GetUserResponseGetIdAttributeType, val GetUserResponseGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type GetUserResponseGetNameAttributeType = *string
-
-func getGetUserResponseGetNameAttributeTypeOk(arg GetUserResponseGetNameAttributeType) (ret GetUserResponseGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetNameAttributeType(arg *GetUserResponseGetNameAttributeType, val GetUserResponseGetNameRetType) {
- *arg = &val
-}
-
-type GetUserResponseGetNameArgType = string
-type GetUserResponseGetNameRetType = string
-
-/*
- types and functions for port
-*/
-
-// isInteger
-type GetUserResponseGetPortAttributeType = *int64
-type GetUserResponseGetPortArgType = int64
-type GetUserResponseGetPortRetType = int64
-
-func getGetUserResponseGetPortAttributeTypeOk(arg GetUserResponseGetPortAttributeType) (ret GetUserResponseGetPortRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetPortAttributeType(arg *GetUserResponseGetPortAttributeType, val GetUserResponseGetPortRetType) {
- *arg = &val
-}
-
-/*
- types and functions for roles
-*/
-
-// isArray
-type GetUserResponseGetRolesAttributeType = *[]UserRole
-type GetUserResponseGetRolesArgType = []UserRole
-type GetUserResponseGetRolesRetType = []UserRole
-
-func getGetUserResponseGetRolesAttributeTypeOk(arg GetUserResponseGetRolesAttributeType) (ret GetUserResponseGetRolesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetRolesAttributeType(arg *GetUserResponseGetRolesAttributeType, val GetUserResponseGetRolesRetType) {
- *arg = &val
-}
-
-/*
- types and functions for status
-*/
-
-// isNotNullableString
-type GetUserResponseGetStatusAttributeType = *string
-
-func getGetUserResponseGetStatusAttributeTypeOk(arg GetUserResponseGetStatusAttributeType) (ret GetUserResponseGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetStatusAttributeType(arg *GetUserResponseGetStatusAttributeType, val GetUserResponseGetStatusRetType) {
- *arg = &val
-}
-
-type GetUserResponseGetStatusArgType = string
-type GetUserResponseGetStatusRetType = string
-
-// GetUserResponse struct for GetUserResponse
-type GetUserResponse struct {
- // The connection string for the user to the instance.
- // REQUIRED
- ConnectionString GetUserResponseGetConnectionStringAttributeType `json:"connectionString" required:"true"`
- // The host of the instance in which the user belongs to.
- // REQUIRED
- Host GetUserResponseGetHostAttributeType `json:"host" required:"true"`
- // The ID of the user.
- // REQUIRED
- Id GetUserResponseGetIdAttributeType `json:"id" required:"true"`
- // The name of the user.
- // REQUIRED
- Name GetUserResponseGetNameAttributeType `json:"name" required:"true"`
- // The port of the instance in which the user belongs to.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- Port GetUserResponseGetPortAttributeType `json:"port" required:"true"`
- // A list of user roles.
- // REQUIRED
- Roles GetUserResponseGetRolesAttributeType `json:"roles" required:"true"`
- // The current status of the user.
- // REQUIRED
- Status GetUserResponseGetStatusAttributeType `json:"status" required:"true"`
-}
-
-type _GetUserResponse GetUserResponse
-
-// NewGetUserResponse instantiates a new GetUserResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetUserResponse(connectionString GetUserResponseGetConnectionStringArgType, host GetUserResponseGetHostArgType, id GetUserResponseGetIdArgType, name GetUserResponseGetNameArgType, port GetUserResponseGetPortArgType, roles GetUserResponseGetRolesArgType, status GetUserResponseGetStatusArgType) *GetUserResponse {
- this := GetUserResponse{}
- setGetUserResponseGetConnectionStringAttributeType(&this.ConnectionString, connectionString)
- setGetUserResponseGetHostAttributeType(&this.Host, host)
- setGetUserResponseGetIdAttributeType(&this.Id, id)
- setGetUserResponseGetNameAttributeType(&this.Name, name)
- setGetUserResponseGetPortAttributeType(&this.Port, port)
- setGetUserResponseGetRolesAttributeType(&this.Roles, roles)
- setGetUserResponseGetStatusAttributeType(&this.Status, status)
- return &this
-}
-
-// NewGetUserResponseWithDefaults instantiates a new GetUserResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetUserResponseWithDefaults() *GetUserResponse {
- this := GetUserResponse{}
- return &this
-}
-
-// GetConnectionString returns the ConnectionString field value
-func (o *GetUserResponse) GetConnectionString() (ret GetUserResponseGetConnectionStringRetType) {
- ret, _ = o.GetConnectionStringOk()
- return ret
-}
-
-// GetConnectionStringOk returns a tuple with the ConnectionString field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetConnectionStringOk() (ret GetUserResponseGetConnectionStringRetType, ok bool) {
- return getGetUserResponseGetConnectionStringAttributeTypeOk(o.ConnectionString)
-}
-
-// SetConnectionString sets field value
-func (o *GetUserResponse) SetConnectionString(v GetUserResponseGetConnectionStringRetType) {
- setGetUserResponseGetConnectionStringAttributeType(&o.ConnectionString, v)
-}
-
-// GetHost returns the Host field value
-func (o *GetUserResponse) GetHost() (ret GetUserResponseGetHostRetType) {
- ret, _ = o.GetHostOk()
- return ret
-}
-
-// GetHostOk returns a tuple with the Host field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetHostOk() (ret GetUserResponseGetHostRetType, ok bool) {
- return getGetUserResponseGetHostAttributeTypeOk(o.Host)
-}
-
-// SetHost sets field value
-func (o *GetUserResponse) SetHost(v GetUserResponseGetHostRetType) {
- setGetUserResponseGetHostAttributeType(&o.Host, v)
-}
-
-// GetId returns the Id field value
-func (o *GetUserResponse) GetId() (ret GetUserResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetIdOk() (ret GetUserResponseGetIdRetType, ok bool) {
- return getGetUserResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *GetUserResponse) SetId(v GetUserResponseGetIdRetType) {
- setGetUserResponseGetIdAttributeType(&o.Id, v)
-}
-
-// GetName returns the Name field value
-func (o *GetUserResponse) GetName() (ret GetUserResponseGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetNameOk() (ret GetUserResponseGetNameRetType, ok bool) {
- return getGetUserResponseGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *GetUserResponse) SetName(v GetUserResponseGetNameRetType) {
- setGetUserResponseGetNameAttributeType(&o.Name, v)
-}
-
-// GetPort returns the Port field value
-func (o *GetUserResponse) GetPort() (ret GetUserResponseGetPortRetType) {
- ret, _ = o.GetPortOk()
- return ret
-}
-
-// GetPortOk returns a tuple with the Port field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetPortOk() (ret GetUserResponseGetPortRetType, ok bool) {
- return getGetUserResponseGetPortAttributeTypeOk(o.Port)
-}
-
-// SetPort sets field value
-func (o *GetUserResponse) SetPort(v GetUserResponseGetPortRetType) {
- setGetUserResponseGetPortAttributeType(&o.Port, v)
-}
-
-// GetRoles returns the Roles field value
-func (o *GetUserResponse) GetRoles() (ret GetUserResponseGetRolesRetType) {
- ret, _ = o.GetRolesOk()
- return ret
-}
-
-// GetRolesOk returns a tuple with the Roles field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetRolesOk() (ret GetUserResponseGetRolesRetType, ok bool) {
- return getGetUserResponseGetRolesAttributeTypeOk(o.Roles)
-}
-
-// SetRoles sets field value
-func (o *GetUserResponse) SetRoles(v GetUserResponseGetRolesRetType) {
- setGetUserResponseGetRolesAttributeType(&o.Roles, v)
-}
-
-// GetStatus returns the Status field value
-func (o *GetUserResponse) GetStatus() (ret GetUserResponseGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetStatusOk() (ret GetUserResponseGetStatusRetType, ok bool) {
- return getGetUserResponseGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *GetUserResponse) SetStatus(v GetUserResponseGetStatusRetType) {
- setGetUserResponseGetStatusAttributeType(&o.Status, v)
-}
-
-func (o GetUserResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetUserResponseGetConnectionStringAttributeTypeOk(o.ConnectionString); ok {
- toSerialize["ConnectionString"] = val
- }
- if val, ok := getGetUserResponseGetHostAttributeTypeOk(o.Host); ok {
- toSerialize["Host"] = val
- }
- if val, ok := getGetUserResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getGetUserResponseGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getGetUserResponseGetPortAttributeTypeOk(o.Port); ok {
- toSerialize["Port"] = val
- }
- if val, ok := getGetUserResponseGetRolesAttributeTypeOk(o.Roles); ok {
- toSerialize["Roles"] = val
- }
- if val, ok := getGetUserResponseGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetUserResponse struct {
- value *GetUserResponse
- isSet bool
-}
-
-func (v NullableGetUserResponse) Get() *GetUserResponse {
- return v.value
-}
-
-func (v *NullableGetUserResponse) Set(val *GetUserResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetUserResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetUserResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetUserResponse(val *GetUserResponse) *NullableGetUserResponse {
- return &NullableGetUserResponse{value: val, isSet: true}
-}
-
-func (v NullableGetUserResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetUserResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_get_user_response_test.go b/pkg/postgresflexalpha/model_get_user_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_get_user_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_get_versions_response.go b/pkg/postgresflexalpha/model_get_versions_response.go
deleted file mode 100644
index e61f1cc0..00000000
--- a/pkg/postgresflexalpha/model_get_versions_response.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetVersionsResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetVersionsResponse{}
-
-/*
- types and functions for versions
-*/
-
-// isArray
-type GetVersionsResponseGetVersionsAttributeType = *[]Version
-type GetVersionsResponseGetVersionsArgType = []Version
-type GetVersionsResponseGetVersionsRetType = []Version
-
-func getGetVersionsResponseGetVersionsAttributeTypeOk(arg GetVersionsResponseGetVersionsAttributeType) (ret GetVersionsResponseGetVersionsRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetVersionsResponseGetVersionsAttributeType(arg *GetVersionsResponseGetVersionsAttributeType, val GetVersionsResponseGetVersionsRetType) {
- *arg = &val
-}
-
-// GetVersionsResponse struct for GetVersionsResponse
-type GetVersionsResponse struct {
- // A list containing available postgres versions.
- // REQUIRED
- Versions GetVersionsResponseGetVersionsAttributeType `json:"versions" required:"true"`
-}
-
-type _GetVersionsResponse GetVersionsResponse
-
-// NewGetVersionsResponse instantiates a new GetVersionsResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetVersionsResponse(versions GetVersionsResponseGetVersionsArgType) *GetVersionsResponse {
- this := GetVersionsResponse{}
- setGetVersionsResponseGetVersionsAttributeType(&this.Versions, versions)
- return &this
-}
-
-// NewGetVersionsResponseWithDefaults instantiates a new GetVersionsResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetVersionsResponseWithDefaults() *GetVersionsResponse {
- this := GetVersionsResponse{}
- return &this
-}
-
-// GetVersions returns the Versions field value
-func (o *GetVersionsResponse) GetVersions() (ret GetVersionsResponseGetVersionsRetType) {
- ret, _ = o.GetVersionsOk()
- return ret
-}
-
-// GetVersionsOk returns a tuple with the Versions field value
-// and a boolean to check if the value has been set.
-func (o *GetVersionsResponse) GetVersionsOk() (ret GetVersionsResponseGetVersionsRetType, ok bool) {
- return getGetVersionsResponseGetVersionsAttributeTypeOk(o.Versions)
-}
-
-// SetVersions sets field value
-func (o *GetVersionsResponse) SetVersions(v GetVersionsResponseGetVersionsRetType) {
- setGetVersionsResponseGetVersionsAttributeType(&o.Versions, v)
-}
-
-func (o GetVersionsResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetVersionsResponseGetVersionsAttributeTypeOk(o.Versions); ok {
- toSerialize["Versions"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetVersionsResponse struct {
- value *GetVersionsResponse
- isSet bool
-}
-
-func (v NullableGetVersionsResponse) Get() *GetVersionsResponse {
- return v.value
-}
-
-func (v *NullableGetVersionsResponse) Set(val *GetVersionsResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetVersionsResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetVersionsResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetVersionsResponse(val *GetVersionsResponse) *NullableGetVersionsResponse {
- return &NullableGetVersionsResponse{value: val, isSet: true}
-}
-
-func (v NullableGetVersionsResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetVersionsResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_get_versions_response_test.go b/pkg/postgresflexalpha/model_get_versions_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_get_versions_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_instance_encryption.go b/pkg/postgresflexalpha/model_instance_encryption.go
deleted file mode 100644
index 529fcbff..00000000
--- a/pkg/postgresflexalpha/model_instance_encryption.go
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the InstanceEncryption type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &InstanceEncryption{}
-
-/*
- types and functions for kekKeyId
-*/
-
-// isNotNullableString
-type InstanceEncryptionGetKekKeyIdAttributeType = *string
-
-func getInstanceEncryptionGetKekKeyIdAttributeTypeOk(arg InstanceEncryptionGetKekKeyIdAttributeType) (ret InstanceEncryptionGetKekKeyIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceEncryptionGetKekKeyIdAttributeType(arg *InstanceEncryptionGetKekKeyIdAttributeType, val InstanceEncryptionGetKekKeyIdRetType) {
- *arg = &val
-}
-
-type InstanceEncryptionGetKekKeyIdArgType = string
-type InstanceEncryptionGetKekKeyIdRetType = string
-
-/*
- types and functions for kekKeyRingId
-*/
-
-// isNotNullableString
-type InstanceEncryptionGetKekKeyRingIdAttributeType = *string
-
-func getInstanceEncryptionGetKekKeyRingIdAttributeTypeOk(arg InstanceEncryptionGetKekKeyRingIdAttributeType) (ret InstanceEncryptionGetKekKeyRingIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceEncryptionGetKekKeyRingIdAttributeType(arg *InstanceEncryptionGetKekKeyRingIdAttributeType, val InstanceEncryptionGetKekKeyRingIdRetType) {
- *arg = &val
-}
-
-type InstanceEncryptionGetKekKeyRingIdArgType = string
-type InstanceEncryptionGetKekKeyRingIdRetType = string
-
-/*
- types and functions for kekKeyVersion
-*/
-
-// isNotNullableString
-type InstanceEncryptionGetKekKeyVersionAttributeType = *string
-
-func getInstanceEncryptionGetKekKeyVersionAttributeTypeOk(arg InstanceEncryptionGetKekKeyVersionAttributeType) (ret InstanceEncryptionGetKekKeyVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceEncryptionGetKekKeyVersionAttributeType(arg *InstanceEncryptionGetKekKeyVersionAttributeType, val InstanceEncryptionGetKekKeyVersionRetType) {
- *arg = &val
-}
-
-type InstanceEncryptionGetKekKeyVersionArgType = string
-type InstanceEncryptionGetKekKeyVersionRetType = string
-
-/*
- types and functions for serviceAccount
-*/
-
-// isNotNullableString
-type InstanceEncryptionGetServiceAccountAttributeType = *string
-
-func getInstanceEncryptionGetServiceAccountAttributeTypeOk(arg InstanceEncryptionGetServiceAccountAttributeType) (ret InstanceEncryptionGetServiceAccountRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceEncryptionGetServiceAccountAttributeType(arg *InstanceEncryptionGetServiceAccountAttributeType, val InstanceEncryptionGetServiceAccountRetType) {
- *arg = &val
-}
-
-type InstanceEncryptionGetServiceAccountArgType = string
-type InstanceEncryptionGetServiceAccountRetType = string
-
-// InstanceEncryption The configuration for instance's volume and backup storage encryption. ⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.
-type InstanceEncryption struct {
- // The encryption-key key identifier
- // REQUIRED
- KekKeyId InstanceEncryptionGetKekKeyIdAttributeType `json:"kekKeyId" required:"true"`
- // The encryption-key keyring identifier
- // REQUIRED
- KekKeyRingId InstanceEncryptionGetKekKeyRingIdAttributeType `json:"kekKeyRingId" required:"true"`
- // The encryption-key version
- // REQUIRED
- KekKeyVersion InstanceEncryptionGetKekKeyVersionAttributeType `json:"kekKeyVersion" required:"true"`
- // REQUIRED
- ServiceAccount InstanceEncryptionGetServiceAccountAttributeType `json:"serviceAccount" required:"true"`
-}
-
-type _InstanceEncryption InstanceEncryption
-
-// NewInstanceEncryption instantiates a new InstanceEncryption object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewInstanceEncryption(kekKeyId InstanceEncryptionGetKekKeyIdArgType, kekKeyRingId InstanceEncryptionGetKekKeyRingIdArgType, kekKeyVersion InstanceEncryptionGetKekKeyVersionArgType, serviceAccount InstanceEncryptionGetServiceAccountArgType) *InstanceEncryption {
- this := InstanceEncryption{}
- setInstanceEncryptionGetKekKeyIdAttributeType(&this.KekKeyId, kekKeyId)
- setInstanceEncryptionGetKekKeyRingIdAttributeType(&this.KekKeyRingId, kekKeyRingId)
- setInstanceEncryptionGetKekKeyVersionAttributeType(&this.KekKeyVersion, kekKeyVersion)
- setInstanceEncryptionGetServiceAccountAttributeType(&this.ServiceAccount, serviceAccount)
- return &this
-}
-
-// NewInstanceEncryptionWithDefaults instantiates a new InstanceEncryption object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewInstanceEncryptionWithDefaults() *InstanceEncryption {
- this := InstanceEncryption{}
- return &this
-}
-
-// GetKekKeyId returns the KekKeyId field value
-func (o *InstanceEncryption) GetKekKeyId() (ret InstanceEncryptionGetKekKeyIdRetType) {
- ret, _ = o.GetKekKeyIdOk()
- return ret
-}
-
-// GetKekKeyIdOk returns a tuple with the KekKeyId field value
-// and a boolean to check if the value has been set.
-func (o *InstanceEncryption) GetKekKeyIdOk() (ret InstanceEncryptionGetKekKeyIdRetType, ok bool) {
- return getInstanceEncryptionGetKekKeyIdAttributeTypeOk(o.KekKeyId)
-}
-
-// SetKekKeyId sets field value
-func (o *InstanceEncryption) SetKekKeyId(v InstanceEncryptionGetKekKeyIdRetType) {
- setInstanceEncryptionGetKekKeyIdAttributeType(&o.KekKeyId, v)
-}
-
-// GetKekKeyRingId returns the KekKeyRingId field value
-func (o *InstanceEncryption) GetKekKeyRingId() (ret InstanceEncryptionGetKekKeyRingIdRetType) {
- ret, _ = o.GetKekKeyRingIdOk()
- return ret
-}
-
-// GetKekKeyRingIdOk returns a tuple with the KekKeyRingId field value
-// and a boolean to check if the value has been set.
-func (o *InstanceEncryption) GetKekKeyRingIdOk() (ret InstanceEncryptionGetKekKeyRingIdRetType, ok bool) {
- return getInstanceEncryptionGetKekKeyRingIdAttributeTypeOk(o.KekKeyRingId)
-}
-
-// SetKekKeyRingId sets field value
-func (o *InstanceEncryption) SetKekKeyRingId(v InstanceEncryptionGetKekKeyRingIdRetType) {
- setInstanceEncryptionGetKekKeyRingIdAttributeType(&o.KekKeyRingId, v)
-}
-
-// GetKekKeyVersion returns the KekKeyVersion field value
-func (o *InstanceEncryption) GetKekKeyVersion() (ret InstanceEncryptionGetKekKeyVersionRetType) {
- ret, _ = o.GetKekKeyVersionOk()
- return ret
-}
-
-// GetKekKeyVersionOk returns a tuple with the KekKeyVersion field value
-// and a boolean to check if the value has been set.
-func (o *InstanceEncryption) GetKekKeyVersionOk() (ret InstanceEncryptionGetKekKeyVersionRetType, ok bool) {
- return getInstanceEncryptionGetKekKeyVersionAttributeTypeOk(o.KekKeyVersion)
-}
-
-// SetKekKeyVersion sets field value
-func (o *InstanceEncryption) SetKekKeyVersion(v InstanceEncryptionGetKekKeyVersionRetType) {
- setInstanceEncryptionGetKekKeyVersionAttributeType(&o.KekKeyVersion, v)
-}
-
-// GetServiceAccount returns the ServiceAccount field value
-func (o *InstanceEncryption) GetServiceAccount() (ret InstanceEncryptionGetServiceAccountRetType) {
- ret, _ = o.GetServiceAccountOk()
- return ret
-}
-
-// GetServiceAccountOk returns a tuple with the ServiceAccount field value
-// and a boolean to check if the value has been set.
-func (o *InstanceEncryption) GetServiceAccountOk() (ret InstanceEncryptionGetServiceAccountRetType, ok bool) {
- return getInstanceEncryptionGetServiceAccountAttributeTypeOk(o.ServiceAccount)
-}
-
-// SetServiceAccount sets field value
-func (o *InstanceEncryption) SetServiceAccount(v InstanceEncryptionGetServiceAccountRetType) {
- setInstanceEncryptionGetServiceAccountAttributeType(&o.ServiceAccount, v)
-}
-
-func (o InstanceEncryption) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getInstanceEncryptionGetKekKeyIdAttributeTypeOk(o.KekKeyId); ok {
- toSerialize["KekKeyId"] = val
- }
- if val, ok := getInstanceEncryptionGetKekKeyRingIdAttributeTypeOk(o.KekKeyRingId); ok {
- toSerialize["KekKeyRingId"] = val
- }
- if val, ok := getInstanceEncryptionGetKekKeyVersionAttributeTypeOk(o.KekKeyVersion); ok {
- toSerialize["KekKeyVersion"] = val
- }
- if val, ok := getInstanceEncryptionGetServiceAccountAttributeTypeOk(o.ServiceAccount); ok {
- toSerialize["ServiceAccount"] = val
- }
- return toSerialize, nil
-}
-
-type NullableInstanceEncryption struct {
- value *InstanceEncryption
- isSet bool
-}
-
-func (v NullableInstanceEncryption) Get() *InstanceEncryption {
- return v.value
-}
-
-func (v *NullableInstanceEncryption) Set(val *InstanceEncryption) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceEncryption) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceEncryption) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceEncryption(val *InstanceEncryption) *NullableInstanceEncryption {
- return &NullableInstanceEncryption{value: val, isSet: true}
-}
-
-func (v NullableInstanceEncryption) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceEncryption) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_instance_encryption_test.go b/pkg/postgresflexalpha/model_instance_encryption_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_instance_encryption_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_instance_network.go b/pkg/postgresflexalpha/model_instance_network.go
deleted file mode 100644
index c3672861..00000000
--- a/pkg/postgresflexalpha/model_instance_network.go
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// checks if the InstanceNetwork type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &InstanceNetwork{}
-
-/*
- types and functions for accessScope
-*/
-
-// isEnum
-
-// InstanceNetworkAccessScope The access scope of the instance. It defines if the instance is public or airgapped.
-// value type for enums
-type InstanceNetworkAccessScope string
-
-// List of AccessScope
-const (
- INSTANCENETWORKACCESS_SCOPE_PUBLIC InstanceNetworkAccessScope = "PUBLIC"
- INSTANCENETWORKACCESS_SCOPE_SNA InstanceNetworkAccessScope = "SNA"
-)
-
-// All allowed values of InstanceNetwork enum
-var AllowedInstanceNetworkAccessScopeEnumValues = []InstanceNetworkAccessScope{
- "PUBLIC",
- "SNA",
-}
-
-func (v *InstanceNetworkAccessScope) UnmarshalJSON(src []byte) error {
- // use a type alias to prevent infinite recursion during unmarshal,
- // see https://biscuit.ninja/posts/go-avoid-an-infitine-loop-with-custom-json-unmarshallers
- type TmpJson InstanceNetworkAccessScope
- var value TmpJson
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue TmpJson
- if value == zeroValue {
- return nil
- }
- enumTypeValue := InstanceNetworkAccessScope(value)
- for _, existing := range AllowedInstanceNetworkAccessScopeEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid InstanceNetwork", value)
-}
-
-// NewInstanceNetworkAccessScopeFromValue returns a pointer to a valid InstanceNetworkAccessScope
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewInstanceNetworkAccessScopeFromValue(v InstanceNetworkAccessScope) (*InstanceNetworkAccessScope, error) {
- ev := InstanceNetworkAccessScope(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for InstanceNetworkAccessScope: valid values are %v", v, AllowedInstanceNetworkAccessScopeEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v InstanceNetworkAccessScope) IsValid() bool {
- for _, existing := range AllowedInstanceNetworkAccessScopeEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to AccessScopeAccessScope value
-func (v InstanceNetworkAccessScope) Ptr() *InstanceNetworkAccessScope {
- return &v
-}
-
-type NullableInstanceNetworkAccessScope struct {
- value *InstanceNetworkAccessScope
- isSet bool
-}
-
-func (v NullableInstanceNetworkAccessScope) Get() *InstanceNetworkAccessScope {
- return v.value
-}
-
-func (v *NullableInstanceNetworkAccessScope) Set(val *InstanceNetworkAccessScope) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceNetworkAccessScope) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceNetworkAccessScope) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceNetworkAccessScope(val *InstanceNetworkAccessScope) *NullableInstanceNetworkAccessScope {
- return &NullableInstanceNetworkAccessScope{value: val, isSet: true}
-}
-
-func (v NullableInstanceNetworkAccessScope) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceNetworkAccessScope) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type InstanceNetworkGetAccessScopeAttributeType = *InstanceNetworkAccessScope
-type InstanceNetworkGetAccessScopeArgType = InstanceNetworkAccessScope
-type InstanceNetworkGetAccessScopeRetType = InstanceNetworkAccessScope
-
-func getInstanceNetworkGetAccessScopeAttributeTypeOk(arg InstanceNetworkGetAccessScopeAttributeType) (ret InstanceNetworkGetAccessScopeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceNetworkGetAccessScopeAttributeType(arg *InstanceNetworkGetAccessScopeAttributeType, val InstanceNetworkGetAccessScopeRetType) {
- *arg = &val
-}
-
-// InstanceNetwork The network configuration of the instance. ⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.
-type InstanceNetwork struct {
- // The access scope of the instance. It defines if the instance is public or airgapped.
- // REQUIRED
- AccessScope InstanceNetworkGetAccessScopeAttributeType `json:"accessScope" required:"true"`
-}
-
-type _InstanceNetwork InstanceNetwork
-
-// NewInstanceNetwork instantiates a new InstanceNetwork object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewInstanceNetwork(accessScope InstanceNetworkGetAccessScopeArgType) *InstanceNetwork {
- this := InstanceNetwork{}
- setInstanceNetworkGetAccessScopeAttributeType(&this.AccessScope, accessScope)
- return &this
-}
-
-// NewInstanceNetworkWithDefaults instantiates a new InstanceNetwork object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewInstanceNetworkWithDefaults() *InstanceNetwork {
- this := InstanceNetwork{}
- var accessScope InstanceNetworkAccessScope = "PUBLIC"
- this.AccessScope = &accessScope
- return &this
-}
-
-// GetAccessScope returns the AccessScope field value
-func (o *InstanceNetwork) GetAccessScope() (ret InstanceNetworkGetAccessScopeRetType) {
- ret, _ = o.GetAccessScopeOk()
- return ret
-}
-
-// GetAccessScopeOk returns a tuple with the AccessScope field value
-// and a boolean to check if the value has been set.
-func (o *InstanceNetwork) GetAccessScopeOk() (ret InstanceNetworkGetAccessScopeRetType, ok bool) {
- return getInstanceNetworkGetAccessScopeAttributeTypeOk(o.AccessScope)
-}
-
-// SetAccessScope sets field value
-func (o *InstanceNetwork) SetAccessScope(v InstanceNetworkGetAccessScopeRetType) {
- setInstanceNetworkGetAccessScopeAttributeType(&o.AccessScope, v)
-}
-
-func (o InstanceNetwork) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getInstanceNetworkGetAccessScopeAttributeTypeOk(o.AccessScope); ok {
- toSerialize["AccessScope"] = val
- }
- return toSerialize, nil
-}
-
-type NullableInstanceNetwork struct {
- value *InstanceNetwork
- isSet bool
-}
-
-func (v NullableInstanceNetwork) Get() *InstanceNetwork {
- return v.value
-}
-
-func (v *NullableInstanceNetwork) Set(val *InstanceNetwork) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceNetwork) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceNetwork) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceNetwork(val *InstanceNetwork) *NullableInstanceNetwork {
- return &NullableInstanceNetwork{value: val, isSet: true}
-}
-
-func (v NullableInstanceNetwork) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceNetwork) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_instance_network_test.go b/pkg/postgresflexalpha/model_instance_network_test.go
deleted file mode 100644
index cc6e3fa5..00000000
--- a/pkg/postgresflexalpha/model_instance_network_test.go
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "testing"
-)
-
-// isEnum
-
-func TestInstanceNetworkAccessScope_UnmarshalJSON(t *testing.T) {
- type args struct {
- src []byte
- }
- tests := []struct {
- name string
- args args
- wantErr bool
- }{
- {
- name: `success - possible enum value no. 1`,
- args: args{
- src: []byte(`"PUBLIC"`),
- },
- wantErr: false,
- },
- {
- name: `success - possible enum value no. 2`,
- args: args{
- src: []byte(`"SNA"`),
- },
- wantErr: false,
- },
- {
- name: "fail",
- args: args{
- src: []byte("\"FOOBAR\""),
- },
- wantErr: true,
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- v := InstanceNetworkAccessScope("")
- if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr {
- t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
-}
diff --git a/pkg/postgresflexalpha/model_instance_sort.go b/pkg/postgresflexalpha/model_instance_sort.go
deleted file mode 100644
index aefc2891..00000000
--- a/pkg/postgresflexalpha/model_instance_sort.go
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// InstanceSort the model 'InstanceSort'
-type InstanceSort string
-
-// List of instance.sort
-const (
- INSTANCESORT_INDEX_DESC InstanceSort = "index.desc"
- INSTANCESORT_INDEX_ASC InstanceSort = "index.asc"
- INSTANCESORT_ID_DESC InstanceSort = "id.desc"
- INSTANCESORT_ID_ASC InstanceSort = "id.asc"
- INSTANCESORT_IS_DELETABLE_DESC InstanceSort = "is_deletable.desc"
- INSTANCESORT_IS_DELETABLE_ASC InstanceSort = "is_deletable.asc"
- INSTANCESORT_NAME_ASC InstanceSort = "name.asc"
- INSTANCESORT_NAME_DESC InstanceSort = "name.desc"
- INSTANCESORT_STATUS_ASC InstanceSort = "status.asc"
- INSTANCESORT_STATUS_DESC InstanceSort = "status.desc"
-)
-
-// All allowed values of InstanceSort enum
-var AllowedInstanceSortEnumValues = []InstanceSort{
- "index.desc",
- "index.asc",
- "id.desc",
- "id.asc",
- "is_deletable.desc",
- "is_deletable.asc",
- "name.asc",
- "name.desc",
- "status.asc",
- "status.desc",
-}
-
-func (v *InstanceSort) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := InstanceSort(value)
- for _, existing := range AllowedInstanceSortEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid InstanceSort", value)
-}
-
-// NewInstanceSortFromValue returns a pointer to a valid InstanceSort
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewInstanceSortFromValue(v string) (*InstanceSort, error) {
- ev := InstanceSort(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for InstanceSort: valid values are %v", v, AllowedInstanceSortEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v InstanceSort) IsValid() bool {
- for _, existing := range AllowedInstanceSortEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to instance.sort value
-func (v InstanceSort) Ptr() *InstanceSort {
- return &v
-}
-
-type NullableInstanceSort struct {
- value *InstanceSort
- isSet bool
-}
-
-func (v NullableInstanceSort) Get() *InstanceSort {
- return v.value
-}
-
-func (v *NullableInstanceSort) Set(val *InstanceSort) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceSort) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceSort) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceSort(val *InstanceSort) *NullableInstanceSort {
- return &NullableInstanceSort{value: val, isSet: true}
-}
-
-func (v NullableInstanceSort) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceSort) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_instance_sort_test.go b/pkg/postgresflexalpha/model_instance_sort_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_instance_sort_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_instance_storage_range.go b/pkg/postgresflexalpha/model_instance_storage_range.go
deleted file mode 100644
index cf5ee0f7..00000000
--- a/pkg/postgresflexalpha/model_instance_storage_range.go
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the InstanceStorageRange type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &InstanceStorageRange{}
-
-/*
- types and functions for max
-*/
-
-// isInteger
-type InstanceStorageRangeGetMaxAttributeType = *int64
-type InstanceStorageRangeGetMaxArgType = int64
-type InstanceStorageRangeGetMaxRetType = int64
-
-func getInstanceStorageRangeGetMaxAttributeTypeOk(arg InstanceStorageRangeGetMaxAttributeType) (ret InstanceStorageRangeGetMaxRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceStorageRangeGetMaxAttributeType(arg *InstanceStorageRangeGetMaxAttributeType, val InstanceStorageRangeGetMaxRetType) {
- *arg = &val
-}
-
-/*
- types and functions for min
-*/
-
-// isInteger
-type InstanceStorageRangeGetMinAttributeType = *int64
-type InstanceStorageRangeGetMinArgType = int64
-type InstanceStorageRangeGetMinRetType = int64
-
-func getInstanceStorageRangeGetMinAttributeTypeOk(arg InstanceStorageRangeGetMinAttributeType) (ret InstanceStorageRangeGetMinRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceStorageRangeGetMinAttributeType(arg *InstanceStorageRangeGetMinAttributeType, val InstanceStorageRangeGetMinRetType) {
- *arg = &val
-}
-
-// InstanceStorageRange Contains the minimum and maximum storage space.
-type InstanceStorageRange struct {
- // The maximum available amount of storage.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- Max InstanceStorageRangeGetMaxAttributeType `json:"max" required:"true"`
- // The minimum available amount of storage.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- Min InstanceStorageRangeGetMinAttributeType `json:"min" required:"true"`
-}
-
-type _InstanceStorageRange InstanceStorageRange
-
-// NewInstanceStorageRange instantiates a new InstanceStorageRange object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewInstanceStorageRange(max InstanceStorageRangeGetMaxArgType, min InstanceStorageRangeGetMinArgType) *InstanceStorageRange {
- this := InstanceStorageRange{}
- setInstanceStorageRangeGetMaxAttributeType(&this.Max, max)
- setInstanceStorageRangeGetMinAttributeType(&this.Min, min)
- return &this
-}
-
-// NewInstanceStorageRangeWithDefaults instantiates a new InstanceStorageRange object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewInstanceStorageRangeWithDefaults() *InstanceStorageRange {
- this := InstanceStorageRange{}
- return &this
-}
-
-// GetMax returns the Max field value
-func (o *InstanceStorageRange) GetMax() (ret InstanceStorageRangeGetMaxRetType) {
- ret, _ = o.GetMaxOk()
- return ret
-}
-
-// GetMaxOk returns a tuple with the Max field value
-// and a boolean to check if the value has been set.
-func (o *InstanceStorageRange) GetMaxOk() (ret InstanceStorageRangeGetMaxRetType, ok bool) {
- return getInstanceStorageRangeGetMaxAttributeTypeOk(o.Max)
-}
-
-// SetMax sets field value
-func (o *InstanceStorageRange) SetMax(v InstanceStorageRangeGetMaxRetType) {
- setInstanceStorageRangeGetMaxAttributeType(&o.Max, v)
-}
-
-// GetMin returns the Min field value
-func (o *InstanceStorageRange) GetMin() (ret InstanceStorageRangeGetMinRetType) {
- ret, _ = o.GetMinOk()
- return ret
-}
-
-// GetMinOk returns a tuple with the Min field value
-// and a boolean to check if the value has been set.
-func (o *InstanceStorageRange) GetMinOk() (ret InstanceStorageRangeGetMinRetType, ok bool) {
- return getInstanceStorageRangeGetMinAttributeTypeOk(o.Min)
-}
-
-// SetMin sets field value
-func (o *InstanceStorageRange) SetMin(v InstanceStorageRangeGetMinRetType) {
- setInstanceStorageRangeGetMinAttributeType(&o.Min, v)
-}
-
-func (o InstanceStorageRange) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getInstanceStorageRangeGetMaxAttributeTypeOk(o.Max); ok {
- toSerialize["Max"] = val
- }
- if val, ok := getInstanceStorageRangeGetMinAttributeTypeOk(o.Min); ok {
- toSerialize["Min"] = val
- }
- return toSerialize, nil
-}
-
-type NullableInstanceStorageRange struct {
- value *InstanceStorageRange
- isSet bool
-}
-
-func (v NullableInstanceStorageRange) Get() *InstanceStorageRange {
- return v.value
-}
-
-func (v *NullableInstanceStorageRange) Set(val *InstanceStorageRange) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceStorageRange) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceStorageRange) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceStorageRange(val *InstanceStorageRange) *NullableInstanceStorageRange {
- return &NullableInstanceStorageRange{value: val, isSet: true}
-}
-
-func (v NullableInstanceStorageRange) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceStorageRange) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_instance_storage_range_test.go b/pkg/postgresflexalpha/model_instance_storage_range_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_instance_storage_range_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_list_backup.go b/pkg/postgresflexalpha/model_list_backup.go
deleted file mode 100644
index 819fcb08..00000000
--- a/pkg/postgresflexalpha/model_list_backup.go
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListBackup type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListBackup{}
-
-/*
- types and functions for completionTime
-*/
-
-// isNotNullableString
-type ListBackupGetCompletionTimeAttributeType = *string
-
-func getListBackupGetCompletionTimeAttributeTypeOk(arg ListBackupGetCompletionTimeAttributeType) (ret ListBackupGetCompletionTimeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetCompletionTimeAttributeType(arg *ListBackupGetCompletionTimeAttributeType, val ListBackupGetCompletionTimeRetType) {
- *arg = &val
-}
-
-type ListBackupGetCompletionTimeArgType = string
-type ListBackupGetCompletionTimeRetType = string
-
-/*
- types and functions for id
-*/
-
-// isLong
-type ListBackupGetIdAttributeType = *int64
-type ListBackupGetIdArgType = int64
-type ListBackupGetIdRetType = int64
-
-func getListBackupGetIdAttributeTypeOk(arg ListBackupGetIdAttributeType) (ret ListBackupGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetIdAttributeType(arg *ListBackupGetIdAttributeType, val ListBackupGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type ListBackupGetNameAttributeType = *string
-
-func getListBackupGetNameAttributeTypeOk(arg ListBackupGetNameAttributeType) (ret ListBackupGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetNameAttributeType(arg *ListBackupGetNameAttributeType, val ListBackupGetNameRetType) {
- *arg = &val
-}
-
-type ListBackupGetNameArgType = string
-type ListBackupGetNameRetType = string
-
-/*
- types and functions for retainedUntil
-*/
-
-// isNotNullableString
-type ListBackupGetRetainedUntilAttributeType = *string
-
-func getListBackupGetRetainedUntilAttributeTypeOk(arg ListBackupGetRetainedUntilAttributeType) (ret ListBackupGetRetainedUntilRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetRetainedUntilAttributeType(arg *ListBackupGetRetainedUntilAttributeType, val ListBackupGetRetainedUntilRetType) {
- *arg = &val
-}
-
-type ListBackupGetRetainedUntilArgType = string
-type ListBackupGetRetainedUntilRetType = string
-
-/*
- types and functions for size
-*/
-
-// isLong
-type ListBackupGetSizeAttributeType = *int64
-type ListBackupGetSizeArgType = int64
-type ListBackupGetSizeRetType = int64
-
-func getListBackupGetSizeAttributeTypeOk(arg ListBackupGetSizeAttributeType) (ret ListBackupGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetSizeAttributeType(arg *ListBackupGetSizeAttributeType, val ListBackupGetSizeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for type
-*/
-
-// isNotNullableString
-type ListBackupGetTypeAttributeType = *string
-
-func getListBackupGetTypeAttributeTypeOk(arg ListBackupGetTypeAttributeType) (ret ListBackupGetTypeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetTypeAttributeType(arg *ListBackupGetTypeAttributeType, val ListBackupGetTypeRetType) {
- *arg = &val
-}
-
-type ListBackupGetTypeArgType = string
-type ListBackupGetTypeRetType = string
-
-// ListBackup struct for ListBackup
-type ListBackup struct {
- // The time when the backup was completed in RFC3339 format.
- // REQUIRED
- CompletionTime ListBackupGetCompletionTimeAttributeType `json:"completionTime" required:"true"`
- // The ID of the backup.
- // REQUIRED
- Id ListBackupGetIdAttributeType `json:"id" required:"true"`
- // The name of the backup.
- // REQUIRED
- Name ListBackupGetNameAttributeType `json:"name" required:"true"`
- // The time until the backup will be retained.
- // REQUIRED
- RetainedUntil ListBackupGetRetainedUntilAttributeType `json:"retainedUntil" required:"true"`
- // The size of the backup in bytes.
- // REQUIRED
- Size ListBackupGetSizeAttributeType `json:"size" required:"true"`
- // The type of the backup, which can be automated or manual triggered.
- // REQUIRED
- Type ListBackupGetTypeAttributeType `json:"type" required:"true"`
-}
-
-type _ListBackup ListBackup
-
-// NewListBackup instantiates a new ListBackup object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListBackup(completionTime ListBackupGetCompletionTimeArgType, id ListBackupGetIdArgType, name ListBackupGetNameArgType, retainedUntil ListBackupGetRetainedUntilArgType, size ListBackupGetSizeArgType, types ListBackupGetTypeArgType) *ListBackup {
- this := ListBackup{}
- setListBackupGetCompletionTimeAttributeType(&this.CompletionTime, completionTime)
- setListBackupGetIdAttributeType(&this.Id, id)
- setListBackupGetNameAttributeType(&this.Name, name)
- setListBackupGetRetainedUntilAttributeType(&this.RetainedUntil, retainedUntil)
- setListBackupGetSizeAttributeType(&this.Size, size)
- setListBackupGetTypeAttributeType(&this.Type, types)
- return &this
-}
-
-// NewListBackupWithDefaults instantiates a new ListBackup object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListBackupWithDefaults() *ListBackup {
- this := ListBackup{}
- return &this
-}
-
-// GetCompletionTime returns the CompletionTime field value
-func (o *ListBackup) GetCompletionTime() (ret ListBackupGetCompletionTimeRetType) {
- ret, _ = o.GetCompletionTimeOk()
- return ret
-}
-
-// GetCompletionTimeOk returns a tuple with the CompletionTime field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetCompletionTimeOk() (ret ListBackupGetCompletionTimeRetType, ok bool) {
- return getListBackupGetCompletionTimeAttributeTypeOk(o.CompletionTime)
-}
-
-// SetCompletionTime sets field value
-func (o *ListBackup) SetCompletionTime(v ListBackupGetCompletionTimeRetType) {
- setListBackupGetCompletionTimeAttributeType(&o.CompletionTime, v)
-}
-
-// GetId returns the Id field value
-func (o *ListBackup) GetId() (ret ListBackupGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetIdOk() (ret ListBackupGetIdRetType, ok bool) {
- return getListBackupGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *ListBackup) SetId(v ListBackupGetIdRetType) {
- setListBackupGetIdAttributeType(&o.Id, v)
-}
-
-// GetName returns the Name field value
-func (o *ListBackup) GetName() (ret ListBackupGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetNameOk() (ret ListBackupGetNameRetType, ok bool) {
- return getListBackupGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *ListBackup) SetName(v ListBackupGetNameRetType) {
- setListBackupGetNameAttributeType(&o.Name, v)
-}
-
-// GetRetainedUntil returns the RetainedUntil field value
-func (o *ListBackup) GetRetainedUntil() (ret ListBackupGetRetainedUntilRetType) {
- ret, _ = o.GetRetainedUntilOk()
- return ret
-}
-
-// GetRetainedUntilOk returns a tuple with the RetainedUntil field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetRetainedUntilOk() (ret ListBackupGetRetainedUntilRetType, ok bool) {
- return getListBackupGetRetainedUntilAttributeTypeOk(o.RetainedUntil)
-}
-
-// SetRetainedUntil sets field value
-func (o *ListBackup) SetRetainedUntil(v ListBackupGetRetainedUntilRetType) {
- setListBackupGetRetainedUntilAttributeType(&o.RetainedUntil, v)
-}
-
-// GetSize returns the Size field value
-func (o *ListBackup) GetSize() (ret ListBackupGetSizeRetType) {
- ret, _ = o.GetSizeOk()
- return ret
-}
-
-// GetSizeOk returns a tuple with the Size field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetSizeOk() (ret ListBackupGetSizeRetType, ok bool) {
- return getListBackupGetSizeAttributeTypeOk(o.Size)
-}
-
-// SetSize sets field value
-func (o *ListBackup) SetSize(v ListBackupGetSizeRetType) {
- setListBackupGetSizeAttributeType(&o.Size, v)
-}
-
-// GetType returns the Type field value
-func (o *ListBackup) GetType() (ret ListBackupGetTypeRetType) {
- ret, _ = o.GetTypeOk()
- return ret
-}
-
-// GetTypeOk returns a tuple with the Type field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetTypeOk() (ret ListBackupGetTypeRetType, ok bool) {
- return getListBackupGetTypeAttributeTypeOk(o.Type)
-}
-
-// SetType sets field value
-func (o *ListBackup) SetType(v ListBackupGetTypeRetType) {
- setListBackupGetTypeAttributeType(&o.Type, v)
-}
-
-func (o ListBackup) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListBackupGetCompletionTimeAttributeTypeOk(o.CompletionTime); ok {
- toSerialize["CompletionTime"] = val
- }
- if val, ok := getListBackupGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getListBackupGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getListBackupGetRetainedUntilAttributeTypeOk(o.RetainedUntil); ok {
- toSerialize["RetainedUntil"] = val
- }
- if val, ok := getListBackupGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- if val, ok := getListBackupGetTypeAttributeTypeOk(o.Type); ok {
- toSerialize["Type"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListBackup struct {
- value *ListBackup
- isSet bool
-}
-
-func (v NullableListBackup) Get() *ListBackup {
- return v.value
-}
-
-func (v *NullableListBackup) Set(val *ListBackup) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListBackup) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListBackup) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListBackup(val *ListBackup) *NullableListBackup {
- return &NullableListBackup{value: val, isSet: true}
-}
-
-func (v NullableListBackup) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListBackup) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_list_backup_response.go b/pkg/postgresflexalpha/model_list_backup_response.go
deleted file mode 100644
index 7fcd2bce..00000000
--- a/pkg/postgresflexalpha/model_list_backup_response.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListBackupResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListBackupResponse{}
-
-/*
- types and functions for backups
-*/
-
-// isArray
-type ListBackupResponseGetBackupsAttributeType = *[]ListBackup
-type ListBackupResponseGetBackupsArgType = []ListBackup
-type ListBackupResponseGetBackupsRetType = []ListBackup
-
-func getListBackupResponseGetBackupsAttributeTypeOk(arg ListBackupResponseGetBackupsAttributeType) (ret ListBackupResponseGetBackupsRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupResponseGetBackupsAttributeType(arg *ListBackupResponseGetBackupsAttributeType, val ListBackupResponseGetBackupsRetType) {
- *arg = &val
-}
-
-/*
- types and functions for pagination
-*/
-
-// isModel
-type ListBackupResponseGetPaginationAttributeType = *Pagination
-type ListBackupResponseGetPaginationArgType = Pagination
-type ListBackupResponseGetPaginationRetType = Pagination
-
-func getListBackupResponseGetPaginationAttributeTypeOk(arg ListBackupResponseGetPaginationAttributeType) (ret ListBackupResponseGetPaginationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupResponseGetPaginationAttributeType(arg *ListBackupResponseGetPaginationAttributeType, val ListBackupResponseGetPaginationRetType) {
- *arg = &val
-}
-
-// ListBackupResponse struct for ListBackupResponse
-type ListBackupResponse struct {
- // The list containing the information about the backups.
- // REQUIRED
- Backups ListBackupResponseGetBackupsAttributeType `json:"backups" required:"true"`
- // REQUIRED
- Pagination ListBackupResponseGetPaginationAttributeType `json:"pagination" required:"true"`
-}
-
-type _ListBackupResponse ListBackupResponse
-
-// NewListBackupResponse instantiates a new ListBackupResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListBackupResponse(backups ListBackupResponseGetBackupsArgType, pagination ListBackupResponseGetPaginationArgType) *ListBackupResponse {
- this := ListBackupResponse{}
- setListBackupResponseGetBackupsAttributeType(&this.Backups, backups)
- setListBackupResponseGetPaginationAttributeType(&this.Pagination, pagination)
- return &this
-}
-
-// NewListBackupResponseWithDefaults instantiates a new ListBackupResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListBackupResponseWithDefaults() *ListBackupResponse {
- this := ListBackupResponse{}
- return &this
-}
-
-// GetBackups returns the Backups field value
-func (o *ListBackupResponse) GetBackups() (ret ListBackupResponseGetBackupsRetType) {
- ret, _ = o.GetBackupsOk()
- return ret
-}
-
-// GetBackupsOk returns a tuple with the Backups field value
-// and a boolean to check if the value has been set.
-func (o *ListBackupResponse) GetBackupsOk() (ret ListBackupResponseGetBackupsRetType, ok bool) {
- return getListBackupResponseGetBackupsAttributeTypeOk(o.Backups)
-}
-
-// SetBackups sets field value
-func (o *ListBackupResponse) SetBackups(v ListBackupResponseGetBackupsRetType) {
- setListBackupResponseGetBackupsAttributeType(&o.Backups, v)
-}
-
-// GetPagination returns the Pagination field value
-func (o *ListBackupResponse) GetPagination() (ret ListBackupResponseGetPaginationRetType) {
- ret, _ = o.GetPaginationOk()
- return ret
-}
-
-// GetPaginationOk returns a tuple with the Pagination field value
-// and a boolean to check if the value has been set.
-func (o *ListBackupResponse) GetPaginationOk() (ret ListBackupResponseGetPaginationRetType, ok bool) {
- return getListBackupResponseGetPaginationAttributeTypeOk(o.Pagination)
-}
-
-// SetPagination sets field value
-func (o *ListBackupResponse) SetPagination(v ListBackupResponseGetPaginationRetType) {
- setListBackupResponseGetPaginationAttributeType(&o.Pagination, v)
-}
-
-func (o ListBackupResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListBackupResponseGetBackupsAttributeTypeOk(o.Backups); ok {
- toSerialize["Backups"] = val
- }
- if val, ok := getListBackupResponseGetPaginationAttributeTypeOk(o.Pagination); ok {
- toSerialize["Pagination"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListBackupResponse struct {
- value *ListBackupResponse
- isSet bool
-}
-
-func (v NullableListBackupResponse) Get() *ListBackupResponse {
- return v.value
-}
-
-func (v *NullableListBackupResponse) Set(val *ListBackupResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListBackupResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListBackupResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListBackupResponse(val *ListBackupResponse) *NullableListBackupResponse {
- return &NullableListBackupResponse{value: val, isSet: true}
-}
-
-func (v NullableListBackupResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListBackupResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_list_backup_response_test.go b/pkg/postgresflexalpha/model_list_backup_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_list_backup_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_list_backup_test.go b/pkg/postgresflexalpha/model_list_backup_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_list_backup_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_list_database.go b/pkg/postgresflexalpha/model_list_database.go
deleted file mode 100644
index f3410fc9..00000000
--- a/pkg/postgresflexalpha/model_list_database.go
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListDatabase type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListDatabase{}
-
-/*
- types and functions for created
-*/
-
-// isNotNullableString
-type ListDatabaseGetCreatedAttributeType = *string
-
-func getListDatabaseGetCreatedAttributeTypeOk(arg ListDatabaseGetCreatedAttributeType) (ret ListDatabaseGetCreatedRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabaseGetCreatedAttributeType(arg *ListDatabaseGetCreatedAttributeType, val ListDatabaseGetCreatedRetType) {
- *arg = &val
-}
-
-type ListDatabaseGetCreatedArgType = string
-type ListDatabaseGetCreatedRetType = string
-
-/*
- types and functions for id
-*/
-
-// isLong
-type ListDatabaseGetIdAttributeType = *int64
-type ListDatabaseGetIdArgType = int64
-type ListDatabaseGetIdRetType = int64
-
-func getListDatabaseGetIdAttributeTypeOk(arg ListDatabaseGetIdAttributeType) (ret ListDatabaseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabaseGetIdAttributeType(arg *ListDatabaseGetIdAttributeType, val ListDatabaseGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type ListDatabaseGetNameAttributeType = *string
-
-func getListDatabaseGetNameAttributeTypeOk(arg ListDatabaseGetNameAttributeType) (ret ListDatabaseGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabaseGetNameAttributeType(arg *ListDatabaseGetNameAttributeType, val ListDatabaseGetNameRetType) {
- *arg = &val
-}
-
-type ListDatabaseGetNameArgType = string
-type ListDatabaseGetNameRetType = string
-
-/*
- types and functions for owner
-*/
-
-// isNotNullableString
-type ListDatabaseGetOwnerAttributeType = *string
-
-func getListDatabaseGetOwnerAttributeTypeOk(arg ListDatabaseGetOwnerAttributeType) (ret ListDatabaseGetOwnerRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabaseGetOwnerAttributeType(arg *ListDatabaseGetOwnerAttributeType, val ListDatabaseGetOwnerRetType) {
- *arg = &val
-}
-
-type ListDatabaseGetOwnerArgType = string
-type ListDatabaseGetOwnerRetType = string
-
-// ListDatabase struct for ListDatabase
-type ListDatabase struct {
- // The data when the database was created in RFC3339 format.
- // REQUIRED
- Created ListDatabaseGetCreatedAttributeType `json:"created" required:"true"`
- // The id of the database.
- // REQUIRED
- Id ListDatabaseGetIdAttributeType `json:"id" required:"true"`
- // The name of the database.
- // REQUIRED
- Name ListDatabaseGetNameAttributeType `json:"name" required:"true"`
- // The owner of the database.
- // REQUIRED
- Owner ListDatabaseGetOwnerAttributeType `json:"owner" required:"true"`
-}
-
-type _ListDatabase ListDatabase
-
-// NewListDatabase instantiates a new ListDatabase object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListDatabase(created ListDatabaseGetCreatedArgType, id ListDatabaseGetIdArgType, name ListDatabaseGetNameArgType, owner ListDatabaseGetOwnerArgType) *ListDatabase {
- this := ListDatabase{}
- setListDatabaseGetCreatedAttributeType(&this.Created, created)
- setListDatabaseGetIdAttributeType(&this.Id, id)
- setListDatabaseGetNameAttributeType(&this.Name, name)
- setListDatabaseGetOwnerAttributeType(&this.Owner, owner)
- return &this
-}
-
-// NewListDatabaseWithDefaults instantiates a new ListDatabase object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListDatabaseWithDefaults() *ListDatabase {
- this := ListDatabase{}
- return &this
-}
-
-// GetCreated returns the Created field value
-func (o *ListDatabase) GetCreated() (ret ListDatabaseGetCreatedRetType) {
- ret, _ = o.GetCreatedOk()
- return ret
-}
-
-// GetCreatedOk returns a tuple with the Created field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabase) GetCreatedOk() (ret ListDatabaseGetCreatedRetType, ok bool) {
- return getListDatabaseGetCreatedAttributeTypeOk(o.Created)
-}
-
-// SetCreated sets field value
-func (o *ListDatabase) SetCreated(v ListDatabaseGetCreatedRetType) {
- setListDatabaseGetCreatedAttributeType(&o.Created, v)
-}
-
-// GetId returns the Id field value
-func (o *ListDatabase) GetId() (ret ListDatabaseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabase) GetIdOk() (ret ListDatabaseGetIdRetType, ok bool) {
- return getListDatabaseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *ListDatabase) SetId(v ListDatabaseGetIdRetType) {
- setListDatabaseGetIdAttributeType(&o.Id, v)
-}
-
-// GetName returns the Name field value
-func (o *ListDatabase) GetName() (ret ListDatabaseGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabase) GetNameOk() (ret ListDatabaseGetNameRetType, ok bool) {
- return getListDatabaseGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *ListDatabase) SetName(v ListDatabaseGetNameRetType) {
- setListDatabaseGetNameAttributeType(&o.Name, v)
-}
-
-// GetOwner returns the Owner field value
-func (o *ListDatabase) GetOwner() (ret ListDatabaseGetOwnerRetType) {
- ret, _ = o.GetOwnerOk()
- return ret
-}
-
-// GetOwnerOk returns a tuple with the Owner field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabase) GetOwnerOk() (ret ListDatabaseGetOwnerRetType, ok bool) {
- return getListDatabaseGetOwnerAttributeTypeOk(o.Owner)
-}
-
-// SetOwner sets field value
-func (o *ListDatabase) SetOwner(v ListDatabaseGetOwnerRetType) {
- setListDatabaseGetOwnerAttributeType(&o.Owner, v)
-}
-
-func (o ListDatabase) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListDatabaseGetCreatedAttributeTypeOk(o.Created); ok {
- toSerialize["Created"] = val
- }
- if val, ok := getListDatabaseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getListDatabaseGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getListDatabaseGetOwnerAttributeTypeOk(o.Owner); ok {
- toSerialize["Owner"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListDatabase struct {
- value *ListDatabase
- isSet bool
-}
-
-func (v NullableListDatabase) Get() *ListDatabase {
- return v.value
-}
-
-func (v *NullableListDatabase) Set(val *ListDatabase) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListDatabase) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListDatabase) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListDatabase(val *ListDatabase) *NullableListDatabase {
- return &NullableListDatabase{value: val, isSet: true}
-}
-
-func (v NullableListDatabase) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListDatabase) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_list_database_test.go b/pkg/postgresflexalpha/model_list_database_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_list_database_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_list_databases_response.go b/pkg/postgresflexalpha/model_list_databases_response.go
deleted file mode 100644
index 5bdb5e24..00000000
--- a/pkg/postgresflexalpha/model_list_databases_response.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListDatabasesResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListDatabasesResponse{}
-
-/*
- types and functions for databases
-*/
-
-// isArray
-type ListDatabasesResponseGetDatabasesAttributeType = *[]ListDatabase
-type ListDatabasesResponseGetDatabasesArgType = []ListDatabase
-type ListDatabasesResponseGetDatabasesRetType = []ListDatabase
-
-func getListDatabasesResponseGetDatabasesAttributeTypeOk(arg ListDatabasesResponseGetDatabasesAttributeType) (ret ListDatabasesResponseGetDatabasesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabasesResponseGetDatabasesAttributeType(arg *ListDatabasesResponseGetDatabasesAttributeType, val ListDatabasesResponseGetDatabasesRetType) {
- *arg = &val
-}
-
-/*
- types and functions for pagination
-*/
-
-// isModel
-type ListDatabasesResponseGetPaginationAttributeType = *Pagination
-type ListDatabasesResponseGetPaginationArgType = Pagination
-type ListDatabasesResponseGetPaginationRetType = Pagination
-
-func getListDatabasesResponseGetPaginationAttributeTypeOk(arg ListDatabasesResponseGetPaginationAttributeType) (ret ListDatabasesResponseGetPaginationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabasesResponseGetPaginationAttributeType(arg *ListDatabasesResponseGetPaginationAttributeType, val ListDatabasesResponseGetPaginationRetType) {
- *arg = &val
-}
-
-// ListDatabasesResponse struct for ListDatabasesResponse
-type ListDatabasesResponse struct {
- // A list containing all databases for the instance.
- // REQUIRED
- Databases ListDatabasesResponseGetDatabasesAttributeType `json:"databases" required:"true"`
- // REQUIRED
- Pagination ListDatabasesResponseGetPaginationAttributeType `json:"pagination" required:"true"`
-}
-
-type _ListDatabasesResponse ListDatabasesResponse
-
-// NewListDatabasesResponse instantiates a new ListDatabasesResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListDatabasesResponse(databases ListDatabasesResponseGetDatabasesArgType, pagination ListDatabasesResponseGetPaginationArgType) *ListDatabasesResponse {
- this := ListDatabasesResponse{}
- setListDatabasesResponseGetDatabasesAttributeType(&this.Databases, databases)
- setListDatabasesResponseGetPaginationAttributeType(&this.Pagination, pagination)
- return &this
-}
-
-// NewListDatabasesResponseWithDefaults instantiates a new ListDatabasesResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListDatabasesResponseWithDefaults() *ListDatabasesResponse {
- this := ListDatabasesResponse{}
- return &this
-}
-
-// GetDatabases returns the Databases field value
-func (o *ListDatabasesResponse) GetDatabases() (ret ListDatabasesResponseGetDatabasesRetType) {
- ret, _ = o.GetDatabasesOk()
- return ret
-}
-
-// GetDatabasesOk returns a tuple with the Databases field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabasesResponse) GetDatabasesOk() (ret ListDatabasesResponseGetDatabasesRetType, ok bool) {
- return getListDatabasesResponseGetDatabasesAttributeTypeOk(o.Databases)
-}
-
-// SetDatabases sets field value
-func (o *ListDatabasesResponse) SetDatabases(v ListDatabasesResponseGetDatabasesRetType) {
- setListDatabasesResponseGetDatabasesAttributeType(&o.Databases, v)
-}
-
-// GetPagination returns the Pagination field value
-func (o *ListDatabasesResponse) GetPagination() (ret ListDatabasesResponseGetPaginationRetType) {
- ret, _ = o.GetPaginationOk()
- return ret
-}
-
-// GetPaginationOk returns a tuple with the Pagination field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabasesResponse) GetPaginationOk() (ret ListDatabasesResponseGetPaginationRetType, ok bool) {
- return getListDatabasesResponseGetPaginationAttributeTypeOk(o.Pagination)
-}
-
-// SetPagination sets field value
-func (o *ListDatabasesResponse) SetPagination(v ListDatabasesResponseGetPaginationRetType) {
- setListDatabasesResponseGetPaginationAttributeType(&o.Pagination, v)
-}
-
-func (o ListDatabasesResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListDatabasesResponseGetDatabasesAttributeTypeOk(o.Databases); ok {
- toSerialize["Databases"] = val
- }
- if val, ok := getListDatabasesResponseGetPaginationAttributeTypeOk(o.Pagination); ok {
- toSerialize["Pagination"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListDatabasesResponse struct {
- value *ListDatabasesResponse
- isSet bool
-}
-
-func (v NullableListDatabasesResponse) Get() *ListDatabasesResponse {
- return v.value
-}
-
-func (v *NullableListDatabasesResponse) Set(val *ListDatabasesResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListDatabasesResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListDatabasesResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListDatabasesResponse(val *ListDatabasesResponse) *NullableListDatabasesResponse {
- return &NullableListDatabasesResponse{value: val, isSet: true}
-}
-
-func (v NullableListDatabasesResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListDatabasesResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_list_databases_response_test.go b/pkg/postgresflexalpha/model_list_databases_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_list_databases_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_list_flavors.go b/pkg/postgresflexalpha/model_list_flavors.go
deleted file mode 100644
index ad4e8722..00000000
--- a/pkg/postgresflexalpha/model_list_flavors.go
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListFlavors type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListFlavors{}
-
-/*
- types and functions for cpu
-*/
-
-// isLong
-type ListFlavorsGetCpuAttributeType = *int64
-type ListFlavorsGetCpuArgType = int64
-type ListFlavorsGetCpuRetType = int64
-
-func getListFlavorsGetCpuAttributeTypeOk(arg ListFlavorsGetCpuAttributeType) (ret ListFlavorsGetCpuRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetCpuAttributeType(arg *ListFlavorsGetCpuAttributeType, val ListFlavorsGetCpuRetType) {
- *arg = &val
-}
-
-/*
- types and functions for description
-*/
-
-// isNotNullableString
-type ListFlavorsGetDescriptionAttributeType = *string
-
-func getListFlavorsGetDescriptionAttributeTypeOk(arg ListFlavorsGetDescriptionAttributeType) (ret ListFlavorsGetDescriptionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetDescriptionAttributeType(arg *ListFlavorsGetDescriptionAttributeType, val ListFlavorsGetDescriptionRetType) {
- *arg = &val
-}
-
-type ListFlavorsGetDescriptionArgType = string
-type ListFlavorsGetDescriptionRetType = string
-
-/*
- types and functions for id
-*/
-
-// isNotNullableString
-type ListFlavorsGetIdAttributeType = *string
-
-func getListFlavorsGetIdAttributeTypeOk(arg ListFlavorsGetIdAttributeType) (ret ListFlavorsGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetIdAttributeType(arg *ListFlavorsGetIdAttributeType, val ListFlavorsGetIdRetType) {
- *arg = &val
-}
-
-type ListFlavorsGetIdArgType = string
-type ListFlavorsGetIdRetType = string
-
-/*
- types and functions for maxGB
-*/
-
-// isInteger
-type ListFlavorsGetMaxGBAttributeType = *int64
-type ListFlavorsGetMaxGBArgType = int64
-type ListFlavorsGetMaxGBRetType = int64
-
-func getListFlavorsGetMaxGBAttributeTypeOk(arg ListFlavorsGetMaxGBAttributeType) (ret ListFlavorsGetMaxGBRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetMaxGBAttributeType(arg *ListFlavorsGetMaxGBAttributeType, val ListFlavorsGetMaxGBRetType) {
- *arg = &val
-}
-
-/*
- types and functions for memory
-*/
-
-// isLong
-type ListFlavorsGetMemoryAttributeType = *int64
-type ListFlavorsGetMemoryArgType = int64
-type ListFlavorsGetMemoryRetType = int64
-
-func getListFlavorsGetMemoryAttributeTypeOk(arg ListFlavorsGetMemoryAttributeType) (ret ListFlavorsGetMemoryRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetMemoryAttributeType(arg *ListFlavorsGetMemoryAttributeType, val ListFlavorsGetMemoryRetType) {
- *arg = &val
-}
-
-/*
- types and functions for minGB
-*/
-
-// isInteger
-type ListFlavorsGetMinGBAttributeType = *int64
-type ListFlavorsGetMinGBArgType = int64
-type ListFlavorsGetMinGBRetType = int64
-
-func getListFlavorsGetMinGBAttributeTypeOk(arg ListFlavorsGetMinGBAttributeType) (ret ListFlavorsGetMinGBRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetMinGBAttributeType(arg *ListFlavorsGetMinGBAttributeType, val ListFlavorsGetMinGBRetType) {
- *arg = &val
-}
-
-/*
- types and functions for nodeType
-*/
-
-// isNotNullableString
-type ListFlavorsGetNodeTypeAttributeType = *string
-
-func getListFlavorsGetNodeTypeAttributeTypeOk(arg ListFlavorsGetNodeTypeAttributeType) (ret ListFlavorsGetNodeTypeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetNodeTypeAttributeType(arg *ListFlavorsGetNodeTypeAttributeType, val ListFlavorsGetNodeTypeRetType) {
- *arg = &val
-}
-
-type ListFlavorsGetNodeTypeArgType = string
-type ListFlavorsGetNodeTypeRetType = string
-
-/*
- types and functions for storageClasses
-*/
-
-// isArray
-type ListFlavorsGetStorageClassesAttributeType = *[]FlavorStorageClassesStorageClass
-type ListFlavorsGetStorageClassesArgType = []FlavorStorageClassesStorageClass
-type ListFlavorsGetStorageClassesRetType = []FlavorStorageClassesStorageClass
-
-func getListFlavorsGetStorageClassesAttributeTypeOk(arg ListFlavorsGetStorageClassesAttributeType) (ret ListFlavorsGetStorageClassesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetStorageClassesAttributeType(arg *ListFlavorsGetStorageClassesAttributeType, val ListFlavorsGetStorageClassesRetType) {
- *arg = &val
-}
-
-// ListFlavors The flavor of the instance containing the technical features.
-type ListFlavors struct {
- // The cpu count of the instance.
- // REQUIRED
- Cpu ListFlavorsGetCpuAttributeType `json:"cpu" required:"true"`
- // The flavor description.
- // REQUIRED
- Description ListFlavorsGetDescriptionAttributeType `json:"description" required:"true"`
- // The id of the instance flavor.
- // REQUIRED
- Id ListFlavorsGetIdAttributeType `json:"id" required:"true"`
- // maximum storage which can be ordered for the flavor in Gigabyte.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- MaxGB ListFlavorsGetMaxGBAttributeType `json:"maxGB" required:"true"`
- // The memory of the instance in Gibibyte.
- // REQUIRED
- Memory ListFlavorsGetMemoryAttributeType `json:"memory" required:"true"`
- // minimum storage which is required to order in Gigabyte.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- MinGB ListFlavorsGetMinGBAttributeType `json:"minGB" required:"true"`
- // defines the nodeType it can be either single or replica
- // REQUIRED
- NodeType ListFlavorsGetNodeTypeAttributeType `json:"nodeType" required:"true"`
- // maximum storage which can be ordered for the flavor in Gigabyte.
- // REQUIRED
- StorageClasses ListFlavorsGetStorageClassesAttributeType `json:"storageClasses" required:"true"`
-}
-
-type _ListFlavors ListFlavors
-
-// NewListFlavors instantiates a new ListFlavors object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListFlavors(cpu ListFlavorsGetCpuArgType, description ListFlavorsGetDescriptionArgType, id ListFlavorsGetIdArgType, maxGB ListFlavorsGetMaxGBArgType, memory ListFlavorsGetMemoryArgType, minGB ListFlavorsGetMinGBArgType, nodeType ListFlavorsGetNodeTypeArgType, storageClasses ListFlavorsGetStorageClassesArgType) *ListFlavors {
- this := ListFlavors{}
- setListFlavorsGetCpuAttributeType(&this.Cpu, cpu)
- setListFlavorsGetDescriptionAttributeType(&this.Description, description)
- setListFlavorsGetIdAttributeType(&this.Id, id)
- setListFlavorsGetMaxGBAttributeType(&this.MaxGB, maxGB)
- setListFlavorsGetMemoryAttributeType(&this.Memory, memory)
- setListFlavorsGetMinGBAttributeType(&this.MinGB, minGB)
- setListFlavorsGetNodeTypeAttributeType(&this.NodeType, nodeType)
- setListFlavorsGetStorageClassesAttributeType(&this.StorageClasses, storageClasses)
- return &this
-}
-
-// NewListFlavorsWithDefaults instantiates a new ListFlavors object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListFlavorsWithDefaults() *ListFlavors {
- this := ListFlavors{}
- return &this
-}
-
-// GetCpu returns the Cpu field value
-func (o *ListFlavors) GetCpu() (ret ListFlavorsGetCpuRetType) {
- ret, _ = o.GetCpuOk()
- return ret
-}
-
-// GetCpuOk returns a tuple with the Cpu field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetCpuOk() (ret ListFlavorsGetCpuRetType, ok bool) {
- return getListFlavorsGetCpuAttributeTypeOk(o.Cpu)
-}
-
-// SetCpu sets field value
-func (o *ListFlavors) SetCpu(v ListFlavorsGetCpuRetType) {
- setListFlavorsGetCpuAttributeType(&o.Cpu, v)
-}
-
-// GetDescription returns the Description field value
-func (o *ListFlavors) GetDescription() (ret ListFlavorsGetDescriptionRetType) {
- ret, _ = o.GetDescriptionOk()
- return ret
-}
-
-// GetDescriptionOk returns a tuple with the Description field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetDescriptionOk() (ret ListFlavorsGetDescriptionRetType, ok bool) {
- return getListFlavorsGetDescriptionAttributeTypeOk(o.Description)
-}
-
-// SetDescription sets field value
-func (o *ListFlavors) SetDescription(v ListFlavorsGetDescriptionRetType) {
- setListFlavorsGetDescriptionAttributeType(&o.Description, v)
-}
-
-// GetId returns the Id field value
-func (o *ListFlavors) GetId() (ret ListFlavorsGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetIdOk() (ret ListFlavorsGetIdRetType, ok bool) {
- return getListFlavorsGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *ListFlavors) SetId(v ListFlavorsGetIdRetType) {
- setListFlavorsGetIdAttributeType(&o.Id, v)
-}
-
-// GetMaxGB returns the MaxGB field value
-func (o *ListFlavors) GetMaxGB() (ret ListFlavorsGetMaxGBRetType) {
- ret, _ = o.GetMaxGBOk()
- return ret
-}
-
-// GetMaxGBOk returns a tuple with the MaxGB field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetMaxGBOk() (ret ListFlavorsGetMaxGBRetType, ok bool) {
- return getListFlavorsGetMaxGBAttributeTypeOk(o.MaxGB)
-}
-
-// SetMaxGB sets field value
-func (o *ListFlavors) SetMaxGB(v ListFlavorsGetMaxGBRetType) {
- setListFlavorsGetMaxGBAttributeType(&o.MaxGB, v)
-}
-
-// GetMemory returns the Memory field value
-func (o *ListFlavors) GetMemory() (ret ListFlavorsGetMemoryRetType) {
- ret, _ = o.GetMemoryOk()
- return ret
-}
-
-// GetMemoryOk returns a tuple with the Memory field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetMemoryOk() (ret ListFlavorsGetMemoryRetType, ok bool) {
- return getListFlavorsGetMemoryAttributeTypeOk(o.Memory)
-}
-
-// SetMemory sets field value
-func (o *ListFlavors) SetMemory(v ListFlavorsGetMemoryRetType) {
- setListFlavorsGetMemoryAttributeType(&o.Memory, v)
-}
-
-// GetMinGB returns the MinGB field value
-func (o *ListFlavors) GetMinGB() (ret ListFlavorsGetMinGBRetType) {
- ret, _ = o.GetMinGBOk()
- return ret
-}
-
-// GetMinGBOk returns a tuple with the MinGB field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetMinGBOk() (ret ListFlavorsGetMinGBRetType, ok bool) {
- return getListFlavorsGetMinGBAttributeTypeOk(o.MinGB)
-}
-
-// SetMinGB sets field value
-func (o *ListFlavors) SetMinGB(v ListFlavorsGetMinGBRetType) {
- setListFlavorsGetMinGBAttributeType(&o.MinGB, v)
-}
-
-// GetNodeType returns the NodeType field value
-func (o *ListFlavors) GetNodeType() (ret ListFlavorsGetNodeTypeRetType) {
- ret, _ = o.GetNodeTypeOk()
- return ret
-}
-
-// GetNodeTypeOk returns a tuple with the NodeType field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetNodeTypeOk() (ret ListFlavorsGetNodeTypeRetType, ok bool) {
- return getListFlavorsGetNodeTypeAttributeTypeOk(o.NodeType)
-}
-
-// SetNodeType sets field value
-func (o *ListFlavors) SetNodeType(v ListFlavorsGetNodeTypeRetType) {
- setListFlavorsGetNodeTypeAttributeType(&o.NodeType, v)
-}
-
-// GetStorageClasses returns the StorageClasses field value
-func (o *ListFlavors) GetStorageClasses() (ret ListFlavorsGetStorageClassesRetType) {
- ret, _ = o.GetStorageClassesOk()
- return ret
-}
-
-// GetStorageClassesOk returns a tuple with the StorageClasses field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetStorageClassesOk() (ret ListFlavorsGetStorageClassesRetType, ok bool) {
- return getListFlavorsGetStorageClassesAttributeTypeOk(o.StorageClasses)
-}
-
-// SetStorageClasses sets field value
-func (o *ListFlavors) SetStorageClasses(v ListFlavorsGetStorageClassesRetType) {
- setListFlavorsGetStorageClassesAttributeType(&o.StorageClasses, v)
-}
-
-func (o ListFlavors) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListFlavorsGetCpuAttributeTypeOk(o.Cpu); ok {
- toSerialize["Cpu"] = val
- }
- if val, ok := getListFlavorsGetDescriptionAttributeTypeOk(o.Description); ok {
- toSerialize["Description"] = val
- }
- if val, ok := getListFlavorsGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getListFlavorsGetMaxGBAttributeTypeOk(o.MaxGB); ok {
- toSerialize["MaxGB"] = val
- }
- if val, ok := getListFlavorsGetMemoryAttributeTypeOk(o.Memory); ok {
- toSerialize["Memory"] = val
- }
- if val, ok := getListFlavorsGetMinGBAttributeTypeOk(o.MinGB); ok {
- toSerialize["MinGB"] = val
- }
- if val, ok := getListFlavorsGetNodeTypeAttributeTypeOk(o.NodeType); ok {
- toSerialize["NodeType"] = val
- }
- if val, ok := getListFlavorsGetStorageClassesAttributeTypeOk(o.StorageClasses); ok {
- toSerialize["StorageClasses"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListFlavors struct {
- value *ListFlavors
- isSet bool
-}
-
-func (v NullableListFlavors) Get() *ListFlavors {
- return v.value
-}
-
-func (v *NullableListFlavors) Set(val *ListFlavors) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListFlavors) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListFlavors) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListFlavors(val *ListFlavors) *NullableListFlavors {
- return &NullableListFlavors{value: val, isSet: true}
-}
-
-func (v NullableListFlavors) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListFlavors) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_list_flavors_test.go b/pkg/postgresflexalpha/model_list_flavors_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_list_flavors_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_list_instance.go b/pkg/postgresflexalpha/model_list_instance.go
deleted file mode 100644
index 467a71f2..00000000
--- a/pkg/postgresflexalpha/model_list_instance.go
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListInstance type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListInstance{}
-
-/*
- types and functions for id
-*/
-
-// isNotNullableString
-type ListInstanceGetIdAttributeType = *string
-
-func getListInstanceGetIdAttributeTypeOk(arg ListInstanceGetIdAttributeType) (ret ListInstanceGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstanceGetIdAttributeType(arg *ListInstanceGetIdAttributeType, val ListInstanceGetIdRetType) {
- *arg = &val
-}
-
-type ListInstanceGetIdArgType = string
-type ListInstanceGetIdRetType = string
-
-/*
- types and functions for isDeletable
-*/
-
-// isBoolean
-type ListInstancegetIsDeletableAttributeType = *bool
-type ListInstancegetIsDeletableArgType = bool
-type ListInstancegetIsDeletableRetType = bool
-
-func getListInstancegetIsDeletableAttributeTypeOk(arg ListInstancegetIsDeletableAttributeType) (ret ListInstancegetIsDeletableRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstancegetIsDeletableAttributeType(arg *ListInstancegetIsDeletableAttributeType, val ListInstancegetIsDeletableRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type ListInstanceGetNameAttributeType = *string
-
-func getListInstanceGetNameAttributeTypeOk(arg ListInstanceGetNameAttributeType) (ret ListInstanceGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstanceGetNameAttributeType(arg *ListInstanceGetNameAttributeType, val ListInstanceGetNameRetType) {
- *arg = &val
-}
-
-type ListInstanceGetNameArgType = string
-type ListInstanceGetNameRetType = string
-
-/*
- types and functions for status
-*/
-
-// isEnumRef
-type ListInstanceGetStatusAttributeType = *Status
-type ListInstanceGetStatusArgType = Status
-type ListInstanceGetStatusRetType = Status
-
-func getListInstanceGetStatusAttributeTypeOk(arg ListInstanceGetStatusAttributeType) (ret ListInstanceGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstanceGetStatusAttributeType(arg *ListInstanceGetStatusAttributeType, val ListInstanceGetStatusRetType) {
- *arg = &val
-}
-
-// ListInstance struct for ListInstance
-type ListInstance struct {
- // The ID of the instance.
- // REQUIRED
- Id ListInstanceGetIdAttributeType `json:"id" required:"true"`
- // Whether the instance can be deleted or not.
- // REQUIRED
- IsDeletable ListInstancegetIsDeletableAttributeType `json:"isDeletable" required:"true"`
- // The name of the instance.
- // REQUIRED
- Name ListInstanceGetNameAttributeType `json:"name" required:"true"`
- // REQUIRED
- Status ListInstanceGetStatusAttributeType `json:"status" required:"true"`
-}
-
-type _ListInstance ListInstance
-
-// NewListInstance instantiates a new ListInstance object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListInstance(id ListInstanceGetIdArgType, isDeletable ListInstancegetIsDeletableArgType, name ListInstanceGetNameArgType, status ListInstanceGetStatusArgType) *ListInstance {
- this := ListInstance{}
- setListInstanceGetIdAttributeType(&this.Id, id)
- setListInstancegetIsDeletableAttributeType(&this.IsDeletable, isDeletable)
- setListInstanceGetNameAttributeType(&this.Name, name)
- setListInstanceGetStatusAttributeType(&this.Status, status)
- return &this
-}
-
-// NewListInstanceWithDefaults instantiates a new ListInstance object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListInstanceWithDefaults() *ListInstance {
- this := ListInstance{}
- return &this
-}
-
-// GetId returns the Id field value
-func (o *ListInstance) GetId() (ret ListInstanceGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *ListInstance) GetIdOk() (ret ListInstanceGetIdRetType, ok bool) {
- return getListInstanceGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *ListInstance) SetId(v ListInstanceGetIdRetType) {
- setListInstanceGetIdAttributeType(&o.Id, v)
-}
-
-// GetIsDeletable returns the IsDeletable field value
-func (o *ListInstance) GetIsDeletable() (ret ListInstancegetIsDeletableRetType) {
- ret, _ = o.GetIsDeletableOk()
- return ret
-}
-
-// GetIsDeletableOk returns a tuple with the IsDeletable field value
-// and a boolean to check if the value has been set.
-func (o *ListInstance) GetIsDeletableOk() (ret ListInstancegetIsDeletableRetType, ok bool) {
- return getListInstancegetIsDeletableAttributeTypeOk(o.IsDeletable)
-}
-
-// SetIsDeletable sets field value
-func (o *ListInstance) SetIsDeletable(v ListInstancegetIsDeletableRetType) {
- setListInstancegetIsDeletableAttributeType(&o.IsDeletable, v)
-}
-
-// GetName returns the Name field value
-func (o *ListInstance) GetName() (ret ListInstanceGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *ListInstance) GetNameOk() (ret ListInstanceGetNameRetType, ok bool) {
- return getListInstanceGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *ListInstance) SetName(v ListInstanceGetNameRetType) {
- setListInstanceGetNameAttributeType(&o.Name, v)
-}
-
-// GetStatus returns the Status field value
-func (o *ListInstance) GetStatus() (ret ListInstanceGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *ListInstance) GetStatusOk() (ret ListInstanceGetStatusRetType, ok bool) {
- return getListInstanceGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *ListInstance) SetStatus(v ListInstanceGetStatusRetType) {
- setListInstanceGetStatusAttributeType(&o.Status, v)
-}
-
-func (o ListInstance) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListInstanceGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getListInstancegetIsDeletableAttributeTypeOk(o.IsDeletable); ok {
- toSerialize["IsDeletable"] = val
- }
- if val, ok := getListInstanceGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getListInstanceGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListInstance struct {
- value *ListInstance
- isSet bool
-}
-
-func (v NullableListInstance) Get() *ListInstance {
- return v.value
-}
-
-func (v *NullableListInstance) Set(val *ListInstance) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListInstance) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListInstance) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListInstance(val *ListInstance) *NullableListInstance {
- return &NullableListInstance{value: val, isSet: true}
-}
-
-func (v NullableListInstance) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListInstance) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_list_instance_test.go b/pkg/postgresflexalpha/model_list_instance_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_list_instance_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_list_instances_response.go b/pkg/postgresflexalpha/model_list_instances_response.go
deleted file mode 100644
index 61487dba..00000000
--- a/pkg/postgresflexalpha/model_list_instances_response.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListInstancesResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListInstancesResponse{}
-
-/*
- types and functions for instances
-*/
-
-// isArray
-type ListInstancesResponseGetInstancesAttributeType = *[]ListInstance
-type ListInstancesResponseGetInstancesArgType = []ListInstance
-type ListInstancesResponseGetInstancesRetType = []ListInstance
-
-func getListInstancesResponseGetInstancesAttributeTypeOk(arg ListInstancesResponseGetInstancesAttributeType) (ret ListInstancesResponseGetInstancesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstancesResponseGetInstancesAttributeType(arg *ListInstancesResponseGetInstancesAttributeType, val ListInstancesResponseGetInstancesRetType) {
- *arg = &val
-}
-
-/*
- types and functions for pagination
-*/
-
-// isModel
-type ListInstancesResponseGetPaginationAttributeType = *Pagination
-type ListInstancesResponseGetPaginationArgType = Pagination
-type ListInstancesResponseGetPaginationRetType = Pagination
-
-func getListInstancesResponseGetPaginationAttributeTypeOk(arg ListInstancesResponseGetPaginationAttributeType) (ret ListInstancesResponseGetPaginationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstancesResponseGetPaginationAttributeType(arg *ListInstancesResponseGetPaginationAttributeType, val ListInstancesResponseGetPaginationRetType) {
- *arg = &val
-}
-
-// ListInstancesResponse struct for ListInstancesResponse
-type ListInstancesResponse struct {
- // List of owned instances and their current status.
- // REQUIRED
- Instances ListInstancesResponseGetInstancesAttributeType `json:"instances" required:"true"`
- // REQUIRED
- Pagination ListInstancesResponseGetPaginationAttributeType `json:"pagination" required:"true"`
-}
-
-type _ListInstancesResponse ListInstancesResponse
-
-// NewListInstancesResponse instantiates a new ListInstancesResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListInstancesResponse(instances ListInstancesResponseGetInstancesArgType, pagination ListInstancesResponseGetPaginationArgType) *ListInstancesResponse {
- this := ListInstancesResponse{}
- setListInstancesResponseGetInstancesAttributeType(&this.Instances, instances)
- setListInstancesResponseGetPaginationAttributeType(&this.Pagination, pagination)
- return &this
-}
-
-// NewListInstancesResponseWithDefaults instantiates a new ListInstancesResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListInstancesResponseWithDefaults() *ListInstancesResponse {
- this := ListInstancesResponse{}
- return &this
-}
-
-// GetInstances returns the Instances field value
-func (o *ListInstancesResponse) GetInstances() (ret ListInstancesResponseGetInstancesRetType) {
- ret, _ = o.GetInstancesOk()
- return ret
-}
-
-// GetInstancesOk returns a tuple with the Instances field value
-// and a boolean to check if the value has been set.
-func (o *ListInstancesResponse) GetInstancesOk() (ret ListInstancesResponseGetInstancesRetType, ok bool) {
- return getListInstancesResponseGetInstancesAttributeTypeOk(o.Instances)
-}
-
-// SetInstances sets field value
-func (o *ListInstancesResponse) SetInstances(v ListInstancesResponseGetInstancesRetType) {
- setListInstancesResponseGetInstancesAttributeType(&o.Instances, v)
-}
-
-// GetPagination returns the Pagination field value
-func (o *ListInstancesResponse) GetPagination() (ret ListInstancesResponseGetPaginationRetType) {
- ret, _ = o.GetPaginationOk()
- return ret
-}
-
-// GetPaginationOk returns a tuple with the Pagination field value
-// and a boolean to check if the value has been set.
-func (o *ListInstancesResponse) GetPaginationOk() (ret ListInstancesResponseGetPaginationRetType, ok bool) {
- return getListInstancesResponseGetPaginationAttributeTypeOk(o.Pagination)
-}
-
-// SetPagination sets field value
-func (o *ListInstancesResponse) SetPagination(v ListInstancesResponseGetPaginationRetType) {
- setListInstancesResponseGetPaginationAttributeType(&o.Pagination, v)
-}
-
-func (o ListInstancesResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListInstancesResponseGetInstancesAttributeTypeOk(o.Instances); ok {
- toSerialize["Instances"] = val
- }
- if val, ok := getListInstancesResponseGetPaginationAttributeTypeOk(o.Pagination); ok {
- toSerialize["Pagination"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListInstancesResponse struct {
- value *ListInstancesResponse
- isSet bool
-}
-
-func (v NullableListInstancesResponse) Get() *ListInstancesResponse {
- return v.value
-}
-
-func (v *NullableListInstancesResponse) Set(val *ListInstancesResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListInstancesResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListInstancesResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListInstancesResponse(val *ListInstancesResponse) *NullableListInstancesResponse {
- return &NullableListInstancesResponse{value: val, isSet: true}
-}
-
-func (v NullableListInstancesResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListInstancesResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_list_instances_response_test.go b/pkg/postgresflexalpha/model_list_instances_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_list_instances_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_list_roles_response.go b/pkg/postgresflexalpha/model_list_roles_response.go
deleted file mode 100644
index ecf37b74..00000000
--- a/pkg/postgresflexalpha/model_list_roles_response.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListRolesResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListRolesResponse{}
-
-/*
- types and functions for roles
-*/
-
-// isArray
-type ListRolesResponseGetRolesAttributeType = *[]string
-type ListRolesResponseGetRolesArgType = []string
-type ListRolesResponseGetRolesRetType = []string
-
-func getListRolesResponseGetRolesAttributeTypeOk(arg ListRolesResponseGetRolesAttributeType) (ret ListRolesResponseGetRolesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListRolesResponseGetRolesAttributeType(arg *ListRolesResponseGetRolesAttributeType, val ListRolesResponseGetRolesRetType) {
- *arg = &val
-}
-
-// ListRolesResponse struct for ListRolesResponse
-type ListRolesResponse struct {
- // List of all role names available in the instance
- // REQUIRED
- Roles ListRolesResponseGetRolesAttributeType `json:"roles" required:"true"`
-}
-
-type _ListRolesResponse ListRolesResponse
-
-// NewListRolesResponse instantiates a new ListRolesResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListRolesResponse(roles ListRolesResponseGetRolesArgType) *ListRolesResponse {
- this := ListRolesResponse{}
- setListRolesResponseGetRolesAttributeType(&this.Roles, roles)
- return &this
-}
-
-// NewListRolesResponseWithDefaults instantiates a new ListRolesResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListRolesResponseWithDefaults() *ListRolesResponse {
- this := ListRolesResponse{}
- return &this
-}
-
-// GetRoles returns the Roles field value
-func (o *ListRolesResponse) GetRoles() (ret ListRolesResponseGetRolesRetType) {
- ret, _ = o.GetRolesOk()
- return ret
-}
-
-// GetRolesOk returns a tuple with the Roles field value
-// and a boolean to check if the value has been set.
-func (o *ListRolesResponse) GetRolesOk() (ret ListRolesResponseGetRolesRetType, ok bool) {
- return getListRolesResponseGetRolesAttributeTypeOk(o.Roles)
-}
-
-// SetRoles sets field value
-func (o *ListRolesResponse) SetRoles(v ListRolesResponseGetRolesRetType) {
- setListRolesResponseGetRolesAttributeType(&o.Roles, v)
-}
-
-func (o ListRolesResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListRolesResponseGetRolesAttributeTypeOk(o.Roles); ok {
- toSerialize["Roles"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListRolesResponse struct {
- value *ListRolesResponse
- isSet bool
-}
-
-func (v NullableListRolesResponse) Get() *ListRolesResponse {
- return v.value
-}
-
-func (v *NullableListRolesResponse) Set(val *ListRolesResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListRolesResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListRolesResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListRolesResponse(val *ListRolesResponse) *NullableListRolesResponse {
- return &NullableListRolesResponse{value: val, isSet: true}
-}
-
-func (v NullableListRolesResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListRolesResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_list_roles_response_test.go b/pkg/postgresflexalpha/model_list_roles_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_list_roles_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_list_user.go b/pkg/postgresflexalpha/model_list_user.go
deleted file mode 100644
index ecd3f590..00000000
--- a/pkg/postgresflexalpha/model_list_user.go
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListUser type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListUser{}
-
-/*
- types and functions for id
-*/
-
-// isLong
-type ListUserGetIdAttributeType = *int64
-type ListUserGetIdArgType = int64
-type ListUserGetIdRetType = int64
-
-func getListUserGetIdAttributeTypeOk(arg ListUserGetIdAttributeType) (ret ListUserGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListUserGetIdAttributeType(arg *ListUserGetIdAttributeType, val ListUserGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type ListUserGetNameAttributeType = *string
-
-func getListUserGetNameAttributeTypeOk(arg ListUserGetNameAttributeType) (ret ListUserGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListUserGetNameAttributeType(arg *ListUserGetNameAttributeType, val ListUserGetNameRetType) {
- *arg = &val
-}
-
-type ListUserGetNameArgType = string
-type ListUserGetNameRetType = string
-
-/*
- types and functions for status
-*/
-
-// isNotNullableString
-type ListUserGetStatusAttributeType = *string
-
-func getListUserGetStatusAttributeTypeOk(arg ListUserGetStatusAttributeType) (ret ListUserGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListUserGetStatusAttributeType(arg *ListUserGetStatusAttributeType, val ListUserGetStatusRetType) {
- *arg = &val
-}
-
-type ListUserGetStatusArgType = string
-type ListUserGetStatusRetType = string
-
-// ListUser struct for ListUser
-type ListUser struct {
- // The ID of the user.
- // REQUIRED
- Id ListUserGetIdAttributeType `json:"id" required:"true"`
- // The name of the user.
- // REQUIRED
- Name ListUserGetNameAttributeType `json:"name" required:"true"`
- // The current status of the user.
- // REQUIRED
- Status ListUserGetStatusAttributeType `json:"status" required:"true"`
-}
-
-type _ListUser ListUser
-
-// NewListUser instantiates a new ListUser object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListUser(id ListUserGetIdArgType, name ListUserGetNameArgType, status ListUserGetStatusArgType) *ListUser {
- this := ListUser{}
- setListUserGetIdAttributeType(&this.Id, id)
- setListUserGetNameAttributeType(&this.Name, name)
- setListUserGetStatusAttributeType(&this.Status, status)
- return &this
-}
-
-// NewListUserWithDefaults instantiates a new ListUser object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListUserWithDefaults() *ListUser {
- this := ListUser{}
- return &this
-}
-
-// GetId returns the Id field value
-func (o *ListUser) GetId() (ret ListUserGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *ListUser) GetIdOk() (ret ListUserGetIdRetType, ok bool) {
- return getListUserGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *ListUser) SetId(v ListUserGetIdRetType) {
- setListUserGetIdAttributeType(&o.Id, v)
-}
-
-// GetName returns the Name field value
-func (o *ListUser) GetName() (ret ListUserGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *ListUser) GetNameOk() (ret ListUserGetNameRetType, ok bool) {
- return getListUserGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *ListUser) SetName(v ListUserGetNameRetType) {
- setListUserGetNameAttributeType(&o.Name, v)
-}
-
-// GetStatus returns the Status field value
-func (o *ListUser) GetStatus() (ret ListUserGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *ListUser) GetStatusOk() (ret ListUserGetStatusRetType, ok bool) {
- return getListUserGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *ListUser) SetStatus(v ListUserGetStatusRetType) {
- setListUserGetStatusAttributeType(&o.Status, v)
-}
-
-func (o ListUser) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListUserGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getListUserGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getListUserGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListUser struct {
- value *ListUser
- isSet bool
-}
-
-func (v NullableListUser) Get() *ListUser {
- return v.value
-}
-
-func (v *NullableListUser) Set(val *ListUser) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListUser) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListUser) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListUser(val *ListUser) *NullableListUser {
- return &NullableListUser{value: val, isSet: true}
-}
-
-func (v NullableListUser) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListUser) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_list_user_response.go b/pkg/postgresflexalpha/model_list_user_response.go
deleted file mode 100644
index 0f9376af..00000000
--- a/pkg/postgresflexalpha/model_list_user_response.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListUserResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListUserResponse{}
-
-/*
- types and functions for pagination
-*/
-
-// isModel
-type ListUserResponseGetPaginationAttributeType = *Pagination
-type ListUserResponseGetPaginationArgType = Pagination
-type ListUserResponseGetPaginationRetType = Pagination
-
-func getListUserResponseGetPaginationAttributeTypeOk(arg ListUserResponseGetPaginationAttributeType) (ret ListUserResponseGetPaginationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListUserResponseGetPaginationAttributeType(arg *ListUserResponseGetPaginationAttributeType, val ListUserResponseGetPaginationRetType) {
- *arg = &val
-}
-
-/*
- types and functions for users
-*/
-
-// isArray
-type ListUserResponseGetUsersAttributeType = *[]ListUser
-type ListUserResponseGetUsersArgType = []ListUser
-type ListUserResponseGetUsersRetType = []ListUser
-
-func getListUserResponseGetUsersAttributeTypeOk(arg ListUserResponseGetUsersAttributeType) (ret ListUserResponseGetUsersRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListUserResponseGetUsersAttributeType(arg *ListUserResponseGetUsersAttributeType, val ListUserResponseGetUsersRetType) {
- *arg = &val
-}
-
-// ListUserResponse struct for ListUserResponse
-type ListUserResponse struct {
- // REQUIRED
- Pagination ListUserResponseGetPaginationAttributeType `json:"pagination" required:"true"`
- // List of all users inside an instance
- // REQUIRED
- Users ListUserResponseGetUsersAttributeType `json:"users" required:"true"`
-}
-
-type _ListUserResponse ListUserResponse
-
-// NewListUserResponse instantiates a new ListUserResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListUserResponse(pagination ListUserResponseGetPaginationArgType, users ListUserResponseGetUsersArgType) *ListUserResponse {
- this := ListUserResponse{}
- setListUserResponseGetPaginationAttributeType(&this.Pagination, pagination)
- setListUserResponseGetUsersAttributeType(&this.Users, users)
- return &this
-}
-
-// NewListUserResponseWithDefaults instantiates a new ListUserResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListUserResponseWithDefaults() *ListUserResponse {
- this := ListUserResponse{}
- return &this
-}
-
-// GetPagination returns the Pagination field value
-func (o *ListUserResponse) GetPagination() (ret ListUserResponseGetPaginationRetType) {
- ret, _ = o.GetPaginationOk()
- return ret
-}
-
-// GetPaginationOk returns a tuple with the Pagination field value
-// and a boolean to check if the value has been set.
-func (o *ListUserResponse) GetPaginationOk() (ret ListUserResponseGetPaginationRetType, ok bool) {
- return getListUserResponseGetPaginationAttributeTypeOk(o.Pagination)
-}
-
-// SetPagination sets field value
-func (o *ListUserResponse) SetPagination(v ListUserResponseGetPaginationRetType) {
- setListUserResponseGetPaginationAttributeType(&o.Pagination, v)
-}
-
-// GetUsers returns the Users field value
-func (o *ListUserResponse) GetUsers() (ret ListUserResponseGetUsersRetType) {
- ret, _ = o.GetUsersOk()
- return ret
-}
-
-// GetUsersOk returns a tuple with the Users field value
-// and a boolean to check if the value has been set.
-func (o *ListUserResponse) GetUsersOk() (ret ListUserResponseGetUsersRetType, ok bool) {
- return getListUserResponseGetUsersAttributeTypeOk(o.Users)
-}
-
-// SetUsers sets field value
-func (o *ListUserResponse) SetUsers(v ListUserResponseGetUsersRetType) {
- setListUserResponseGetUsersAttributeType(&o.Users, v)
-}
-
-func (o ListUserResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListUserResponseGetPaginationAttributeTypeOk(o.Pagination); ok {
- toSerialize["Pagination"] = val
- }
- if val, ok := getListUserResponseGetUsersAttributeTypeOk(o.Users); ok {
- toSerialize["Users"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListUserResponse struct {
- value *ListUserResponse
- isSet bool
-}
-
-func (v NullableListUserResponse) Get() *ListUserResponse {
- return v.value
-}
-
-func (v *NullableListUserResponse) Set(val *ListUserResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListUserResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListUserResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListUserResponse(val *ListUserResponse) *NullableListUserResponse {
- return &NullableListUserResponse{value: val, isSet: true}
-}
-
-func (v NullableListUserResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListUserResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_list_user_response_test.go b/pkg/postgresflexalpha/model_list_user_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_list_user_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_list_user_test.go b/pkg/postgresflexalpha/model_list_user_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_list_user_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_pagination.go b/pkg/postgresflexalpha/model_pagination.go
deleted file mode 100644
index e35a1957..00000000
--- a/pkg/postgresflexalpha/model_pagination.go
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the Pagination type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &Pagination{}
-
-/*
- types and functions for page
-*/
-
-// isLong
-type PaginationGetPageAttributeType = *int64
-type PaginationGetPageArgType = int64
-type PaginationGetPageRetType = int64
-
-func getPaginationGetPageAttributeTypeOk(arg PaginationGetPageAttributeType) (ret PaginationGetPageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPaginationGetPageAttributeType(arg *PaginationGetPageAttributeType, val PaginationGetPageRetType) {
- *arg = &val
-}
-
-/*
- types and functions for size
-*/
-
-// isLong
-type PaginationGetSizeAttributeType = *int64
-type PaginationGetSizeArgType = int64
-type PaginationGetSizeRetType = int64
-
-func getPaginationGetSizeAttributeTypeOk(arg PaginationGetSizeAttributeType) (ret PaginationGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPaginationGetSizeAttributeType(arg *PaginationGetSizeAttributeType, val PaginationGetSizeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for sort
-*/
-
-// isNotNullableString
-type PaginationGetSortAttributeType = *string
-
-func getPaginationGetSortAttributeTypeOk(arg PaginationGetSortAttributeType) (ret PaginationGetSortRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPaginationGetSortAttributeType(arg *PaginationGetSortAttributeType, val PaginationGetSortRetType) {
- *arg = &val
-}
-
-type PaginationGetSortArgType = string
-type PaginationGetSortRetType = string
-
-/*
- types and functions for totalPages
-*/
-
-// isLong
-type PaginationGetTotalPagesAttributeType = *int64
-type PaginationGetTotalPagesArgType = int64
-type PaginationGetTotalPagesRetType = int64
-
-func getPaginationGetTotalPagesAttributeTypeOk(arg PaginationGetTotalPagesAttributeType) (ret PaginationGetTotalPagesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPaginationGetTotalPagesAttributeType(arg *PaginationGetTotalPagesAttributeType, val PaginationGetTotalPagesRetType) {
- *arg = &val
-}
-
-/*
- types and functions for totalRows
-*/
-
-// isLong
-type PaginationGetTotalRowsAttributeType = *int64
-type PaginationGetTotalRowsArgType = int64
-type PaginationGetTotalRowsRetType = int64
-
-func getPaginationGetTotalRowsAttributeTypeOk(arg PaginationGetTotalRowsAttributeType) (ret PaginationGetTotalRowsRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPaginationGetTotalRowsAttributeType(arg *PaginationGetTotalRowsAttributeType, val PaginationGetTotalRowsRetType) {
- *arg = &val
-}
-
-// Pagination struct for Pagination
-type Pagination struct {
- // REQUIRED
- Page PaginationGetPageAttributeType `json:"page" required:"true"`
- // REQUIRED
- Size PaginationGetSizeAttributeType `json:"size" required:"true"`
- // REQUIRED
- Sort PaginationGetSortAttributeType `json:"sort" required:"true"`
- // REQUIRED
- TotalPages PaginationGetTotalPagesAttributeType `json:"totalPages" required:"true"`
- // REQUIRED
- TotalRows PaginationGetTotalRowsAttributeType `json:"totalRows" required:"true"`
-}
-
-type _Pagination Pagination
-
-// NewPagination instantiates a new Pagination object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewPagination(page PaginationGetPageArgType, size PaginationGetSizeArgType, sort PaginationGetSortArgType, totalPages PaginationGetTotalPagesArgType, totalRows PaginationGetTotalRowsArgType) *Pagination {
- this := Pagination{}
- setPaginationGetPageAttributeType(&this.Page, page)
- setPaginationGetSizeAttributeType(&this.Size, size)
- setPaginationGetSortAttributeType(&this.Sort, sort)
- setPaginationGetTotalPagesAttributeType(&this.TotalPages, totalPages)
- setPaginationGetTotalRowsAttributeType(&this.TotalRows, totalRows)
- return &this
-}
-
-// NewPaginationWithDefaults instantiates a new Pagination object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewPaginationWithDefaults() *Pagination {
- this := Pagination{}
- return &this
-}
-
-// GetPage returns the Page field value
-func (o *Pagination) GetPage() (ret PaginationGetPageRetType) {
- ret, _ = o.GetPageOk()
- return ret
-}
-
-// GetPageOk returns a tuple with the Page field value
-// and a boolean to check if the value has been set.
-func (o *Pagination) GetPageOk() (ret PaginationGetPageRetType, ok bool) {
- return getPaginationGetPageAttributeTypeOk(o.Page)
-}
-
-// SetPage sets field value
-func (o *Pagination) SetPage(v PaginationGetPageRetType) {
- setPaginationGetPageAttributeType(&o.Page, v)
-}
-
-// GetSize returns the Size field value
-func (o *Pagination) GetSize() (ret PaginationGetSizeRetType) {
- ret, _ = o.GetSizeOk()
- return ret
-}
-
-// GetSizeOk returns a tuple with the Size field value
-// and a boolean to check if the value has been set.
-func (o *Pagination) GetSizeOk() (ret PaginationGetSizeRetType, ok bool) {
- return getPaginationGetSizeAttributeTypeOk(o.Size)
-}
-
-// SetSize sets field value
-func (o *Pagination) SetSize(v PaginationGetSizeRetType) {
- setPaginationGetSizeAttributeType(&o.Size, v)
-}
-
-// GetSort returns the Sort field value
-func (o *Pagination) GetSort() (ret PaginationGetSortRetType) {
- ret, _ = o.GetSortOk()
- return ret
-}
-
-// GetSortOk returns a tuple with the Sort field value
-// and a boolean to check if the value has been set.
-func (o *Pagination) GetSortOk() (ret PaginationGetSortRetType, ok bool) {
- return getPaginationGetSortAttributeTypeOk(o.Sort)
-}
-
-// SetSort sets field value
-func (o *Pagination) SetSort(v PaginationGetSortRetType) {
- setPaginationGetSortAttributeType(&o.Sort, v)
-}
-
-// GetTotalPages returns the TotalPages field value
-func (o *Pagination) GetTotalPages() (ret PaginationGetTotalPagesRetType) {
- ret, _ = o.GetTotalPagesOk()
- return ret
-}
-
-// GetTotalPagesOk returns a tuple with the TotalPages field value
-// and a boolean to check if the value has been set.
-func (o *Pagination) GetTotalPagesOk() (ret PaginationGetTotalPagesRetType, ok bool) {
- return getPaginationGetTotalPagesAttributeTypeOk(o.TotalPages)
-}
-
-// SetTotalPages sets field value
-func (o *Pagination) SetTotalPages(v PaginationGetTotalPagesRetType) {
- setPaginationGetTotalPagesAttributeType(&o.TotalPages, v)
-}
-
-// GetTotalRows returns the TotalRows field value
-func (o *Pagination) GetTotalRows() (ret PaginationGetTotalRowsRetType) {
- ret, _ = o.GetTotalRowsOk()
- return ret
-}
-
-// GetTotalRowsOk returns a tuple with the TotalRows field value
-// and a boolean to check if the value has been set.
-func (o *Pagination) GetTotalRowsOk() (ret PaginationGetTotalRowsRetType, ok bool) {
- return getPaginationGetTotalRowsAttributeTypeOk(o.TotalRows)
-}
-
-// SetTotalRows sets field value
-func (o *Pagination) SetTotalRows(v PaginationGetTotalRowsRetType) {
- setPaginationGetTotalRowsAttributeType(&o.TotalRows, v)
-}
-
-func (o Pagination) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getPaginationGetPageAttributeTypeOk(o.Page); ok {
- toSerialize["Page"] = val
- }
- if val, ok := getPaginationGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- if val, ok := getPaginationGetSortAttributeTypeOk(o.Sort); ok {
- toSerialize["Sort"] = val
- }
- if val, ok := getPaginationGetTotalPagesAttributeTypeOk(o.TotalPages); ok {
- toSerialize["TotalPages"] = val
- }
- if val, ok := getPaginationGetTotalRowsAttributeTypeOk(o.TotalRows); ok {
- toSerialize["TotalRows"] = val
- }
- return toSerialize, nil
-}
-
-type NullablePagination struct {
- value *Pagination
- isSet bool
-}
-
-func (v NullablePagination) Get() *Pagination {
- return v.value
-}
-
-func (v *NullablePagination) Set(val *Pagination) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullablePagination) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullablePagination) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullablePagination(val *Pagination) *NullablePagination {
- return &NullablePagination{value: val, isSet: true}
-}
-
-func (v NullablePagination) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullablePagination) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_pagination_test.go b/pkg/postgresflexalpha/model_pagination_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_pagination_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_point_in_time_recovery_request_payload.go b/pkg/postgresflexalpha/model_point_in_time_recovery_request_payload.go
deleted file mode 100644
index e64a82c6..00000000
--- a/pkg/postgresflexalpha/model_point_in_time_recovery_request_payload.go
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "time"
-)
-
-// checks if the PointInTimeRecoveryRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &PointInTimeRecoveryRequestPayload{}
-
-/*
- types and functions for performanceClass
-*/
-
-// isNotNullableString
-type PointInTimeRecoveryRequestPayloadGetPerformanceClassAttributeType = *string
-
-func getPointInTimeRecoveryRequestPayloadGetPerformanceClassAttributeTypeOk(arg PointInTimeRecoveryRequestPayloadGetPerformanceClassAttributeType) (ret PointInTimeRecoveryRequestPayloadGetPerformanceClassRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPointInTimeRecoveryRequestPayloadGetPerformanceClassAttributeType(arg *PointInTimeRecoveryRequestPayloadGetPerformanceClassAttributeType, val PointInTimeRecoveryRequestPayloadGetPerformanceClassRetType) {
- *arg = &val
-}
-
-type PointInTimeRecoveryRequestPayloadGetPerformanceClassArgType = string
-type PointInTimeRecoveryRequestPayloadGetPerformanceClassRetType = string
-
-/*
- types and functions for recoveryTime
-*/
-
-// isDateTime
-type PointInTimeRecoveryRequestPayloadGetRecoveryTimeAttributeType = *time.Time
-type PointInTimeRecoveryRequestPayloadGetRecoveryTimeArgType = time.Time
-type PointInTimeRecoveryRequestPayloadGetRecoveryTimeRetType = time.Time
-
-func getPointInTimeRecoveryRequestPayloadGetRecoveryTimeAttributeTypeOk(arg PointInTimeRecoveryRequestPayloadGetRecoveryTimeAttributeType) (ret PointInTimeRecoveryRequestPayloadGetRecoveryTimeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPointInTimeRecoveryRequestPayloadGetRecoveryTimeAttributeType(arg *PointInTimeRecoveryRequestPayloadGetRecoveryTimeAttributeType, val PointInTimeRecoveryRequestPayloadGetRecoveryTimeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for size
-*/
-
-// isLong
-type PointInTimeRecoveryRequestPayloadGetSizeAttributeType = *int64
-type PointInTimeRecoveryRequestPayloadGetSizeArgType = int64
-type PointInTimeRecoveryRequestPayloadGetSizeRetType = int64
-
-func getPointInTimeRecoveryRequestPayloadGetSizeAttributeTypeOk(arg PointInTimeRecoveryRequestPayloadGetSizeAttributeType) (ret PointInTimeRecoveryRequestPayloadGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPointInTimeRecoveryRequestPayloadGetSizeAttributeType(arg *PointInTimeRecoveryRequestPayloadGetSizeAttributeType, val PointInTimeRecoveryRequestPayloadGetSizeRetType) {
- *arg = &val
-}
-
-// PointInTimeRecoveryRequestPayload struct for PointInTimeRecoveryRequestPayload
-type PointInTimeRecoveryRequestPayload struct {
- // The storage class for the storage.
- // REQUIRED
- PerformanceClass PointInTimeRecoveryRequestPayloadGetPerformanceClassAttributeType `json:"performanceClass" required:"true"`
- // the time for the point in time recovery it will be calculated between first backup and last backup
- // REQUIRED
- RecoveryTime PointInTimeRecoveryRequestPayloadGetRecoveryTimeAttributeType `json:"recoveryTime" required:"true"`
- // The storage size in Gigabytes.
- // REQUIRED
- Size PointInTimeRecoveryRequestPayloadGetSizeAttributeType `json:"size" required:"true"`
-}
-
-type _PointInTimeRecoveryRequestPayload PointInTimeRecoveryRequestPayload
-
-// NewPointInTimeRecoveryRequestPayload instantiates a new PointInTimeRecoveryRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewPointInTimeRecoveryRequestPayload(performanceClass PointInTimeRecoveryRequestPayloadGetPerformanceClassArgType, recoveryTime PointInTimeRecoveryRequestPayloadGetRecoveryTimeArgType, size PointInTimeRecoveryRequestPayloadGetSizeArgType) *PointInTimeRecoveryRequestPayload {
- this := PointInTimeRecoveryRequestPayload{}
- setPointInTimeRecoveryRequestPayloadGetPerformanceClassAttributeType(&this.PerformanceClass, performanceClass)
- setPointInTimeRecoveryRequestPayloadGetRecoveryTimeAttributeType(&this.RecoveryTime, recoveryTime)
- setPointInTimeRecoveryRequestPayloadGetSizeAttributeType(&this.Size, size)
- return &this
-}
-
-// NewPointInTimeRecoveryRequestPayloadWithDefaults instantiates a new PointInTimeRecoveryRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewPointInTimeRecoveryRequestPayloadWithDefaults() *PointInTimeRecoveryRequestPayload {
- this := PointInTimeRecoveryRequestPayload{}
- return &this
-}
-
-// GetPerformanceClass returns the PerformanceClass field value
-func (o *PointInTimeRecoveryRequestPayload) GetPerformanceClass() (ret PointInTimeRecoveryRequestPayloadGetPerformanceClassRetType) {
- ret, _ = o.GetPerformanceClassOk()
- return ret
-}
-
-// GetPerformanceClassOk returns a tuple with the PerformanceClass field value
-// and a boolean to check if the value has been set.
-func (o *PointInTimeRecoveryRequestPayload) GetPerformanceClassOk() (ret PointInTimeRecoveryRequestPayloadGetPerformanceClassRetType, ok bool) {
- return getPointInTimeRecoveryRequestPayloadGetPerformanceClassAttributeTypeOk(o.PerformanceClass)
-}
-
-// SetPerformanceClass sets field value
-func (o *PointInTimeRecoveryRequestPayload) SetPerformanceClass(v PointInTimeRecoveryRequestPayloadGetPerformanceClassRetType) {
- setPointInTimeRecoveryRequestPayloadGetPerformanceClassAttributeType(&o.PerformanceClass, v)
-}
-
-// GetRecoveryTime returns the RecoveryTime field value
-func (o *PointInTimeRecoveryRequestPayload) GetRecoveryTime() (ret PointInTimeRecoveryRequestPayloadGetRecoveryTimeRetType) {
- ret, _ = o.GetRecoveryTimeOk()
- return ret
-}
-
-// GetRecoveryTimeOk returns a tuple with the RecoveryTime field value
-// and a boolean to check if the value has been set.
-func (o *PointInTimeRecoveryRequestPayload) GetRecoveryTimeOk() (ret PointInTimeRecoveryRequestPayloadGetRecoveryTimeRetType, ok bool) {
- return getPointInTimeRecoveryRequestPayloadGetRecoveryTimeAttributeTypeOk(o.RecoveryTime)
-}
-
-// SetRecoveryTime sets field value
-func (o *PointInTimeRecoveryRequestPayload) SetRecoveryTime(v PointInTimeRecoveryRequestPayloadGetRecoveryTimeRetType) {
- setPointInTimeRecoveryRequestPayloadGetRecoveryTimeAttributeType(&o.RecoveryTime, v)
-}
-
-// GetSize returns the Size field value
-func (o *PointInTimeRecoveryRequestPayload) GetSize() (ret PointInTimeRecoveryRequestPayloadGetSizeRetType) {
- ret, _ = o.GetSizeOk()
- return ret
-}
-
-// GetSizeOk returns a tuple with the Size field value
-// and a boolean to check if the value has been set.
-func (o *PointInTimeRecoveryRequestPayload) GetSizeOk() (ret PointInTimeRecoveryRequestPayloadGetSizeRetType, ok bool) {
- return getPointInTimeRecoveryRequestPayloadGetSizeAttributeTypeOk(o.Size)
-}
-
-// SetSize sets field value
-func (o *PointInTimeRecoveryRequestPayload) SetSize(v PointInTimeRecoveryRequestPayloadGetSizeRetType) {
- setPointInTimeRecoveryRequestPayloadGetSizeAttributeType(&o.Size, v)
-}
-
-func (o PointInTimeRecoveryRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getPointInTimeRecoveryRequestPayloadGetPerformanceClassAttributeTypeOk(o.PerformanceClass); ok {
- toSerialize["PerformanceClass"] = val
- }
- if val, ok := getPointInTimeRecoveryRequestPayloadGetRecoveryTimeAttributeTypeOk(o.RecoveryTime); ok {
- toSerialize["RecoveryTime"] = val
- }
- if val, ok := getPointInTimeRecoveryRequestPayloadGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- return toSerialize, nil
-}
-
-type NullablePointInTimeRecoveryRequestPayload struct {
- value *PointInTimeRecoveryRequestPayload
- isSet bool
-}
-
-func (v NullablePointInTimeRecoveryRequestPayload) Get() *PointInTimeRecoveryRequestPayload {
- return v.value
-}
-
-func (v *NullablePointInTimeRecoveryRequestPayload) Set(val *PointInTimeRecoveryRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullablePointInTimeRecoveryRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullablePointInTimeRecoveryRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullablePointInTimeRecoveryRequestPayload(val *PointInTimeRecoveryRequestPayload) *NullablePointInTimeRecoveryRequestPayload {
- return &NullablePointInTimeRecoveryRequestPayload{value: val, isSet: true}
-}
-
-func (v NullablePointInTimeRecoveryRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullablePointInTimeRecoveryRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_point_in_time_recovery_request_payload_test.go b/pkg/postgresflexalpha/model_point_in_time_recovery_request_payload_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_point_in_time_recovery_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_protect_instance_request_payload.go b/pkg/postgresflexalpha/model_protect_instance_request_payload.go
deleted file mode 100644
index d80513dd..00000000
--- a/pkg/postgresflexalpha/model_protect_instance_request_payload.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ProtectInstanceRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ProtectInstanceRequestPayload{}
-
-/*
- types and functions for isDeletable
-*/
-
-// isBoolean
-type ProtectInstanceRequestPayloadgetIsDeletableAttributeType = *bool
-type ProtectInstanceRequestPayloadgetIsDeletableArgType = bool
-type ProtectInstanceRequestPayloadgetIsDeletableRetType = bool
-
-func getProtectInstanceRequestPayloadgetIsDeletableAttributeTypeOk(arg ProtectInstanceRequestPayloadgetIsDeletableAttributeType) (ret ProtectInstanceRequestPayloadgetIsDeletableRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setProtectInstanceRequestPayloadgetIsDeletableAttributeType(arg *ProtectInstanceRequestPayloadgetIsDeletableAttributeType, val ProtectInstanceRequestPayloadgetIsDeletableRetType) {
- *arg = &val
-}
-
-// ProtectInstanceRequestPayload struct for ProtectInstanceRequestPayload
-type ProtectInstanceRequestPayload struct {
- // Protect instance from deletion.
- // REQUIRED
- IsDeletable ProtectInstanceRequestPayloadgetIsDeletableAttributeType `json:"isDeletable" required:"true"`
-}
-
-type _ProtectInstanceRequestPayload ProtectInstanceRequestPayload
-
-// NewProtectInstanceRequestPayload instantiates a new ProtectInstanceRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewProtectInstanceRequestPayload(isDeletable ProtectInstanceRequestPayloadgetIsDeletableArgType) *ProtectInstanceRequestPayload {
- this := ProtectInstanceRequestPayload{}
- setProtectInstanceRequestPayloadgetIsDeletableAttributeType(&this.IsDeletable, isDeletable)
- return &this
-}
-
-// NewProtectInstanceRequestPayloadWithDefaults instantiates a new ProtectInstanceRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewProtectInstanceRequestPayloadWithDefaults() *ProtectInstanceRequestPayload {
- this := ProtectInstanceRequestPayload{}
- return &this
-}
-
-// GetIsDeletable returns the IsDeletable field value
-func (o *ProtectInstanceRequestPayload) GetIsDeletable() (ret ProtectInstanceRequestPayloadgetIsDeletableRetType) {
- ret, _ = o.GetIsDeletableOk()
- return ret
-}
-
-// GetIsDeletableOk returns a tuple with the IsDeletable field value
-// and a boolean to check if the value has been set.
-func (o *ProtectInstanceRequestPayload) GetIsDeletableOk() (ret ProtectInstanceRequestPayloadgetIsDeletableRetType, ok bool) {
- return getProtectInstanceRequestPayloadgetIsDeletableAttributeTypeOk(o.IsDeletable)
-}
-
-// SetIsDeletable sets field value
-func (o *ProtectInstanceRequestPayload) SetIsDeletable(v ProtectInstanceRequestPayloadgetIsDeletableRetType) {
- setProtectInstanceRequestPayloadgetIsDeletableAttributeType(&o.IsDeletable, v)
-}
-
-func (o ProtectInstanceRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getProtectInstanceRequestPayloadgetIsDeletableAttributeTypeOk(o.IsDeletable); ok {
- toSerialize["IsDeletable"] = val
- }
- return toSerialize, nil
-}
-
-type NullableProtectInstanceRequestPayload struct {
- value *ProtectInstanceRequestPayload
- isSet bool
-}
-
-func (v NullableProtectInstanceRequestPayload) Get() *ProtectInstanceRequestPayload {
- return v.value
-}
-
-func (v *NullableProtectInstanceRequestPayload) Set(val *ProtectInstanceRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableProtectInstanceRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableProtectInstanceRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableProtectInstanceRequestPayload(val *ProtectInstanceRequestPayload) *NullableProtectInstanceRequestPayload {
- return &NullableProtectInstanceRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableProtectInstanceRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableProtectInstanceRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_protect_instance_request_payload_test.go b/pkg/postgresflexalpha/model_protect_instance_request_payload_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_protect_instance_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_protect_instance_response.go b/pkg/postgresflexalpha/model_protect_instance_response.go
deleted file mode 100644
index b0c8c8d5..00000000
--- a/pkg/postgresflexalpha/model_protect_instance_response.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ProtectInstanceResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ProtectInstanceResponse{}
-
-/*
- types and functions for isDeletable
-*/
-
-// isBoolean
-type ProtectInstanceResponsegetIsDeletableAttributeType = *bool
-type ProtectInstanceResponsegetIsDeletableArgType = bool
-type ProtectInstanceResponsegetIsDeletableRetType = bool
-
-func getProtectInstanceResponsegetIsDeletableAttributeTypeOk(arg ProtectInstanceResponsegetIsDeletableAttributeType) (ret ProtectInstanceResponsegetIsDeletableRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setProtectInstanceResponsegetIsDeletableAttributeType(arg *ProtectInstanceResponsegetIsDeletableAttributeType, val ProtectInstanceResponsegetIsDeletableRetType) {
- *arg = &val
-}
-
-// ProtectInstanceResponse struct for ProtectInstanceResponse
-type ProtectInstanceResponse struct {
- // Protect instance from deletion.
- // REQUIRED
- IsDeletable ProtectInstanceResponsegetIsDeletableAttributeType `json:"isDeletable" required:"true"`
-}
-
-type _ProtectInstanceResponse ProtectInstanceResponse
-
-// NewProtectInstanceResponse instantiates a new ProtectInstanceResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewProtectInstanceResponse(isDeletable ProtectInstanceResponsegetIsDeletableArgType) *ProtectInstanceResponse {
- this := ProtectInstanceResponse{}
- setProtectInstanceResponsegetIsDeletableAttributeType(&this.IsDeletable, isDeletable)
- return &this
-}
-
-// NewProtectInstanceResponseWithDefaults instantiates a new ProtectInstanceResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewProtectInstanceResponseWithDefaults() *ProtectInstanceResponse {
- this := ProtectInstanceResponse{}
- return &this
-}
-
-// GetIsDeletable returns the IsDeletable field value
-func (o *ProtectInstanceResponse) GetIsDeletable() (ret ProtectInstanceResponsegetIsDeletableRetType) {
- ret, _ = o.GetIsDeletableOk()
- return ret
-}
-
-// GetIsDeletableOk returns a tuple with the IsDeletable field value
-// and a boolean to check if the value has been set.
-func (o *ProtectInstanceResponse) GetIsDeletableOk() (ret ProtectInstanceResponsegetIsDeletableRetType, ok bool) {
- return getProtectInstanceResponsegetIsDeletableAttributeTypeOk(o.IsDeletable)
-}
-
-// SetIsDeletable sets field value
-func (o *ProtectInstanceResponse) SetIsDeletable(v ProtectInstanceResponsegetIsDeletableRetType) {
- setProtectInstanceResponsegetIsDeletableAttributeType(&o.IsDeletable, v)
-}
-
-func (o ProtectInstanceResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getProtectInstanceResponsegetIsDeletableAttributeTypeOk(o.IsDeletable); ok {
- toSerialize["IsDeletable"] = val
- }
- return toSerialize, nil
-}
-
-type NullableProtectInstanceResponse struct {
- value *ProtectInstanceResponse
- isSet bool
-}
-
-func (v NullableProtectInstanceResponse) Get() *ProtectInstanceResponse {
- return v.value
-}
-
-func (v *NullableProtectInstanceResponse) Set(val *ProtectInstanceResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableProtectInstanceResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableProtectInstanceResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableProtectInstanceResponse(val *ProtectInstanceResponse) *NullableProtectInstanceResponse {
- return &NullableProtectInstanceResponse{value: val, isSet: true}
-}
-
-func (v NullableProtectInstanceResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableProtectInstanceResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_protect_instance_response_test.go b/pkg/postgresflexalpha/model_protect_instance_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_protect_instance_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_recovery_response.go b/pkg/postgresflexalpha/model_recovery_response.go
deleted file mode 100644
index cb591040..00000000
--- a/pkg/postgresflexalpha/model_recovery_response.go
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the RecoveryResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &RecoveryResponse{}
-
-/*
- types and functions for id
-*/
-
-// isNotNullableString
-type RecoveryResponseGetIdAttributeType = *string
-
-func getRecoveryResponseGetIdAttributeTypeOk(arg RecoveryResponseGetIdAttributeType) (ret RecoveryResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setRecoveryResponseGetIdAttributeType(arg *RecoveryResponseGetIdAttributeType, val RecoveryResponseGetIdRetType) {
- *arg = &val
-}
-
-type RecoveryResponseGetIdArgType = string
-type RecoveryResponseGetIdRetType = string
-
-// RecoveryResponse struct for RecoveryResponse
-type RecoveryResponse struct {
- // The ID of the instance.
- // REQUIRED
- Id RecoveryResponseGetIdAttributeType `json:"id" required:"true"`
-}
-
-type _RecoveryResponse RecoveryResponse
-
-// NewRecoveryResponse instantiates a new RecoveryResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewRecoveryResponse(id RecoveryResponseGetIdArgType) *RecoveryResponse {
- this := RecoveryResponse{}
- setRecoveryResponseGetIdAttributeType(&this.Id, id)
- return &this
-}
-
-// NewRecoveryResponseWithDefaults instantiates a new RecoveryResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewRecoveryResponseWithDefaults() *RecoveryResponse {
- this := RecoveryResponse{}
- return &this
-}
-
-// GetId returns the Id field value
-func (o *RecoveryResponse) GetId() (ret RecoveryResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *RecoveryResponse) GetIdOk() (ret RecoveryResponseGetIdRetType, ok bool) {
- return getRecoveryResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *RecoveryResponse) SetId(v RecoveryResponseGetIdRetType) {
- setRecoveryResponseGetIdAttributeType(&o.Id, v)
-}
-
-func (o RecoveryResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getRecoveryResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- return toSerialize, nil
-}
-
-type NullableRecoveryResponse struct {
- value *RecoveryResponse
- isSet bool
-}
-
-func (v NullableRecoveryResponse) Get() *RecoveryResponse {
- return v.value
-}
-
-func (v *NullableRecoveryResponse) Set(val *RecoveryResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableRecoveryResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableRecoveryResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableRecoveryResponse(val *RecoveryResponse) *NullableRecoveryResponse {
- return &NullableRecoveryResponse{value: val, isSet: true}
-}
-
-func (v NullableRecoveryResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableRecoveryResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_recovery_response_test.go b/pkg/postgresflexalpha/model_recovery_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_recovery_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_replicas.go b/pkg/postgresflexalpha/model_replicas.go
deleted file mode 100644
index ec7e9ebe..00000000
--- a/pkg/postgresflexalpha/model_replicas.go
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// Replicas How many replicas the instance should have.
-type Replicas int32
-
-// List of replicas
-const (
- REPLICAS__1 Replicas = 1
- REPLICAS__3 Replicas = 3
-)
-
-// All allowed values of Replicas enum
-var AllowedReplicasEnumValues = []Replicas{
- 1,
- 3,
-}
-
-func (v *Replicas) UnmarshalJSON(src []byte) error {
- var value int32
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue int32
- if value == zeroValue {
- return nil
- }
- enumTypeValue := Replicas(value)
- for _, existing := range AllowedReplicasEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid Replicas", value)
-}
-
-// NewReplicasFromValue returns a pointer to a valid Replicas
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewReplicasFromValue(v int32) (*Replicas, error) {
- ev := Replicas(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for Replicas: valid values are %v", v, AllowedReplicasEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v Replicas) IsValid() bool {
- for _, existing := range AllowedReplicasEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to replicas value
-func (v Replicas) Ptr() *Replicas {
- return &v
-}
-
-type NullableReplicas struct {
- value *Replicas
- isSet bool
-}
-
-func (v NullableReplicas) Get() *Replicas {
- return v.value
-}
-
-func (v *NullableReplicas) Set(val *Replicas) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableReplicas) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableReplicas) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableReplicas(val *Replicas) *NullableReplicas {
- return &NullableReplicas{value: val, isSet: true}
-}
-
-func (v NullableReplicas) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableReplicas) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_replicas_opt.go b/pkg/postgresflexalpha/model_replicas_opt.go
deleted file mode 100644
index 4761c334..00000000
--- a/pkg/postgresflexalpha/model_replicas_opt.go
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// ReplicasOpt How many replicas the instance should have.
-type ReplicasOpt int32
-
-// List of replicas.opt
-const (
- REPLICASOPT__1 ReplicasOpt = 1
- REPLICASOPT__3 ReplicasOpt = 3
-)
-
-// All allowed values of ReplicasOpt enum
-var AllowedReplicasOptEnumValues = []ReplicasOpt{
- 1,
- 3,
-}
-
-func (v *ReplicasOpt) UnmarshalJSON(src []byte) error {
- var value int32
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue int32
- if value == zeroValue {
- return nil
- }
- enumTypeValue := ReplicasOpt(value)
- for _, existing := range AllowedReplicasOptEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid ReplicasOpt", value)
-}
-
-// NewReplicasOptFromValue returns a pointer to a valid ReplicasOpt
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewReplicasOptFromValue(v int32) (*ReplicasOpt, error) {
- ev := ReplicasOpt(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for ReplicasOpt: valid values are %v", v, AllowedReplicasOptEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v ReplicasOpt) IsValid() bool {
- for _, existing := range AllowedReplicasOptEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to replicas.opt value
-func (v ReplicasOpt) Ptr() *ReplicasOpt {
- return &v
-}
-
-type NullableReplicasOpt struct {
- value *ReplicasOpt
- isSet bool
-}
-
-func (v NullableReplicasOpt) Get() *ReplicasOpt {
- return v.value
-}
-
-func (v *NullableReplicasOpt) Set(val *ReplicasOpt) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableReplicasOpt) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableReplicasOpt) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableReplicasOpt(val *ReplicasOpt) *NullableReplicasOpt {
- return &NullableReplicasOpt{value: val, isSet: true}
-}
-
-func (v NullableReplicasOpt) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableReplicasOpt) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_replicas_opt_test.go b/pkg/postgresflexalpha/model_replicas_opt_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_replicas_opt_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_replicas_test.go b/pkg/postgresflexalpha/model_replicas_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_replicas_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_reset_user_response.go b/pkg/postgresflexalpha/model_reset_user_response.go
deleted file mode 100644
index bcff75e4..00000000
--- a/pkg/postgresflexalpha/model_reset_user_response.go
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ResetUserResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ResetUserResponse{}
-
-/*
- types and functions for connectionString
-*/
-
-// isNotNullableString
-type ResetUserResponseGetConnectionStringAttributeType = *string
-
-func getResetUserResponseGetConnectionStringAttributeTypeOk(arg ResetUserResponseGetConnectionStringAttributeType) (ret ResetUserResponseGetConnectionStringRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setResetUserResponseGetConnectionStringAttributeType(arg *ResetUserResponseGetConnectionStringAttributeType, val ResetUserResponseGetConnectionStringRetType) {
- *arg = &val
-}
-
-type ResetUserResponseGetConnectionStringArgType = string
-type ResetUserResponseGetConnectionStringRetType = string
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type ResetUserResponseGetNameAttributeType = *string
-
-func getResetUserResponseGetNameAttributeTypeOk(arg ResetUserResponseGetNameAttributeType) (ret ResetUserResponseGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setResetUserResponseGetNameAttributeType(arg *ResetUserResponseGetNameAttributeType, val ResetUserResponseGetNameRetType) {
- *arg = &val
-}
-
-type ResetUserResponseGetNameArgType = string
-type ResetUserResponseGetNameRetType = string
-
-/*
- types and functions for password
-*/
-
-// isNotNullableString
-type ResetUserResponseGetPasswordAttributeType = *string
-
-func getResetUserResponseGetPasswordAttributeTypeOk(arg ResetUserResponseGetPasswordAttributeType) (ret ResetUserResponseGetPasswordRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setResetUserResponseGetPasswordAttributeType(arg *ResetUserResponseGetPasswordAttributeType, val ResetUserResponseGetPasswordRetType) {
- *arg = &val
-}
-
-type ResetUserResponseGetPasswordArgType = string
-type ResetUserResponseGetPasswordRetType = string
-
-/*
- types and functions for status
-*/
-
-// isNotNullableString
-type ResetUserResponseGetStatusAttributeType = *string
-
-func getResetUserResponseGetStatusAttributeTypeOk(arg ResetUserResponseGetStatusAttributeType) (ret ResetUserResponseGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setResetUserResponseGetStatusAttributeType(arg *ResetUserResponseGetStatusAttributeType, val ResetUserResponseGetStatusRetType) {
- *arg = &val
-}
-
-type ResetUserResponseGetStatusArgType = string
-type ResetUserResponseGetStatusRetType = string
-
-// ResetUserResponse struct for ResetUserResponse
-type ResetUserResponse struct {
- // The connection string for the user to the instance.
- // REQUIRED
- ConnectionString ResetUserResponseGetConnectionStringAttributeType `json:"connectionString" required:"true"`
- // The name of the user.
- // REQUIRED
- Name ResetUserResponseGetNameAttributeType `json:"name" required:"true"`
- // The password for the user.
- // REQUIRED
- Password ResetUserResponseGetPasswordAttributeType `json:"password" required:"true"`
- // The current status of the user.
- // REQUIRED
- Status ResetUserResponseGetStatusAttributeType `json:"status" required:"true"`
-}
-
-type _ResetUserResponse ResetUserResponse
-
-// NewResetUserResponse instantiates a new ResetUserResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewResetUserResponse(connectionString ResetUserResponseGetConnectionStringArgType, name ResetUserResponseGetNameArgType, password ResetUserResponseGetPasswordArgType, status ResetUserResponseGetStatusArgType) *ResetUserResponse {
- this := ResetUserResponse{}
- setResetUserResponseGetConnectionStringAttributeType(&this.ConnectionString, connectionString)
- setResetUserResponseGetNameAttributeType(&this.Name, name)
- setResetUserResponseGetPasswordAttributeType(&this.Password, password)
- setResetUserResponseGetStatusAttributeType(&this.Status, status)
- return &this
-}
-
-// NewResetUserResponseWithDefaults instantiates a new ResetUserResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewResetUserResponseWithDefaults() *ResetUserResponse {
- this := ResetUserResponse{}
- return &this
-}
-
-// GetConnectionString returns the ConnectionString field value
-func (o *ResetUserResponse) GetConnectionString() (ret ResetUserResponseGetConnectionStringRetType) {
- ret, _ = o.GetConnectionStringOk()
- return ret
-}
-
-// GetConnectionStringOk returns a tuple with the ConnectionString field value
-// and a boolean to check if the value has been set.
-func (o *ResetUserResponse) GetConnectionStringOk() (ret ResetUserResponseGetConnectionStringRetType, ok bool) {
- return getResetUserResponseGetConnectionStringAttributeTypeOk(o.ConnectionString)
-}
-
-// SetConnectionString sets field value
-func (o *ResetUserResponse) SetConnectionString(v ResetUserResponseGetConnectionStringRetType) {
- setResetUserResponseGetConnectionStringAttributeType(&o.ConnectionString, v)
-}
-
-// GetName returns the Name field value
-func (o *ResetUserResponse) GetName() (ret ResetUserResponseGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *ResetUserResponse) GetNameOk() (ret ResetUserResponseGetNameRetType, ok bool) {
- return getResetUserResponseGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *ResetUserResponse) SetName(v ResetUserResponseGetNameRetType) {
- setResetUserResponseGetNameAttributeType(&o.Name, v)
-}
-
-// GetPassword returns the Password field value
-func (o *ResetUserResponse) GetPassword() (ret ResetUserResponseGetPasswordRetType) {
- ret, _ = o.GetPasswordOk()
- return ret
-}
-
-// GetPasswordOk returns a tuple with the Password field value
-// and a boolean to check if the value has been set.
-func (o *ResetUserResponse) GetPasswordOk() (ret ResetUserResponseGetPasswordRetType, ok bool) {
- return getResetUserResponseGetPasswordAttributeTypeOk(o.Password)
-}
-
-// SetPassword sets field value
-func (o *ResetUserResponse) SetPassword(v ResetUserResponseGetPasswordRetType) {
- setResetUserResponseGetPasswordAttributeType(&o.Password, v)
-}
-
-// GetStatus returns the Status field value
-func (o *ResetUserResponse) GetStatus() (ret ResetUserResponseGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *ResetUserResponse) GetStatusOk() (ret ResetUserResponseGetStatusRetType, ok bool) {
- return getResetUserResponseGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *ResetUserResponse) SetStatus(v ResetUserResponseGetStatusRetType) {
- setResetUserResponseGetStatusAttributeType(&o.Status, v)
-}
-
-func (o ResetUserResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getResetUserResponseGetConnectionStringAttributeTypeOk(o.ConnectionString); ok {
- toSerialize["ConnectionString"] = val
- }
- if val, ok := getResetUserResponseGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getResetUserResponseGetPasswordAttributeTypeOk(o.Password); ok {
- toSerialize["Password"] = val
- }
- if val, ok := getResetUserResponseGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- return toSerialize, nil
-}
-
-type NullableResetUserResponse struct {
- value *ResetUserResponse
- isSet bool
-}
-
-func (v NullableResetUserResponse) Get() *ResetUserResponse {
- return v.value
-}
-
-func (v *NullableResetUserResponse) Set(val *ResetUserResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableResetUserResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableResetUserResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableResetUserResponse(val *ResetUserResponse) *NullableResetUserResponse {
- return &NullableResetUserResponse{value: val, isSet: true}
-}
-
-func (v NullableResetUserResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableResetUserResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_reset_user_response_test.go b/pkg/postgresflexalpha/model_reset_user_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_reset_user_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_status.go b/pkg/postgresflexalpha/model_status.go
deleted file mode 100644
index 0bd594ce..00000000
--- a/pkg/postgresflexalpha/model_status.go
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// Status The current status of the instance.
-type Status string
-
-// List of status
-const (
- STATUS_READY Status = "READY"
- STATUS_PENDING Status = "PENDING"
- STATUS_PROGRESSING Status = "PROGRESSING"
- STATUS_FAILURE Status = "FAILURE"
- STATUS_UNKNOWN Status = "UNKNOWN"
- STATUS_TERMINATING Status = "TERMINATING"
-)
-
-// All allowed values of Status enum
-var AllowedStatusEnumValues = []Status{
- "READY",
- "PENDING",
- "PROGRESSING",
- "FAILURE",
- "UNKNOWN",
- "TERMINATING",
-}
-
-func (v *Status) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := Status(value)
- for _, existing := range AllowedStatusEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid Status", value)
-}
-
-// NewStatusFromValue returns a pointer to a valid Status
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewStatusFromValue(v string) (*Status, error) {
- ev := Status(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for Status: valid values are %v", v, AllowedStatusEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v Status) IsValid() bool {
- for _, existing := range AllowedStatusEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to status value
-func (v Status) Ptr() *Status {
- return &v
-}
-
-type NullableStatus struct {
- value *Status
- isSet bool
-}
-
-func (v NullableStatus) Get() *Status {
- return v.value
-}
-
-func (v *NullableStatus) Set(val *Status) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableStatus) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableStatus) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableStatus(val *Status) *NullableStatus {
- return &NullableStatus{value: val, isSet: true}
-}
-
-func (v NullableStatus) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableStatus) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_status_test.go b/pkg/postgresflexalpha/model_status_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_status_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_storage.go b/pkg/postgresflexalpha/model_storage.go
deleted file mode 100644
index d3bddc55..00000000
--- a/pkg/postgresflexalpha/model_storage.go
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the Storage type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &Storage{}
-
-/*
- types and functions for performanceClass
-*/
-
-// isNotNullableString
-type StorageGetPerformanceClassAttributeType = *string
-
-func getStorageGetPerformanceClassAttributeTypeOk(arg StorageGetPerformanceClassAttributeType) (ret StorageGetPerformanceClassRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setStorageGetPerformanceClassAttributeType(arg *StorageGetPerformanceClassAttributeType, val StorageGetPerformanceClassRetType) {
- *arg = &val
-}
-
-type StorageGetPerformanceClassArgType = string
-type StorageGetPerformanceClassRetType = string
-
-/*
- types and functions for size
-*/
-
-// isLong
-type StorageGetSizeAttributeType = *int64
-type StorageGetSizeArgType = int64
-type StorageGetSizeRetType = int64
-
-func getStorageGetSizeAttributeTypeOk(arg StorageGetSizeAttributeType) (ret StorageGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setStorageGetSizeAttributeType(arg *StorageGetSizeAttributeType, val StorageGetSizeRetType) {
- *arg = &val
-}
-
-// Storage The object containing information about the storage size and class.
-type Storage struct {
- // The storage class for the storage.
- PerformanceClass StorageGetPerformanceClassAttributeType `json:"performanceClass,omitempty"`
- // The storage size in Gigabytes.
- Size StorageGetSizeAttributeType `json:"size,omitempty"`
-}
-
-// NewStorage instantiates a new Storage object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewStorage() *Storage {
- this := Storage{}
- return &this
-}
-
-// NewStorageWithDefaults instantiates a new Storage object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewStorageWithDefaults() *Storage {
- this := Storage{}
- return &this
-}
-
-// GetPerformanceClass returns the PerformanceClass field value if set, zero value otherwise.
-func (o *Storage) GetPerformanceClass() (res StorageGetPerformanceClassRetType) {
- res, _ = o.GetPerformanceClassOk()
- return
-}
-
-// GetPerformanceClassOk returns a tuple with the PerformanceClass field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *Storage) GetPerformanceClassOk() (ret StorageGetPerformanceClassRetType, ok bool) {
- return getStorageGetPerformanceClassAttributeTypeOk(o.PerformanceClass)
-}
-
-// HasPerformanceClass returns a boolean if a field has been set.
-func (o *Storage) HasPerformanceClass() bool {
- _, ok := o.GetPerformanceClassOk()
- return ok
-}
-
-// SetPerformanceClass gets a reference to the given string and assigns it to the PerformanceClass field.
-func (o *Storage) SetPerformanceClass(v StorageGetPerformanceClassRetType) {
- setStorageGetPerformanceClassAttributeType(&o.PerformanceClass, v)
-}
-
-// GetSize returns the Size field value if set, zero value otherwise.
-func (o *Storage) GetSize() (res StorageGetSizeRetType) {
- res, _ = o.GetSizeOk()
- return
-}
-
-// GetSizeOk returns a tuple with the Size field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *Storage) GetSizeOk() (ret StorageGetSizeRetType, ok bool) {
- return getStorageGetSizeAttributeTypeOk(o.Size)
-}
-
-// HasSize returns a boolean if a field has been set.
-func (o *Storage) HasSize() bool {
- _, ok := o.GetSizeOk()
- return ok
-}
-
-// SetSize gets a reference to the given int64 and assigns it to the Size field.
-func (o *Storage) SetSize(v StorageGetSizeRetType) {
- setStorageGetSizeAttributeType(&o.Size, v)
-}
-
-func (o Storage) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getStorageGetPerformanceClassAttributeTypeOk(o.PerformanceClass); ok {
- toSerialize["PerformanceClass"] = val
- }
- if val, ok := getStorageGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- return toSerialize, nil
-}
-
-type NullableStorage struct {
- value *Storage
- isSet bool
-}
-
-func (v NullableStorage) Get() *Storage {
- return v.value
-}
-
-func (v *NullableStorage) Set(val *Storage) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableStorage) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableStorage) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableStorage(val *Storage) *NullableStorage {
- return &NullableStorage{value: val, isSet: true}
-}
-
-func (v NullableStorage) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableStorage) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_storage_create.go b/pkg/postgresflexalpha/model_storage_create.go
deleted file mode 100644
index 9654433c..00000000
--- a/pkg/postgresflexalpha/model_storage_create.go
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the StorageCreate type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &StorageCreate{}
-
-/*
- types and functions for performanceClass
-*/
-
-// isNotNullableString
-type StorageCreateGetPerformanceClassAttributeType = *string
-
-func getStorageCreateGetPerformanceClassAttributeTypeOk(arg StorageCreateGetPerformanceClassAttributeType) (ret StorageCreateGetPerformanceClassRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setStorageCreateGetPerformanceClassAttributeType(arg *StorageCreateGetPerformanceClassAttributeType, val StorageCreateGetPerformanceClassRetType) {
- *arg = &val
-}
-
-type StorageCreateGetPerformanceClassArgType = string
-type StorageCreateGetPerformanceClassRetType = string
-
-/*
- types and functions for size
-*/
-
-// isLong
-type StorageCreateGetSizeAttributeType = *int64
-type StorageCreateGetSizeArgType = int64
-type StorageCreateGetSizeRetType = int64
-
-func getStorageCreateGetSizeAttributeTypeOk(arg StorageCreateGetSizeAttributeType) (ret StorageCreateGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setStorageCreateGetSizeAttributeType(arg *StorageCreateGetSizeAttributeType, val StorageCreateGetSizeRetType) {
- *arg = &val
-}
-
-// StorageCreate The object containing information about the storage size and class.
-type StorageCreate struct {
- // The storage class for the storage.
- // REQUIRED
- PerformanceClass StorageCreateGetPerformanceClassAttributeType `json:"performanceClass" required:"true"`
- // The storage size in Gigabytes.
- // REQUIRED
- Size StorageCreateGetSizeAttributeType `json:"size" required:"true"`
-}
-
-type _StorageCreate StorageCreate
-
-// NewStorageCreate instantiates a new StorageCreate object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewStorageCreate(performanceClass StorageCreateGetPerformanceClassArgType, size StorageCreateGetSizeArgType) *StorageCreate {
- this := StorageCreate{}
- setStorageCreateGetPerformanceClassAttributeType(&this.PerformanceClass, performanceClass)
- setStorageCreateGetSizeAttributeType(&this.Size, size)
- return &this
-}
-
-// NewStorageCreateWithDefaults instantiates a new StorageCreate object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewStorageCreateWithDefaults() *StorageCreate {
- this := StorageCreate{}
- return &this
-}
-
-// GetPerformanceClass returns the PerformanceClass field value
-func (o *StorageCreate) GetPerformanceClass() (ret StorageCreateGetPerformanceClassRetType) {
- ret, _ = o.GetPerformanceClassOk()
- return ret
-}
-
-// GetPerformanceClassOk returns a tuple with the PerformanceClass field value
-// and a boolean to check if the value has been set.
-func (o *StorageCreate) GetPerformanceClassOk() (ret StorageCreateGetPerformanceClassRetType, ok bool) {
- return getStorageCreateGetPerformanceClassAttributeTypeOk(o.PerformanceClass)
-}
-
-// SetPerformanceClass sets field value
-func (o *StorageCreate) SetPerformanceClass(v StorageCreateGetPerformanceClassRetType) {
- setStorageCreateGetPerformanceClassAttributeType(&o.PerformanceClass, v)
-}
-
-// GetSize returns the Size field value
-func (o *StorageCreate) GetSize() (ret StorageCreateGetSizeRetType) {
- ret, _ = o.GetSizeOk()
- return ret
-}
-
-// GetSizeOk returns a tuple with the Size field value
-// and a boolean to check if the value has been set.
-func (o *StorageCreate) GetSizeOk() (ret StorageCreateGetSizeRetType, ok bool) {
- return getStorageCreateGetSizeAttributeTypeOk(o.Size)
-}
-
-// SetSize sets field value
-func (o *StorageCreate) SetSize(v StorageCreateGetSizeRetType) {
- setStorageCreateGetSizeAttributeType(&o.Size, v)
-}
-
-func (o StorageCreate) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getStorageCreateGetPerformanceClassAttributeTypeOk(o.PerformanceClass); ok {
- toSerialize["PerformanceClass"] = val
- }
- if val, ok := getStorageCreateGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- return toSerialize, nil
-}
-
-type NullableStorageCreate struct {
- value *StorageCreate
- isSet bool
-}
-
-func (v NullableStorageCreate) Get() *StorageCreate {
- return v.value
-}
-
-func (v *NullableStorageCreate) Set(val *StorageCreate) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableStorageCreate) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableStorageCreate) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableStorageCreate(val *StorageCreate) *NullableStorageCreate {
- return &NullableStorageCreate{value: val, isSet: true}
-}
-
-func (v NullableStorageCreate) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableStorageCreate) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_storage_create_test.go b/pkg/postgresflexalpha/model_storage_create_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_storage_create_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_storage_test.go b/pkg/postgresflexalpha/model_storage_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_storage_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_storage_update.go b/pkg/postgresflexalpha/model_storage_update.go
deleted file mode 100644
index 17496289..00000000
--- a/pkg/postgresflexalpha/model_storage_update.go
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the StorageUpdate type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &StorageUpdate{}
-
-/*
- types and functions for size
-*/
-
-// isLong
-type StorageUpdateGetSizeAttributeType = *int64
-type StorageUpdateGetSizeArgType = int64
-type StorageUpdateGetSizeRetType = int64
-
-func getStorageUpdateGetSizeAttributeTypeOk(arg StorageUpdateGetSizeAttributeType) (ret StorageUpdateGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setStorageUpdateGetSizeAttributeType(arg *StorageUpdateGetSizeAttributeType, val StorageUpdateGetSizeRetType) {
- *arg = &val
-}
-
-// StorageUpdate The object containing information about the storage size and class.
-type StorageUpdate struct {
- // The storage size in Gigabytes.
- Size StorageUpdateGetSizeAttributeType `json:"size,omitempty"`
-}
-
-// NewStorageUpdate instantiates a new StorageUpdate object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewStorageUpdate() *StorageUpdate {
- this := StorageUpdate{}
- return &this
-}
-
-// NewStorageUpdateWithDefaults instantiates a new StorageUpdate object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewStorageUpdateWithDefaults() *StorageUpdate {
- this := StorageUpdate{}
- return &this
-}
-
-// GetSize returns the Size field value if set, zero value otherwise.
-func (o *StorageUpdate) GetSize() (res StorageUpdateGetSizeRetType) {
- res, _ = o.GetSizeOk()
- return
-}
-
-// GetSizeOk returns a tuple with the Size field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *StorageUpdate) GetSizeOk() (ret StorageUpdateGetSizeRetType, ok bool) {
- return getStorageUpdateGetSizeAttributeTypeOk(o.Size)
-}
-
-// HasSize returns a boolean if a field has been set.
-func (o *StorageUpdate) HasSize() bool {
- _, ok := o.GetSizeOk()
- return ok
-}
-
-// SetSize gets a reference to the given int64 and assigns it to the Size field.
-func (o *StorageUpdate) SetSize(v StorageUpdateGetSizeRetType) {
- setStorageUpdateGetSizeAttributeType(&o.Size, v)
-}
-
-func (o StorageUpdate) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getStorageUpdateGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- return toSerialize, nil
-}
-
-type NullableStorageUpdate struct {
- value *StorageUpdate
- isSet bool
-}
-
-func (v NullableStorageUpdate) Get() *StorageUpdate {
- return v.value
-}
-
-func (v *NullableStorageUpdate) Set(val *StorageUpdate) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableStorageUpdate) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableStorageUpdate) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableStorageUpdate(val *StorageUpdate) *NullableStorageUpdate {
- return &NullableStorageUpdate{value: val, isSet: true}
-}
-
-func (v NullableStorageUpdate) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableStorageUpdate) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_storage_update_test.go b/pkg/postgresflexalpha/model_storage_update_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_storage_update_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_update_database_partially_request_payload.go b/pkg/postgresflexalpha/model_update_database_partially_request_payload.go
deleted file mode 100644
index 883e4f6b..00000000
--- a/pkg/postgresflexalpha/model_update_database_partially_request_payload.go
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the UpdateDatabasePartiallyRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &UpdateDatabasePartiallyRequestPayload{}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type UpdateDatabasePartiallyRequestPayloadGetNameAttributeType = *string
-
-func getUpdateDatabasePartiallyRequestPayloadGetNameAttributeTypeOk(arg UpdateDatabasePartiallyRequestPayloadGetNameAttributeType) (ret UpdateDatabasePartiallyRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateDatabasePartiallyRequestPayloadGetNameAttributeType(arg *UpdateDatabasePartiallyRequestPayloadGetNameAttributeType, val UpdateDatabasePartiallyRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type UpdateDatabasePartiallyRequestPayloadGetNameArgType = string
-type UpdateDatabasePartiallyRequestPayloadGetNameRetType = string
-
-/*
- types and functions for owner
-*/
-
-// isNotNullableString
-type UpdateDatabasePartiallyRequestPayloadGetOwnerAttributeType = *string
-
-func getUpdateDatabasePartiallyRequestPayloadGetOwnerAttributeTypeOk(arg UpdateDatabasePartiallyRequestPayloadGetOwnerAttributeType) (ret UpdateDatabasePartiallyRequestPayloadGetOwnerRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateDatabasePartiallyRequestPayloadGetOwnerAttributeType(arg *UpdateDatabasePartiallyRequestPayloadGetOwnerAttributeType, val UpdateDatabasePartiallyRequestPayloadGetOwnerRetType) {
- *arg = &val
-}
-
-type UpdateDatabasePartiallyRequestPayloadGetOwnerArgType = string
-type UpdateDatabasePartiallyRequestPayloadGetOwnerRetType = string
-
-// UpdateDatabasePartiallyRequestPayload struct for UpdateDatabasePartiallyRequestPayload
-type UpdateDatabasePartiallyRequestPayload struct {
- // The name of the database.
- Name UpdateDatabasePartiallyRequestPayloadGetNameAttributeType `json:"name,omitempty"`
- // The owner of the database.
- Owner UpdateDatabasePartiallyRequestPayloadGetOwnerAttributeType `json:"owner,omitempty"`
-}
-
-// NewUpdateDatabasePartiallyRequestPayload instantiates a new UpdateDatabasePartiallyRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewUpdateDatabasePartiallyRequestPayload() *UpdateDatabasePartiallyRequestPayload {
- this := UpdateDatabasePartiallyRequestPayload{}
- return &this
-}
-
-// NewUpdateDatabasePartiallyRequestPayloadWithDefaults instantiates a new UpdateDatabasePartiallyRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewUpdateDatabasePartiallyRequestPayloadWithDefaults() *UpdateDatabasePartiallyRequestPayload {
- this := UpdateDatabasePartiallyRequestPayload{}
- return &this
-}
-
-// GetName returns the Name field value if set, zero value otherwise.
-func (o *UpdateDatabasePartiallyRequestPayload) GetName() (res UpdateDatabasePartiallyRequestPayloadGetNameRetType) {
- res, _ = o.GetNameOk()
- return
-}
-
-// GetNameOk returns a tuple with the Name field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateDatabasePartiallyRequestPayload) GetNameOk() (ret UpdateDatabasePartiallyRequestPayloadGetNameRetType, ok bool) {
- return getUpdateDatabasePartiallyRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// HasName returns a boolean if a field has been set.
-func (o *UpdateDatabasePartiallyRequestPayload) HasName() bool {
- _, ok := o.GetNameOk()
- return ok
-}
-
-// SetName gets a reference to the given string and assigns it to the Name field.
-func (o *UpdateDatabasePartiallyRequestPayload) SetName(v UpdateDatabasePartiallyRequestPayloadGetNameRetType) {
- setUpdateDatabasePartiallyRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetOwner returns the Owner field value if set, zero value otherwise.
-func (o *UpdateDatabasePartiallyRequestPayload) GetOwner() (res UpdateDatabasePartiallyRequestPayloadGetOwnerRetType) {
- res, _ = o.GetOwnerOk()
- return
-}
-
-// GetOwnerOk returns a tuple with the Owner field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateDatabasePartiallyRequestPayload) GetOwnerOk() (ret UpdateDatabasePartiallyRequestPayloadGetOwnerRetType, ok bool) {
- return getUpdateDatabasePartiallyRequestPayloadGetOwnerAttributeTypeOk(o.Owner)
-}
-
-// HasOwner returns a boolean if a field has been set.
-func (o *UpdateDatabasePartiallyRequestPayload) HasOwner() bool {
- _, ok := o.GetOwnerOk()
- return ok
-}
-
-// SetOwner gets a reference to the given string and assigns it to the Owner field.
-func (o *UpdateDatabasePartiallyRequestPayload) SetOwner(v UpdateDatabasePartiallyRequestPayloadGetOwnerRetType) {
- setUpdateDatabasePartiallyRequestPayloadGetOwnerAttributeType(&o.Owner, v)
-}
-
-func (o UpdateDatabasePartiallyRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getUpdateDatabasePartiallyRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getUpdateDatabasePartiallyRequestPayloadGetOwnerAttributeTypeOk(o.Owner); ok {
- toSerialize["Owner"] = val
- }
- return toSerialize, nil
-}
-
-type NullableUpdateDatabasePartiallyRequestPayload struct {
- value *UpdateDatabasePartiallyRequestPayload
- isSet bool
-}
-
-func (v NullableUpdateDatabasePartiallyRequestPayload) Get() *UpdateDatabasePartiallyRequestPayload {
- return v.value
-}
-
-func (v *NullableUpdateDatabasePartiallyRequestPayload) Set(val *UpdateDatabasePartiallyRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUpdateDatabasePartiallyRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUpdateDatabasePartiallyRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUpdateDatabasePartiallyRequestPayload(val *UpdateDatabasePartiallyRequestPayload) *NullableUpdateDatabasePartiallyRequestPayload {
- return &NullableUpdateDatabasePartiallyRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableUpdateDatabasePartiallyRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUpdateDatabasePartiallyRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_update_database_partially_request_payload_test.go b/pkg/postgresflexalpha/model_update_database_partially_request_payload_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_update_database_partially_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_update_database_partially_response.go b/pkg/postgresflexalpha/model_update_database_partially_response.go
deleted file mode 100644
index f689dec8..00000000
--- a/pkg/postgresflexalpha/model_update_database_partially_response.go
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the UpdateDatabasePartiallyResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &UpdateDatabasePartiallyResponse{}
-
-/*
- types and functions for database
-*/
-
-// isModel
-type UpdateDatabasePartiallyResponseGetDatabaseAttributeType = *ListDatabase
-type UpdateDatabasePartiallyResponseGetDatabaseArgType = ListDatabase
-type UpdateDatabasePartiallyResponseGetDatabaseRetType = ListDatabase
-
-func getUpdateDatabasePartiallyResponseGetDatabaseAttributeTypeOk(arg UpdateDatabasePartiallyResponseGetDatabaseAttributeType) (ret UpdateDatabasePartiallyResponseGetDatabaseRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateDatabasePartiallyResponseGetDatabaseAttributeType(arg *UpdateDatabasePartiallyResponseGetDatabaseAttributeType, val UpdateDatabasePartiallyResponseGetDatabaseRetType) {
- *arg = &val
-}
-
-// UpdateDatabasePartiallyResponse struct for UpdateDatabasePartiallyResponse
-type UpdateDatabasePartiallyResponse struct {
- // REQUIRED
- Database UpdateDatabasePartiallyResponseGetDatabaseAttributeType `json:"database" required:"true"`
-}
-
-type _UpdateDatabasePartiallyResponse UpdateDatabasePartiallyResponse
-
-// NewUpdateDatabasePartiallyResponse instantiates a new UpdateDatabasePartiallyResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewUpdateDatabasePartiallyResponse(database UpdateDatabasePartiallyResponseGetDatabaseArgType) *UpdateDatabasePartiallyResponse {
- this := UpdateDatabasePartiallyResponse{}
- setUpdateDatabasePartiallyResponseGetDatabaseAttributeType(&this.Database, database)
- return &this
-}
-
-// NewUpdateDatabasePartiallyResponseWithDefaults instantiates a new UpdateDatabasePartiallyResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewUpdateDatabasePartiallyResponseWithDefaults() *UpdateDatabasePartiallyResponse {
- this := UpdateDatabasePartiallyResponse{}
- return &this
-}
-
-// GetDatabase returns the Database field value
-func (o *UpdateDatabasePartiallyResponse) GetDatabase() (ret UpdateDatabasePartiallyResponseGetDatabaseRetType) {
- ret, _ = o.GetDatabaseOk()
- return ret
-}
-
-// GetDatabaseOk returns a tuple with the Database field value
-// and a boolean to check if the value has been set.
-func (o *UpdateDatabasePartiallyResponse) GetDatabaseOk() (ret UpdateDatabasePartiallyResponseGetDatabaseRetType, ok bool) {
- return getUpdateDatabasePartiallyResponseGetDatabaseAttributeTypeOk(o.Database)
-}
-
-// SetDatabase sets field value
-func (o *UpdateDatabasePartiallyResponse) SetDatabase(v UpdateDatabasePartiallyResponseGetDatabaseRetType) {
- setUpdateDatabasePartiallyResponseGetDatabaseAttributeType(&o.Database, v)
-}
-
-func (o UpdateDatabasePartiallyResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getUpdateDatabasePartiallyResponseGetDatabaseAttributeTypeOk(o.Database); ok {
- toSerialize["Database"] = val
- }
- return toSerialize, nil
-}
-
-type NullableUpdateDatabasePartiallyResponse struct {
- value *UpdateDatabasePartiallyResponse
- isSet bool
-}
-
-func (v NullableUpdateDatabasePartiallyResponse) Get() *UpdateDatabasePartiallyResponse {
- return v.value
-}
-
-func (v *NullableUpdateDatabasePartiallyResponse) Set(val *UpdateDatabasePartiallyResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUpdateDatabasePartiallyResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUpdateDatabasePartiallyResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUpdateDatabasePartiallyResponse(val *UpdateDatabasePartiallyResponse) *NullableUpdateDatabasePartiallyResponse {
- return &NullableUpdateDatabasePartiallyResponse{value: val, isSet: true}
-}
-
-func (v NullableUpdateDatabasePartiallyResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUpdateDatabasePartiallyResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_update_database_partially_response_test.go b/pkg/postgresflexalpha/model_update_database_partially_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_update_database_partially_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_update_database_request_payload.go b/pkg/postgresflexalpha/model_update_database_request_payload.go
deleted file mode 100644
index ef00ac4e..00000000
--- a/pkg/postgresflexalpha/model_update_database_request_payload.go
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the UpdateDatabaseRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &UpdateDatabaseRequestPayload{}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type UpdateDatabaseRequestPayloadGetNameAttributeType = *string
-
-func getUpdateDatabaseRequestPayloadGetNameAttributeTypeOk(arg UpdateDatabaseRequestPayloadGetNameAttributeType) (ret UpdateDatabaseRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateDatabaseRequestPayloadGetNameAttributeType(arg *UpdateDatabaseRequestPayloadGetNameAttributeType, val UpdateDatabaseRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type UpdateDatabaseRequestPayloadGetNameArgType = string
-type UpdateDatabaseRequestPayloadGetNameRetType = string
-
-/*
- types and functions for owner
-*/
-
-// isNotNullableString
-type UpdateDatabaseRequestPayloadGetOwnerAttributeType = *string
-
-func getUpdateDatabaseRequestPayloadGetOwnerAttributeTypeOk(arg UpdateDatabaseRequestPayloadGetOwnerAttributeType) (ret UpdateDatabaseRequestPayloadGetOwnerRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateDatabaseRequestPayloadGetOwnerAttributeType(arg *UpdateDatabaseRequestPayloadGetOwnerAttributeType, val UpdateDatabaseRequestPayloadGetOwnerRetType) {
- *arg = &val
-}
-
-type UpdateDatabaseRequestPayloadGetOwnerArgType = string
-type UpdateDatabaseRequestPayloadGetOwnerRetType = string
-
-// UpdateDatabaseRequestPayload struct for UpdateDatabaseRequestPayload
-type UpdateDatabaseRequestPayload struct {
- // The name of the database.
- // REQUIRED
- Name UpdateDatabaseRequestPayloadGetNameAttributeType `json:"name" required:"true"`
- // The owner of the database.
- // REQUIRED
- Owner UpdateDatabaseRequestPayloadGetOwnerAttributeType `json:"owner" required:"true"`
-}
-
-type _UpdateDatabaseRequestPayload UpdateDatabaseRequestPayload
-
-// NewUpdateDatabaseRequestPayload instantiates a new UpdateDatabaseRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewUpdateDatabaseRequestPayload(name UpdateDatabaseRequestPayloadGetNameArgType, owner UpdateDatabaseRequestPayloadGetOwnerArgType) *UpdateDatabaseRequestPayload {
- this := UpdateDatabaseRequestPayload{}
- setUpdateDatabaseRequestPayloadGetNameAttributeType(&this.Name, name)
- setUpdateDatabaseRequestPayloadGetOwnerAttributeType(&this.Owner, owner)
- return &this
-}
-
-// NewUpdateDatabaseRequestPayloadWithDefaults instantiates a new UpdateDatabaseRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewUpdateDatabaseRequestPayloadWithDefaults() *UpdateDatabaseRequestPayload {
- this := UpdateDatabaseRequestPayload{}
- return &this
-}
-
-// GetName returns the Name field value
-func (o *UpdateDatabaseRequestPayload) GetName() (ret UpdateDatabaseRequestPayloadGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *UpdateDatabaseRequestPayload) GetNameOk() (ret UpdateDatabaseRequestPayloadGetNameRetType, ok bool) {
- return getUpdateDatabaseRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *UpdateDatabaseRequestPayload) SetName(v UpdateDatabaseRequestPayloadGetNameRetType) {
- setUpdateDatabaseRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetOwner returns the Owner field value
-func (o *UpdateDatabaseRequestPayload) GetOwner() (ret UpdateDatabaseRequestPayloadGetOwnerRetType) {
- ret, _ = o.GetOwnerOk()
- return ret
-}
-
-// GetOwnerOk returns a tuple with the Owner field value
-// and a boolean to check if the value has been set.
-func (o *UpdateDatabaseRequestPayload) GetOwnerOk() (ret UpdateDatabaseRequestPayloadGetOwnerRetType, ok bool) {
- return getUpdateDatabaseRequestPayloadGetOwnerAttributeTypeOk(o.Owner)
-}
-
-// SetOwner sets field value
-func (o *UpdateDatabaseRequestPayload) SetOwner(v UpdateDatabaseRequestPayloadGetOwnerRetType) {
- setUpdateDatabaseRequestPayloadGetOwnerAttributeType(&o.Owner, v)
-}
-
-func (o UpdateDatabaseRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getUpdateDatabaseRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getUpdateDatabaseRequestPayloadGetOwnerAttributeTypeOk(o.Owner); ok {
- toSerialize["Owner"] = val
- }
- return toSerialize, nil
-}
-
-type NullableUpdateDatabaseRequestPayload struct {
- value *UpdateDatabaseRequestPayload
- isSet bool
-}
-
-func (v NullableUpdateDatabaseRequestPayload) Get() *UpdateDatabaseRequestPayload {
- return v.value
-}
-
-func (v *NullableUpdateDatabaseRequestPayload) Set(val *UpdateDatabaseRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUpdateDatabaseRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUpdateDatabaseRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUpdateDatabaseRequestPayload(val *UpdateDatabaseRequestPayload) *NullableUpdateDatabaseRequestPayload {
- return &NullableUpdateDatabaseRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableUpdateDatabaseRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUpdateDatabaseRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_update_database_request_payload_test.go b/pkg/postgresflexalpha/model_update_database_request_payload_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_update_database_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_update_database_response.go b/pkg/postgresflexalpha/model_update_database_response.go
deleted file mode 100644
index b875b677..00000000
--- a/pkg/postgresflexalpha/model_update_database_response.go
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the UpdateDatabaseResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &UpdateDatabaseResponse{}
-
-/*
- types and functions for database
-*/
-
-// isModel
-type UpdateDatabaseResponseGetDatabaseAttributeType = *ListDatabase
-type UpdateDatabaseResponseGetDatabaseArgType = ListDatabase
-type UpdateDatabaseResponseGetDatabaseRetType = ListDatabase
-
-func getUpdateDatabaseResponseGetDatabaseAttributeTypeOk(arg UpdateDatabaseResponseGetDatabaseAttributeType) (ret UpdateDatabaseResponseGetDatabaseRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateDatabaseResponseGetDatabaseAttributeType(arg *UpdateDatabaseResponseGetDatabaseAttributeType, val UpdateDatabaseResponseGetDatabaseRetType) {
- *arg = &val
-}
-
-// UpdateDatabaseResponse struct for UpdateDatabaseResponse
-type UpdateDatabaseResponse struct {
- // REQUIRED
- Database UpdateDatabaseResponseGetDatabaseAttributeType `json:"database" required:"true"`
-}
-
-type _UpdateDatabaseResponse UpdateDatabaseResponse
-
-// NewUpdateDatabaseResponse instantiates a new UpdateDatabaseResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewUpdateDatabaseResponse(database UpdateDatabaseResponseGetDatabaseArgType) *UpdateDatabaseResponse {
- this := UpdateDatabaseResponse{}
- setUpdateDatabaseResponseGetDatabaseAttributeType(&this.Database, database)
- return &this
-}
-
-// NewUpdateDatabaseResponseWithDefaults instantiates a new UpdateDatabaseResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewUpdateDatabaseResponseWithDefaults() *UpdateDatabaseResponse {
- this := UpdateDatabaseResponse{}
- return &this
-}
-
-// GetDatabase returns the Database field value
-func (o *UpdateDatabaseResponse) GetDatabase() (ret UpdateDatabaseResponseGetDatabaseRetType) {
- ret, _ = o.GetDatabaseOk()
- return ret
-}
-
-// GetDatabaseOk returns a tuple with the Database field value
-// and a boolean to check if the value has been set.
-func (o *UpdateDatabaseResponse) GetDatabaseOk() (ret UpdateDatabaseResponseGetDatabaseRetType, ok bool) {
- return getUpdateDatabaseResponseGetDatabaseAttributeTypeOk(o.Database)
-}
-
-// SetDatabase sets field value
-func (o *UpdateDatabaseResponse) SetDatabase(v UpdateDatabaseResponseGetDatabaseRetType) {
- setUpdateDatabaseResponseGetDatabaseAttributeType(&o.Database, v)
-}
-
-func (o UpdateDatabaseResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getUpdateDatabaseResponseGetDatabaseAttributeTypeOk(o.Database); ok {
- toSerialize["Database"] = val
- }
- return toSerialize, nil
-}
-
-type NullableUpdateDatabaseResponse struct {
- value *UpdateDatabaseResponse
- isSet bool
-}
-
-func (v NullableUpdateDatabaseResponse) Get() *UpdateDatabaseResponse {
- return v.value
-}
-
-func (v *NullableUpdateDatabaseResponse) Set(val *UpdateDatabaseResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUpdateDatabaseResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUpdateDatabaseResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUpdateDatabaseResponse(val *UpdateDatabaseResponse) *NullableUpdateDatabaseResponse {
- return &NullableUpdateDatabaseResponse{value: val, isSet: true}
-}
-
-func (v NullableUpdateDatabaseResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUpdateDatabaseResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_update_database_response_test.go b/pkg/postgresflexalpha/model_update_database_response_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_update_database_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_update_instance_partially_request_payload.go b/pkg/postgresflexalpha/model_update_instance_partially_request_payload.go
deleted file mode 100644
index e1f2924a..00000000
--- a/pkg/postgresflexalpha/model_update_instance_partially_request_payload.go
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the UpdateInstancePartiallyRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &UpdateInstancePartiallyRequestPayload{}
-
-/*
- types and functions for acl
-*/
-
-// isArray
-type UpdateInstancePartiallyRequestPayloadGetAclAttributeType = *[]string
-type UpdateInstancePartiallyRequestPayloadGetAclArgType = []string
-type UpdateInstancePartiallyRequestPayloadGetAclRetType = []string
-
-func getUpdateInstancePartiallyRequestPayloadGetAclAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetAclAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetAclRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetAclAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetAclAttributeType, val UpdateInstancePartiallyRequestPayloadGetAclRetType) {
- *arg = &val
-}
-
-/*
- types and functions for backupSchedule
-*/
-
-// isNotNullableString
-type UpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType = *string
-
-func getUpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType, val UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType) {
- *arg = &val
-}
-
-type UpdateInstancePartiallyRequestPayloadGetBackupScheduleArgType = string
-type UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType = string
-
-/*
- types and functions for flavorId
-*/
-
-// isNotNullableString
-type UpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType = *string
-
-func getUpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType, val UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType) {
- *arg = &val
-}
-
-type UpdateInstancePartiallyRequestPayloadGetFlavorIdArgType = string
-type UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType = string
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type UpdateInstancePartiallyRequestPayloadGetNameAttributeType = *string
-
-func getUpdateInstancePartiallyRequestPayloadGetNameAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetNameAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetNameAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetNameAttributeType, val UpdateInstancePartiallyRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type UpdateInstancePartiallyRequestPayloadGetNameArgType = string
-type UpdateInstancePartiallyRequestPayloadGetNameRetType = string
-
-/*
- types and functions for replicas
-*/
-
-// isEnumRef
-type UpdateInstancePartiallyRequestPayloadGetReplicasAttributeType = *ReplicasOpt
-type UpdateInstancePartiallyRequestPayloadGetReplicasArgType = ReplicasOpt
-type UpdateInstancePartiallyRequestPayloadGetReplicasRetType = ReplicasOpt
-
-func getUpdateInstancePartiallyRequestPayloadGetReplicasAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetReplicasAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetReplicasRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetReplicasAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetReplicasAttributeType, val UpdateInstancePartiallyRequestPayloadGetReplicasRetType) {
- *arg = &val
-}
-
-/*
- types and functions for retentionDays
-*/
-
-// isInteger
-type UpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType = *int64
-type UpdateInstancePartiallyRequestPayloadGetRetentionDaysArgType = int64
-type UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType = int64
-
-func getUpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType, val UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType) {
- *arg = &val
-}
-
-/*
- types and functions for storage
-*/
-
-// isModel
-type UpdateInstancePartiallyRequestPayloadGetStorageAttributeType = *StorageUpdate
-type UpdateInstancePartiallyRequestPayloadGetStorageArgType = StorageUpdate
-type UpdateInstancePartiallyRequestPayloadGetStorageRetType = StorageUpdate
-
-func getUpdateInstancePartiallyRequestPayloadGetStorageAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetStorageAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetStorageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetStorageAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetStorageAttributeType, val UpdateInstancePartiallyRequestPayloadGetStorageRetType) {
- *arg = &val
-}
-
-/*
- types and functions for version
-*/
-
-// isNotNullableString
-type UpdateInstancePartiallyRequestPayloadGetVersionAttributeType = *string
-
-func getUpdateInstancePartiallyRequestPayloadGetVersionAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetVersionAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetVersionAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetVersionAttributeType, val UpdateInstancePartiallyRequestPayloadGetVersionRetType) {
- *arg = &val
-}
-
-type UpdateInstancePartiallyRequestPayloadGetVersionArgType = string
-type UpdateInstancePartiallyRequestPayloadGetVersionRetType = string
-
-// UpdateInstancePartiallyRequestPayload struct for UpdateInstancePartiallyRequestPayload
-type UpdateInstancePartiallyRequestPayload struct {
- // List of IPV4 cidr.
- Acl UpdateInstancePartiallyRequestPayloadGetAclAttributeType `json:"acl,omitempty"`
- // The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.
- BackupSchedule UpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType `json:"backupSchedule,omitempty"`
- // The id of the instance flavor.
- FlavorId UpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType `json:"flavorId,omitempty"`
- // The name of the instance.
- Name UpdateInstancePartiallyRequestPayloadGetNameAttributeType `json:"name,omitempty"`
- Replicas UpdateInstancePartiallyRequestPayloadGetReplicasAttributeType `json:"replicas,omitempty"`
- // How long backups are retained. The value can only be between 32 and 365 days.
- // Can be cast to int32 without loss of precision.
- RetentionDays UpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType `json:"retentionDays,omitempty"`
- Storage UpdateInstancePartiallyRequestPayloadGetStorageAttributeType `json:"storage,omitempty"`
- // The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters.
- Version UpdateInstancePartiallyRequestPayloadGetVersionAttributeType `json:"version,omitempty"`
-}
-
-// NewUpdateInstancePartiallyRequestPayload instantiates a new UpdateInstancePartiallyRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewUpdateInstancePartiallyRequestPayload() *UpdateInstancePartiallyRequestPayload {
- this := UpdateInstancePartiallyRequestPayload{}
- return &this
-}
-
-// NewUpdateInstancePartiallyRequestPayloadWithDefaults instantiates a new UpdateInstancePartiallyRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewUpdateInstancePartiallyRequestPayloadWithDefaults() *UpdateInstancePartiallyRequestPayload {
- this := UpdateInstancePartiallyRequestPayload{}
- return &this
-}
-
-// GetAcl returns the Acl field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetAcl() (res UpdateInstancePartiallyRequestPayloadGetAclRetType) {
- res, _ = o.GetAclOk()
- return
-}
-
-// GetAclOk returns a tuple with the Acl field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetAclOk() (ret UpdateInstancePartiallyRequestPayloadGetAclRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetAclAttributeTypeOk(o.Acl)
-}
-
-// HasAcl returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasAcl() bool {
- _, ok := o.GetAclOk()
- return ok
-}
-
-// SetAcl gets a reference to the given []string and assigns it to the Acl field.
-func (o *UpdateInstancePartiallyRequestPayload) SetAcl(v UpdateInstancePartiallyRequestPayloadGetAclRetType) {
- setUpdateInstancePartiallyRequestPayloadGetAclAttributeType(&o.Acl, v)
-}
-
-// GetBackupSchedule returns the BackupSchedule field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetBackupSchedule() (res UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType) {
- res, _ = o.GetBackupScheduleOk()
- return
-}
-
-// GetBackupScheduleOk returns a tuple with the BackupSchedule field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetBackupScheduleOk() (ret UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule)
-}
-
-// HasBackupSchedule returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasBackupSchedule() bool {
- _, ok := o.GetBackupScheduleOk()
- return ok
-}
-
-// SetBackupSchedule gets a reference to the given string and assigns it to the BackupSchedule field.
-func (o *UpdateInstancePartiallyRequestPayload) SetBackupSchedule(v UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType) {
- setUpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType(&o.BackupSchedule, v)
-}
-
-// GetFlavorId returns the FlavorId field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetFlavorId() (res UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType) {
- res, _ = o.GetFlavorIdOk()
- return
-}
-
-// GetFlavorIdOk returns a tuple with the FlavorId field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetFlavorIdOk() (ret UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId)
-}
-
-// HasFlavorId returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasFlavorId() bool {
- _, ok := o.GetFlavorIdOk()
- return ok
-}
-
-// SetFlavorId gets a reference to the given string and assigns it to the FlavorId field.
-func (o *UpdateInstancePartiallyRequestPayload) SetFlavorId(v UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType) {
- setUpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType(&o.FlavorId, v)
-}
-
-// GetName returns the Name field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetName() (res UpdateInstancePartiallyRequestPayloadGetNameRetType) {
- res, _ = o.GetNameOk()
- return
-}
-
-// GetNameOk returns a tuple with the Name field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetNameOk() (ret UpdateInstancePartiallyRequestPayloadGetNameRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// HasName returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasName() bool {
- _, ok := o.GetNameOk()
- return ok
-}
-
-// SetName gets a reference to the given string and assigns it to the Name field.
-func (o *UpdateInstancePartiallyRequestPayload) SetName(v UpdateInstancePartiallyRequestPayloadGetNameRetType) {
- setUpdateInstancePartiallyRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetReplicas returns the Replicas field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetReplicas() (res UpdateInstancePartiallyRequestPayloadGetReplicasRetType) {
- res, _ = o.GetReplicasOk()
- return
-}
-
-// GetReplicasOk returns a tuple with the Replicas field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetReplicasOk() (ret UpdateInstancePartiallyRequestPayloadGetReplicasRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetReplicasAttributeTypeOk(o.Replicas)
-}
-
-// HasReplicas returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasReplicas() bool {
- _, ok := o.GetReplicasOk()
- return ok
-}
-
-// SetReplicas gets a reference to the given ReplicasOpt and assigns it to the Replicas field.
-func (o *UpdateInstancePartiallyRequestPayload) SetReplicas(v UpdateInstancePartiallyRequestPayloadGetReplicasRetType) {
- setUpdateInstancePartiallyRequestPayloadGetReplicasAttributeType(&o.Replicas, v)
-}
-
-// GetRetentionDays returns the RetentionDays field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetRetentionDays() (res UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType) {
- res, _ = o.GetRetentionDaysOk()
- return
-}
-
-// GetRetentionDaysOk returns a tuple with the RetentionDays field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetRetentionDaysOk() (ret UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays)
-}
-
-// HasRetentionDays returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasRetentionDays() bool {
- _, ok := o.GetRetentionDaysOk()
- return ok
-}
-
-// SetRetentionDays gets a reference to the given int64 and assigns it to the RetentionDays field.
-func (o *UpdateInstancePartiallyRequestPayload) SetRetentionDays(v UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType) {
- setUpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType(&o.RetentionDays, v)
-}
-
-// GetStorage returns the Storage field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetStorage() (res UpdateInstancePartiallyRequestPayloadGetStorageRetType) {
- res, _ = o.GetStorageOk()
- return
-}
-
-// GetStorageOk returns a tuple with the Storage field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetStorageOk() (ret UpdateInstancePartiallyRequestPayloadGetStorageRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetStorageAttributeTypeOk(o.Storage)
-}
-
-// HasStorage returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasStorage() bool {
- _, ok := o.GetStorageOk()
- return ok
-}
-
-// SetStorage gets a reference to the given StorageUpdate and assigns it to the Storage field.
-func (o *UpdateInstancePartiallyRequestPayload) SetStorage(v UpdateInstancePartiallyRequestPayloadGetStorageRetType) {
- setUpdateInstancePartiallyRequestPayloadGetStorageAttributeType(&o.Storage, v)
-}
-
-// GetVersion returns the Version field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetVersion() (res UpdateInstancePartiallyRequestPayloadGetVersionRetType) {
- res, _ = o.GetVersionOk()
- return
-}
-
-// GetVersionOk returns a tuple with the Version field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetVersionOk() (ret UpdateInstancePartiallyRequestPayloadGetVersionRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetVersionAttributeTypeOk(o.Version)
-}
-
-// HasVersion returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasVersion() bool {
- _, ok := o.GetVersionOk()
- return ok
-}
-
-// SetVersion gets a reference to the given string and assigns it to the Version field.
-func (o *UpdateInstancePartiallyRequestPayload) SetVersion(v UpdateInstancePartiallyRequestPayloadGetVersionRetType) {
- setUpdateInstancePartiallyRequestPayloadGetVersionAttributeType(&o.Version, v)
-}
-
-func (o UpdateInstancePartiallyRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetAclAttributeTypeOk(o.Acl); ok {
- toSerialize["Acl"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule); ok {
- toSerialize["BackupSchedule"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId); ok {
- toSerialize["FlavorId"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetReplicasAttributeTypeOk(o.Replicas); ok {
- toSerialize["Replicas"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays); ok {
- toSerialize["RetentionDays"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetStorageAttributeTypeOk(o.Storage); ok {
- toSerialize["Storage"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetVersionAttributeTypeOk(o.Version); ok {
- toSerialize["Version"] = val
- }
- return toSerialize, nil
-}
-
-type NullableUpdateInstancePartiallyRequestPayload struct {
- value *UpdateInstancePartiallyRequestPayload
- isSet bool
-}
-
-func (v NullableUpdateInstancePartiallyRequestPayload) Get() *UpdateInstancePartiallyRequestPayload {
- return v.value
-}
-
-func (v *NullableUpdateInstancePartiallyRequestPayload) Set(val *UpdateInstancePartiallyRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUpdateInstancePartiallyRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUpdateInstancePartiallyRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUpdateInstancePartiallyRequestPayload(val *UpdateInstancePartiallyRequestPayload) *NullableUpdateInstancePartiallyRequestPayload {
- return &NullableUpdateInstancePartiallyRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableUpdateInstancePartiallyRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUpdateInstancePartiallyRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_update_instance_partially_request_payload_test.go b/pkg/postgresflexalpha/model_update_instance_partially_request_payload_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_update_instance_partially_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_update_instance_request_payload.go b/pkg/postgresflexalpha/model_update_instance_request_payload.go
deleted file mode 100644
index 613a8bb3..00000000
--- a/pkg/postgresflexalpha/model_update_instance_request_payload.go
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the UpdateInstanceRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &UpdateInstanceRequestPayload{}
-
-/*
- types and functions for acl
-*/
-
-// isArray
-type UpdateInstanceRequestPayloadGetAclAttributeType = *[]string
-type UpdateInstanceRequestPayloadGetAclArgType = []string
-type UpdateInstanceRequestPayloadGetAclRetType = []string
-
-func getUpdateInstanceRequestPayloadGetAclAttributeTypeOk(arg UpdateInstanceRequestPayloadGetAclAttributeType) (ret UpdateInstanceRequestPayloadGetAclRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetAclAttributeType(arg *UpdateInstanceRequestPayloadGetAclAttributeType, val UpdateInstanceRequestPayloadGetAclRetType) {
- *arg = &val
-}
-
-/*
- types and functions for backupSchedule
-*/
-
-// isNotNullableString
-type UpdateInstanceRequestPayloadGetBackupScheduleAttributeType = *string
-
-func getUpdateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(arg UpdateInstanceRequestPayloadGetBackupScheduleAttributeType) (ret UpdateInstanceRequestPayloadGetBackupScheduleRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetBackupScheduleAttributeType(arg *UpdateInstanceRequestPayloadGetBackupScheduleAttributeType, val UpdateInstanceRequestPayloadGetBackupScheduleRetType) {
- *arg = &val
-}
-
-type UpdateInstanceRequestPayloadGetBackupScheduleArgType = string
-type UpdateInstanceRequestPayloadGetBackupScheduleRetType = string
-
-/*
- types and functions for flavorId
-*/
-
-// isNotNullableString
-type UpdateInstanceRequestPayloadGetFlavorIdAttributeType = *string
-
-func getUpdateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(arg UpdateInstanceRequestPayloadGetFlavorIdAttributeType) (ret UpdateInstanceRequestPayloadGetFlavorIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetFlavorIdAttributeType(arg *UpdateInstanceRequestPayloadGetFlavorIdAttributeType, val UpdateInstanceRequestPayloadGetFlavorIdRetType) {
- *arg = &val
-}
-
-type UpdateInstanceRequestPayloadGetFlavorIdArgType = string
-type UpdateInstanceRequestPayloadGetFlavorIdRetType = string
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type UpdateInstanceRequestPayloadGetNameAttributeType = *string
-
-func getUpdateInstanceRequestPayloadGetNameAttributeTypeOk(arg UpdateInstanceRequestPayloadGetNameAttributeType) (ret UpdateInstanceRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetNameAttributeType(arg *UpdateInstanceRequestPayloadGetNameAttributeType, val UpdateInstanceRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type UpdateInstanceRequestPayloadGetNameArgType = string
-type UpdateInstanceRequestPayloadGetNameRetType = string
-
-/*
- types and functions for replicas
-*/
-
-// isEnumRef
-type UpdateInstanceRequestPayloadGetReplicasAttributeType = *Replicas
-type UpdateInstanceRequestPayloadGetReplicasArgType = Replicas
-type UpdateInstanceRequestPayloadGetReplicasRetType = Replicas
-
-func getUpdateInstanceRequestPayloadGetReplicasAttributeTypeOk(arg UpdateInstanceRequestPayloadGetReplicasAttributeType) (ret UpdateInstanceRequestPayloadGetReplicasRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetReplicasAttributeType(arg *UpdateInstanceRequestPayloadGetReplicasAttributeType, val UpdateInstanceRequestPayloadGetReplicasRetType) {
- *arg = &val
-}
-
-/*
- types and functions for retentionDays
-*/
-
-// isInteger
-type UpdateInstanceRequestPayloadGetRetentionDaysAttributeType = *int64
-type UpdateInstanceRequestPayloadGetRetentionDaysArgType = int64
-type UpdateInstanceRequestPayloadGetRetentionDaysRetType = int64
-
-func getUpdateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(arg UpdateInstanceRequestPayloadGetRetentionDaysAttributeType) (ret UpdateInstanceRequestPayloadGetRetentionDaysRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetRetentionDaysAttributeType(arg *UpdateInstanceRequestPayloadGetRetentionDaysAttributeType, val UpdateInstanceRequestPayloadGetRetentionDaysRetType) {
- *arg = &val
-}
-
-/*
- types and functions for storage
-*/
-
-// isModel
-type UpdateInstanceRequestPayloadGetStorageAttributeType = *StorageUpdate
-type UpdateInstanceRequestPayloadGetStorageArgType = StorageUpdate
-type UpdateInstanceRequestPayloadGetStorageRetType = StorageUpdate
-
-func getUpdateInstanceRequestPayloadGetStorageAttributeTypeOk(arg UpdateInstanceRequestPayloadGetStorageAttributeType) (ret UpdateInstanceRequestPayloadGetStorageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetStorageAttributeType(arg *UpdateInstanceRequestPayloadGetStorageAttributeType, val UpdateInstanceRequestPayloadGetStorageRetType) {
- *arg = &val
-}
-
-/*
- types and functions for version
-*/
-
-// isNotNullableString
-type UpdateInstanceRequestPayloadGetVersionAttributeType = *string
-
-func getUpdateInstanceRequestPayloadGetVersionAttributeTypeOk(arg UpdateInstanceRequestPayloadGetVersionAttributeType) (ret UpdateInstanceRequestPayloadGetVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetVersionAttributeType(arg *UpdateInstanceRequestPayloadGetVersionAttributeType, val UpdateInstanceRequestPayloadGetVersionRetType) {
- *arg = &val
-}
-
-type UpdateInstanceRequestPayloadGetVersionArgType = string
-type UpdateInstanceRequestPayloadGetVersionRetType = string
-
-// UpdateInstanceRequestPayload struct for UpdateInstanceRequestPayload
-type UpdateInstanceRequestPayload struct {
- // List of IPV4 cidr.
- // REQUIRED
- Acl UpdateInstanceRequestPayloadGetAclAttributeType `json:"acl" required:"true"`
- // The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.
- // REQUIRED
- BackupSchedule UpdateInstanceRequestPayloadGetBackupScheduleAttributeType `json:"backupSchedule" required:"true"`
- // The id of the instance flavor.
- // REQUIRED
- FlavorId UpdateInstanceRequestPayloadGetFlavorIdAttributeType `json:"flavorId" required:"true"`
- // The name of the instance.
- // REQUIRED
- Name UpdateInstanceRequestPayloadGetNameAttributeType `json:"name" required:"true"`
- // REQUIRED
- Replicas UpdateInstanceRequestPayloadGetReplicasAttributeType `json:"replicas" required:"true"`
- // How long backups are retained. The value can only be between 32 and 365 days.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- RetentionDays UpdateInstanceRequestPayloadGetRetentionDaysAttributeType `json:"retentionDays" required:"true"`
- // REQUIRED
- Storage UpdateInstanceRequestPayloadGetStorageAttributeType `json:"storage" required:"true"`
- // The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters.
- // REQUIRED
- Version UpdateInstanceRequestPayloadGetVersionAttributeType `json:"version" required:"true"`
-}
-
-type _UpdateInstanceRequestPayload UpdateInstanceRequestPayload
-
-// NewUpdateInstanceRequestPayload instantiates a new UpdateInstanceRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewUpdateInstanceRequestPayload(acl UpdateInstanceRequestPayloadGetAclArgType, backupSchedule UpdateInstanceRequestPayloadGetBackupScheduleArgType, flavorId UpdateInstanceRequestPayloadGetFlavorIdArgType, name UpdateInstanceRequestPayloadGetNameArgType, replicas UpdateInstanceRequestPayloadGetReplicasArgType, retentionDays UpdateInstanceRequestPayloadGetRetentionDaysArgType, storage UpdateInstanceRequestPayloadGetStorageArgType, version UpdateInstanceRequestPayloadGetVersionArgType) *UpdateInstanceRequestPayload {
- this := UpdateInstanceRequestPayload{}
- setUpdateInstanceRequestPayloadGetAclAttributeType(&this.Acl, acl)
- setUpdateInstanceRequestPayloadGetBackupScheduleAttributeType(&this.BackupSchedule, backupSchedule)
- setUpdateInstanceRequestPayloadGetFlavorIdAttributeType(&this.FlavorId, flavorId)
- setUpdateInstanceRequestPayloadGetNameAttributeType(&this.Name, name)
- setUpdateInstanceRequestPayloadGetReplicasAttributeType(&this.Replicas, replicas)
- setUpdateInstanceRequestPayloadGetRetentionDaysAttributeType(&this.RetentionDays, retentionDays)
- setUpdateInstanceRequestPayloadGetStorageAttributeType(&this.Storage, storage)
- setUpdateInstanceRequestPayloadGetVersionAttributeType(&this.Version, version)
- return &this
-}
-
-// NewUpdateInstanceRequestPayloadWithDefaults instantiates a new UpdateInstanceRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewUpdateInstanceRequestPayloadWithDefaults() *UpdateInstanceRequestPayload {
- this := UpdateInstanceRequestPayload{}
- return &this
-}
-
-// GetAcl returns the Acl field value
-func (o *UpdateInstanceRequestPayload) GetAcl() (ret UpdateInstanceRequestPayloadGetAclRetType) {
- ret, _ = o.GetAclOk()
- return ret
-}
-
-// GetAclOk returns a tuple with the Acl field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetAclOk() (ret UpdateInstanceRequestPayloadGetAclRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetAclAttributeTypeOk(o.Acl)
-}
-
-// SetAcl sets field value
-func (o *UpdateInstanceRequestPayload) SetAcl(v UpdateInstanceRequestPayloadGetAclRetType) {
- setUpdateInstanceRequestPayloadGetAclAttributeType(&o.Acl, v)
-}
-
-// GetBackupSchedule returns the BackupSchedule field value
-func (o *UpdateInstanceRequestPayload) GetBackupSchedule() (ret UpdateInstanceRequestPayloadGetBackupScheduleRetType) {
- ret, _ = o.GetBackupScheduleOk()
- return ret
-}
-
-// GetBackupScheduleOk returns a tuple with the BackupSchedule field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetBackupScheduleOk() (ret UpdateInstanceRequestPayloadGetBackupScheduleRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule)
-}
-
-// SetBackupSchedule sets field value
-func (o *UpdateInstanceRequestPayload) SetBackupSchedule(v UpdateInstanceRequestPayloadGetBackupScheduleRetType) {
- setUpdateInstanceRequestPayloadGetBackupScheduleAttributeType(&o.BackupSchedule, v)
-}
-
-// GetFlavorId returns the FlavorId field value
-func (o *UpdateInstanceRequestPayload) GetFlavorId() (ret UpdateInstanceRequestPayloadGetFlavorIdRetType) {
- ret, _ = o.GetFlavorIdOk()
- return ret
-}
-
-// GetFlavorIdOk returns a tuple with the FlavorId field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetFlavorIdOk() (ret UpdateInstanceRequestPayloadGetFlavorIdRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId)
-}
-
-// SetFlavorId sets field value
-func (o *UpdateInstanceRequestPayload) SetFlavorId(v UpdateInstanceRequestPayloadGetFlavorIdRetType) {
- setUpdateInstanceRequestPayloadGetFlavorIdAttributeType(&o.FlavorId, v)
-}
-
-// GetName returns the Name field value
-func (o *UpdateInstanceRequestPayload) GetName() (ret UpdateInstanceRequestPayloadGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetNameOk() (ret UpdateInstanceRequestPayloadGetNameRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *UpdateInstanceRequestPayload) SetName(v UpdateInstanceRequestPayloadGetNameRetType) {
- setUpdateInstanceRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetReplicas returns the Replicas field value
-func (o *UpdateInstanceRequestPayload) GetReplicas() (ret UpdateInstanceRequestPayloadGetReplicasRetType) {
- ret, _ = o.GetReplicasOk()
- return ret
-}
-
-// GetReplicasOk returns a tuple with the Replicas field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetReplicasOk() (ret UpdateInstanceRequestPayloadGetReplicasRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetReplicasAttributeTypeOk(o.Replicas)
-}
-
-// SetReplicas sets field value
-func (o *UpdateInstanceRequestPayload) SetReplicas(v UpdateInstanceRequestPayloadGetReplicasRetType) {
- setUpdateInstanceRequestPayloadGetReplicasAttributeType(&o.Replicas, v)
-}
-
-// GetRetentionDays returns the RetentionDays field value
-func (o *UpdateInstanceRequestPayload) GetRetentionDays() (ret UpdateInstanceRequestPayloadGetRetentionDaysRetType) {
- ret, _ = o.GetRetentionDaysOk()
- return ret
-}
-
-// GetRetentionDaysOk returns a tuple with the RetentionDays field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetRetentionDaysOk() (ret UpdateInstanceRequestPayloadGetRetentionDaysRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays)
-}
-
-// SetRetentionDays sets field value
-func (o *UpdateInstanceRequestPayload) SetRetentionDays(v UpdateInstanceRequestPayloadGetRetentionDaysRetType) {
- setUpdateInstanceRequestPayloadGetRetentionDaysAttributeType(&o.RetentionDays, v)
-}
-
-// GetStorage returns the Storage field value
-func (o *UpdateInstanceRequestPayload) GetStorage() (ret UpdateInstanceRequestPayloadGetStorageRetType) {
- ret, _ = o.GetStorageOk()
- return ret
-}
-
-// GetStorageOk returns a tuple with the Storage field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetStorageOk() (ret UpdateInstanceRequestPayloadGetStorageRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetStorageAttributeTypeOk(o.Storage)
-}
-
-// SetStorage sets field value
-func (o *UpdateInstanceRequestPayload) SetStorage(v UpdateInstanceRequestPayloadGetStorageRetType) {
- setUpdateInstanceRequestPayloadGetStorageAttributeType(&o.Storage, v)
-}
-
-// GetVersion returns the Version field value
-func (o *UpdateInstanceRequestPayload) GetVersion() (ret UpdateInstanceRequestPayloadGetVersionRetType) {
- ret, _ = o.GetVersionOk()
- return ret
-}
-
-// GetVersionOk returns a tuple with the Version field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetVersionOk() (ret UpdateInstanceRequestPayloadGetVersionRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetVersionAttributeTypeOk(o.Version)
-}
-
-// SetVersion sets field value
-func (o *UpdateInstanceRequestPayload) SetVersion(v UpdateInstanceRequestPayloadGetVersionRetType) {
- setUpdateInstanceRequestPayloadGetVersionAttributeType(&o.Version, v)
-}
-
-func (o UpdateInstanceRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getUpdateInstanceRequestPayloadGetAclAttributeTypeOk(o.Acl); ok {
- toSerialize["Acl"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule); ok {
- toSerialize["BackupSchedule"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId); ok {
- toSerialize["FlavorId"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetReplicasAttributeTypeOk(o.Replicas); ok {
- toSerialize["Replicas"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays); ok {
- toSerialize["RetentionDays"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetStorageAttributeTypeOk(o.Storage); ok {
- toSerialize["Storage"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetVersionAttributeTypeOk(o.Version); ok {
- toSerialize["Version"] = val
- }
- return toSerialize, nil
-}
-
-type NullableUpdateInstanceRequestPayload struct {
- value *UpdateInstanceRequestPayload
- isSet bool
-}
-
-func (v NullableUpdateInstanceRequestPayload) Get() *UpdateInstanceRequestPayload {
- return v.value
-}
-
-func (v *NullableUpdateInstanceRequestPayload) Set(val *UpdateInstanceRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUpdateInstanceRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUpdateInstanceRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUpdateInstanceRequestPayload(val *UpdateInstanceRequestPayload) *NullableUpdateInstanceRequestPayload {
- return &NullableUpdateInstanceRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableUpdateInstanceRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUpdateInstanceRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_update_instance_request_payload_test.go b/pkg/postgresflexalpha/model_update_instance_request_payload_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_update_instance_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_update_user_partially_request_payload.go b/pkg/postgresflexalpha/model_update_user_partially_request_payload.go
deleted file mode 100644
index 9edb2ee3..00000000
--- a/pkg/postgresflexalpha/model_update_user_partially_request_payload.go
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the UpdateUserPartiallyRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &UpdateUserPartiallyRequestPayload{}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type UpdateUserPartiallyRequestPayloadGetNameAttributeType = *string
-
-func getUpdateUserPartiallyRequestPayloadGetNameAttributeTypeOk(arg UpdateUserPartiallyRequestPayloadGetNameAttributeType) (ret UpdateUserPartiallyRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateUserPartiallyRequestPayloadGetNameAttributeType(arg *UpdateUserPartiallyRequestPayloadGetNameAttributeType, val UpdateUserPartiallyRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type UpdateUserPartiallyRequestPayloadGetNameArgType = string
-type UpdateUserPartiallyRequestPayloadGetNameRetType = string
-
-/*
- types and functions for roles
-*/
-
-// isArray
-type UpdateUserPartiallyRequestPayloadGetRolesAttributeType = *[]UserRole
-type UpdateUserPartiallyRequestPayloadGetRolesArgType = []UserRole
-type UpdateUserPartiallyRequestPayloadGetRolesRetType = []UserRole
-
-func getUpdateUserPartiallyRequestPayloadGetRolesAttributeTypeOk(arg UpdateUserPartiallyRequestPayloadGetRolesAttributeType) (ret UpdateUserPartiallyRequestPayloadGetRolesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateUserPartiallyRequestPayloadGetRolesAttributeType(arg *UpdateUserPartiallyRequestPayloadGetRolesAttributeType, val UpdateUserPartiallyRequestPayloadGetRolesRetType) {
- *arg = &val
-}
-
-// UpdateUserPartiallyRequestPayload struct for UpdateUserPartiallyRequestPayload
-type UpdateUserPartiallyRequestPayload struct {
- // The name of the user.
- Name UpdateUserPartiallyRequestPayloadGetNameAttributeType `json:"name,omitempty"`
- // A list containing the user roles for the instance.
- Roles UpdateUserPartiallyRequestPayloadGetRolesAttributeType `json:"roles,omitempty"`
-}
-
-// NewUpdateUserPartiallyRequestPayload instantiates a new UpdateUserPartiallyRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewUpdateUserPartiallyRequestPayload() *UpdateUserPartiallyRequestPayload {
- this := UpdateUserPartiallyRequestPayload{}
- return &this
-}
-
-// NewUpdateUserPartiallyRequestPayloadWithDefaults instantiates a new UpdateUserPartiallyRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewUpdateUserPartiallyRequestPayloadWithDefaults() *UpdateUserPartiallyRequestPayload {
- this := UpdateUserPartiallyRequestPayload{}
- return &this
-}
-
-// GetName returns the Name field value if set, zero value otherwise.
-func (o *UpdateUserPartiallyRequestPayload) GetName() (res UpdateUserPartiallyRequestPayloadGetNameRetType) {
- res, _ = o.GetNameOk()
- return
-}
-
-// GetNameOk returns a tuple with the Name field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateUserPartiallyRequestPayload) GetNameOk() (ret UpdateUserPartiallyRequestPayloadGetNameRetType, ok bool) {
- return getUpdateUserPartiallyRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// HasName returns a boolean if a field has been set.
-func (o *UpdateUserPartiallyRequestPayload) HasName() bool {
- _, ok := o.GetNameOk()
- return ok
-}
-
-// SetName gets a reference to the given string and assigns it to the Name field.
-func (o *UpdateUserPartiallyRequestPayload) SetName(v UpdateUserPartiallyRequestPayloadGetNameRetType) {
- setUpdateUserPartiallyRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetRoles returns the Roles field value if set, zero value otherwise.
-func (o *UpdateUserPartiallyRequestPayload) GetRoles() (res UpdateUserPartiallyRequestPayloadGetRolesRetType) {
- res, _ = o.GetRolesOk()
- return
-}
-
-// GetRolesOk returns a tuple with the Roles field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateUserPartiallyRequestPayload) GetRolesOk() (ret UpdateUserPartiallyRequestPayloadGetRolesRetType, ok bool) {
- return getUpdateUserPartiallyRequestPayloadGetRolesAttributeTypeOk(o.Roles)
-}
-
-// HasRoles returns a boolean if a field has been set.
-func (o *UpdateUserPartiallyRequestPayload) HasRoles() bool {
- _, ok := o.GetRolesOk()
- return ok
-}
-
-// SetRoles gets a reference to the given []UserRole and assigns it to the Roles field.
-func (o *UpdateUserPartiallyRequestPayload) SetRoles(v UpdateUserPartiallyRequestPayloadGetRolesRetType) {
- setUpdateUserPartiallyRequestPayloadGetRolesAttributeType(&o.Roles, v)
-}
-
-func (o UpdateUserPartiallyRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getUpdateUserPartiallyRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getUpdateUserPartiallyRequestPayloadGetRolesAttributeTypeOk(o.Roles); ok {
- toSerialize["Roles"] = val
- }
- return toSerialize, nil
-}
-
-type NullableUpdateUserPartiallyRequestPayload struct {
- value *UpdateUserPartiallyRequestPayload
- isSet bool
-}
-
-func (v NullableUpdateUserPartiallyRequestPayload) Get() *UpdateUserPartiallyRequestPayload {
- return v.value
-}
-
-func (v *NullableUpdateUserPartiallyRequestPayload) Set(val *UpdateUserPartiallyRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUpdateUserPartiallyRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUpdateUserPartiallyRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUpdateUserPartiallyRequestPayload(val *UpdateUserPartiallyRequestPayload) *NullableUpdateUserPartiallyRequestPayload {
- return &NullableUpdateUserPartiallyRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableUpdateUserPartiallyRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUpdateUserPartiallyRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_update_user_partially_request_payload_test.go b/pkg/postgresflexalpha/model_update_user_partially_request_payload_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_update_user_partially_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_update_user_request_payload.go b/pkg/postgresflexalpha/model_update_user_request_payload.go
deleted file mode 100644
index 5eeeb059..00000000
--- a/pkg/postgresflexalpha/model_update_user_request_payload.go
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the UpdateUserRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &UpdateUserRequestPayload{}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type UpdateUserRequestPayloadGetNameAttributeType = *string
-
-func getUpdateUserRequestPayloadGetNameAttributeTypeOk(arg UpdateUserRequestPayloadGetNameAttributeType) (ret UpdateUserRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateUserRequestPayloadGetNameAttributeType(arg *UpdateUserRequestPayloadGetNameAttributeType, val UpdateUserRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type UpdateUserRequestPayloadGetNameArgType = string
-type UpdateUserRequestPayloadGetNameRetType = string
-
-/*
- types and functions for roles
-*/
-
-// isArray
-type UpdateUserRequestPayloadGetRolesAttributeType = *[]UserRole
-type UpdateUserRequestPayloadGetRolesArgType = []UserRole
-type UpdateUserRequestPayloadGetRolesRetType = []UserRole
-
-func getUpdateUserRequestPayloadGetRolesAttributeTypeOk(arg UpdateUserRequestPayloadGetRolesAttributeType) (ret UpdateUserRequestPayloadGetRolesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateUserRequestPayloadGetRolesAttributeType(arg *UpdateUserRequestPayloadGetRolesAttributeType, val UpdateUserRequestPayloadGetRolesRetType) {
- *arg = &val
-}
-
-// UpdateUserRequestPayload struct for UpdateUserRequestPayload
-type UpdateUserRequestPayload struct {
- // The name of the user.
- Name UpdateUserRequestPayloadGetNameAttributeType `json:"name,omitempty"`
- // A list containing the user roles for the instance.
- // REQUIRED
- Roles UpdateUserRequestPayloadGetRolesAttributeType `json:"roles" required:"true"`
-}
-
-type _UpdateUserRequestPayload UpdateUserRequestPayload
-
-// NewUpdateUserRequestPayload instantiates a new UpdateUserRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewUpdateUserRequestPayload(roles UpdateUserRequestPayloadGetRolesArgType) *UpdateUserRequestPayload {
- this := UpdateUserRequestPayload{}
- setUpdateUserRequestPayloadGetRolesAttributeType(&this.Roles, roles)
- return &this
-}
-
-// NewUpdateUserRequestPayloadWithDefaults instantiates a new UpdateUserRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewUpdateUserRequestPayloadWithDefaults() *UpdateUserRequestPayload {
- this := UpdateUserRequestPayload{}
- return &this
-}
-
-// GetName returns the Name field value if set, zero value otherwise.
-func (o *UpdateUserRequestPayload) GetName() (res UpdateUserRequestPayloadGetNameRetType) {
- res, _ = o.GetNameOk()
- return
-}
-
-// GetNameOk returns a tuple with the Name field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateUserRequestPayload) GetNameOk() (ret UpdateUserRequestPayloadGetNameRetType, ok bool) {
- return getUpdateUserRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// HasName returns a boolean if a field has been set.
-func (o *UpdateUserRequestPayload) HasName() bool {
- _, ok := o.GetNameOk()
- return ok
-}
-
-// SetName gets a reference to the given string and assigns it to the Name field.
-func (o *UpdateUserRequestPayload) SetName(v UpdateUserRequestPayloadGetNameRetType) {
- setUpdateUserRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetRoles returns the Roles field value
-func (o *UpdateUserRequestPayload) GetRoles() (ret UpdateUserRequestPayloadGetRolesRetType) {
- ret, _ = o.GetRolesOk()
- return ret
-}
-
-// GetRolesOk returns a tuple with the Roles field value
-// and a boolean to check if the value has been set.
-func (o *UpdateUserRequestPayload) GetRolesOk() (ret UpdateUserRequestPayloadGetRolesRetType, ok bool) {
- return getUpdateUserRequestPayloadGetRolesAttributeTypeOk(o.Roles)
-}
-
-// SetRoles sets field value
-func (o *UpdateUserRequestPayload) SetRoles(v UpdateUserRequestPayloadGetRolesRetType) {
- setUpdateUserRequestPayloadGetRolesAttributeType(&o.Roles, v)
-}
-
-func (o UpdateUserRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getUpdateUserRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getUpdateUserRequestPayloadGetRolesAttributeTypeOk(o.Roles); ok {
- toSerialize["Roles"] = val
- }
- return toSerialize, nil
-}
-
-type NullableUpdateUserRequestPayload struct {
- value *UpdateUserRequestPayload
- isSet bool
-}
-
-func (v NullableUpdateUserRequestPayload) Get() *UpdateUserRequestPayload {
- return v.value
-}
-
-func (v *NullableUpdateUserRequestPayload) Set(val *UpdateUserRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUpdateUserRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUpdateUserRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUpdateUserRequestPayload(val *UpdateUserRequestPayload) *NullableUpdateUserRequestPayload {
- return &NullableUpdateUserRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableUpdateUserRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUpdateUserRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_update_user_request_payload_test.go b/pkg/postgresflexalpha/model_update_user_request_payload_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_update_user_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_user_role.go b/pkg/postgresflexalpha/model_user_role.go
deleted file mode 100644
index 4c5b2ba3..00000000
--- a/pkg/postgresflexalpha/model_user_role.go
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// UserRole The user role for the instance.
-type UserRole string
-
-// List of user.role
-const (
- USERROLE_CREATEDB UserRole = "createdb"
- USERROLE_LOGIN UserRole = "login"
- USERROLE_CREATEROLE UserRole = "createrole"
-)
-
-// All allowed values of UserRole enum
-var AllowedUserRoleEnumValues = []UserRole{
- "createdb",
- "login",
- "createrole",
-}
-
-func (v *UserRole) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := UserRole(value)
- for _, existing := range AllowedUserRoleEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid UserRole", value)
-}
-
-// NewUserRoleFromValue returns a pointer to a valid UserRole
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewUserRoleFromValue(v string) (*UserRole, error) {
- ev := UserRole(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for UserRole: valid values are %v", v, AllowedUserRoleEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v UserRole) IsValid() bool {
- for _, existing := range AllowedUserRoleEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to user.role value
-func (v UserRole) Ptr() *UserRole {
- return &v
-}
-
-type NullableUserRole struct {
- value *UserRole
- isSet bool
-}
-
-func (v NullableUserRole) Get() *UserRole {
- return v.value
-}
-
-func (v *NullableUserRole) Set(val *UserRole) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUserRole) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUserRole) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUserRole(val *UserRole) *NullableUserRole {
- return &NullableUserRole{value: val, isSet: true}
-}
-
-func (v NullableUserRole) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUserRole) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_user_role_test.go b/pkg/postgresflexalpha/model_user_role_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_user_role_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_user_sort.go b/pkg/postgresflexalpha/model_user_sort.go
deleted file mode 100644
index a47ae0d9..00000000
--- a/pkg/postgresflexalpha/model_user_sort.go
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// UserSort the model 'UserSort'
-type UserSort string
-
-// List of user.sort
-const (
- USERSORT_ID_ASC UserSort = "id.asc"
- USERSORT_ID_DESC UserSort = "id.desc"
- USERSORT_INDEX_DESC UserSort = "index.desc"
- USERSORT_INDEX_ASC UserSort = "index.asc"
- USERSORT_NAME_DESC UserSort = "name.desc"
- USERSORT_NAME_ASC UserSort = "name.asc"
- USERSORT_STATUS_DESC UserSort = "status.desc"
- USERSORT_STATUS_ASC UserSort = "status.asc"
-)
-
-// All allowed values of UserSort enum
-var AllowedUserSortEnumValues = []UserSort{
- "id.asc",
- "id.desc",
- "index.desc",
- "index.asc",
- "name.desc",
- "name.asc",
- "status.desc",
- "status.asc",
-}
-
-func (v *UserSort) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := UserSort(value)
- for _, existing := range AllowedUserSortEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid UserSort", value)
-}
-
-// NewUserSortFromValue returns a pointer to a valid UserSort
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewUserSortFromValue(v string) (*UserSort, error) {
- ev := UserSort(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for UserSort: valid values are %v", v, AllowedUserSortEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v UserSort) IsValid() bool {
- for _, existing := range AllowedUserSortEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to user.sort value
-func (v UserSort) Ptr() *UserSort {
- return &v
-}
-
-type NullableUserSort struct {
- value *UserSort
- isSet bool
-}
-
-func (v NullableUserSort) Get() *UserSort {
- return v.value
-}
-
-func (v *NullableUserSort) Set(val *UserSort) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUserSort) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUserSort) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUserSort(val *UserSort) *NullableUserSort {
- return &NullableUserSort{value: val, isSet: true}
-}
-
-func (v NullableUserSort) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUserSort) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_user_sort_test.go b/pkg/postgresflexalpha/model_user_sort_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_user_sort_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_validation_error.go b/pkg/postgresflexalpha/model_validation_error.go
deleted file mode 100644
index 0d708746..00000000
--- a/pkg/postgresflexalpha/model_validation_error.go
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ValidationError type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ValidationError{}
-
-/*
- types and functions for code
-*/
-
-// isInteger
-type ValidationErrorGetCodeAttributeType = *int64
-type ValidationErrorGetCodeArgType = int64
-type ValidationErrorGetCodeRetType = int64
-
-func getValidationErrorGetCodeAttributeTypeOk(arg ValidationErrorGetCodeAttributeType) (ret ValidationErrorGetCodeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setValidationErrorGetCodeAttributeType(arg *ValidationErrorGetCodeAttributeType, val ValidationErrorGetCodeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for validation
-*/
-
-// isArray
-type ValidationErrorGetValidationAttributeType = *[]ValidationErrorValidationInner
-type ValidationErrorGetValidationArgType = []ValidationErrorValidationInner
-type ValidationErrorGetValidationRetType = []ValidationErrorValidationInner
-
-func getValidationErrorGetValidationAttributeTypeOk(arg ValidationErrorGetValidationAttributeType) (ret ValidationErrorGetValidationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setValidationErrorGetValidationAttributeType(arg *ValidationErrorGetValidationAttributeType, val ValidationErrorGetValidationRetType) {
- *arg = &val
-}
-
-// ValidationError struct for ValidationError
-type ValidationError struct {
- // the http error should be always 422 for validationError
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- Code ValidationErrorGetCodeAttributeType `json:"code" required:"true"`
- // errors for all fields where the error happened
- // REQUIRED
- Validation ValidationErrorGetValidationAttributeType `json:"validation" required:"true"`
-}
-
-type _ValidationError ValidationError
-
-// NewValidationError instantiates a new ValidationError object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewValidationError(code ValidationErrorGetCodeArgType, validation ValidationErrorGetValidationArgType) *ValidationError {
- this := ValidationError{}
- setValidationErrorGetCodeAttributeType(&this.Code, code)
- setValidationErrorGetValidationAttributeType(&this.Validation, validation)
- return &this
-}
-
-// NewValidationErrorWithDefaults instantiates a new ValidationError object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewValidationErrorWithDefaults() *ValidationError {
- this := ValidationError{}
- return &this
-}
-
-// GetCode returns the Code field value
-func (o *ValidationError) GetCode() (ret ValidationErrorGetCodeRetType) {
- ret, _ = o.GetCodeOk()
- return ret
-}
-
-// GetCodeOk returns a tuple with the Code field value
-// and a boolean to check if the value has been set.
-func (o *ValidationError) GetCodeOk() (ret ValidationErrorGetCodeRetType, ok bool) {
- return getValidationErrorGetCodeAttributeTypeOk(o.Code)
-}
-
-// SetCode sets field value
-func (o *ValidationError) SetCode(v ValidationErrorGetCodeRetType) {
- setValidationErrorGetCodeAttributeType(&o.Code, v)
-}
-
-// GetValidation returns the Validation field value
-func (o *ValidationError) GetValidation() (ret ValidationErrorGetValidationRetType) {
- ret, _ = o.GetValidationOk()
- return ret
-}
-
-// GetValidationOk returns a tuple with the Validation field value
-// and a boolean to check if the value has been set.
-func (o *ValidationError) GetValidationOk() (ret ValidationErrorGetValidationRetType, ok bool) {
- return getValidationErrorGetValidationAttributeTypeOk(o.Validation)
-}
-
-// SetValidation sets field value
-func (o *ValidationError) SetValidation(v ValidationErrorGetValidationRetType) {
- setValidationErrorGetValidationAttributeType(&o.Validation, v)
-}
-
-func (o ValidationError) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getValidationErrorGetCodeAttributeTypeOk(o.Code); ok {
- toSerialize["Code"] = val
- }
- if val, ok := getValidationErrorGetValidationAttributeTypeOk(o.Validation); ok {
- toSerialize["Validation"] = val
- }
- return toSerialize, nil
-}
-
-type NullableValidationError struct {
- value *ValidationError
- isSet bool
-}
-
-func (v NullableValidationError) Get() *ValidationError {
- return v.value
-}
-
-func (v *NullableValidationError) Set(val *ValidationError) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableValidationError) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableValidationError) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableValidationError(val *ValidationError) *NullableValidationError {
- return &NullableValidationError{value: val, isSet: true}
-}
-
-func (v NullableValidationError) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableValidationError) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_validation_error_test.go b/pkg/postgresflexalpha/model_validation_error_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_validation_error_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_validation_error_validation_inner.go b/pkg/postgresflexalpha/model_validation_error_validation_inner.go
deleted file mode 100644
index cfb92ffc..00000000
--- a/pkg/postgresflexalpha/model_validation_error_validation_inner.go
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ValidationErrorValidationInner type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ValidationErrorValidationInner{}
-
-/*
- types and functions for field
-*/
-
-// isNotNullableString
-type ValidationErrorValidationInnerGetFieldAttributeType = *string
-
-func getValidationErrorValidationInnerGetFieldAttributeTypeOk(arg ValidationErrorValidationInnerGetFieldAttributeType) (ret ValidationErrorValidationInnerGetFieldRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setValidationErrorValidationInnerGetFieldAttributeType(arg *ValidationErrorValidationInnerGetFieldAttributeType, val ValidationErrorValidationInnerGetFieldRetType) {
- *arg = &val
-}
-
-type ValidationErrorValidationInnerGetFieldArgType = string
-type ValidationErrorValidationInnerGetFieldRetType = string
-
-/*
- types and functions for message
-*/
-
-// isNotNullableString
-type ValidationErrorValidationInnerGetMessageAttributeType = *string
-
-func getValidationErrorValidationInnerGetMessageAttributeTypeOk(arg ValidationErrorValidationInnerGetMessageAttributeType) (ret ValidationErrorValidationInnerGetMessageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setValidationErrorValidationInnerGetMessageAttributeType(arg *ValidationErrorValidationInnerGetMessageAttributeType, val ValidationErrorValidationInnerGetMessageRetType) {
- *arg = &val
-}
-
-type ValidationErrorValidationInnerGetMessageArgType = string
-type ValidationErrorValidationInnerGetMessageRetType = string
-
-// ValidationErrorValidationInner struct for ValidationErrorValidationInner
-type ValidationErrorValidationInner struct {
- // REQUIRED
- Field ValidationErrorValidationInnerGetFieldAttributeType `json:"field" required:"true"`
- // REQUIRED
- Message ValidationErrorValidationInnerGetMessageAttributeType `json:"message" required:"true"`
-}
-
-type _ValidationErrorValidationInner ValidationErrorValidationInner
-
-// NewValidationErrorValidationInner instantiates a new ValidationErrorValidationInner object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewValidationErrorValidationInner(field ValidationErrorValidationInnerGetFieldArgType, message ValidationErrorValidationInnerGetMessageArgType) *ValidationErrorValidationInner {
- this := ValidationErrorValidationInner{}
- setValidationErrorValidationInnerGetFieldAttributeType(&this.Field, field)
- setValidationErrorValidationInnerGetMessageAttributeType(&this.Message, message)
- return &this
-}
-
-// NewValidationErrorValidationInnerWithDefaults instantiates a new ValidationErrorValidationInner object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewValidationErrorValidationInnerWithDefaults() *ValidationErrorValidationInner {
- this := ValidationErrorValidationInner{}
- return &this
-}
-
-// GetField returns the Field field value
-func (o *ValidationErrorValidationInner) GetField() (ret ValidationErrorValidationInnerGetFieldRetType) {
- ret, _ = o.GetFieldOk()
- return ret
-}
-
-// GetFieldOk returns a tuple with the Field field value
-// and a boolean to check if the value has been set.
-func (o *ValidationErrorValidationInner) GetFieldOk() (ret ValidationErrorValidationInnerGetFieldRetType, ok bool) {
- return getValidationErrorValidationInnerGetFieldAttributeTypeOk(o.Field)
-}
-
-// SetField sets field value
-func (o *ValidationErrorValidationInner) SetField(v ValidationErrorValidationInnerGetFieldRetType) {
- setValidationErrorValidationInnerGetFieldAttributeType(&o.Field, v)
-}
-
-// GetMessage returns the Message field value
-func (o *ValidationErrorValidationInner) GetMessage() (ret ValidationErrorValidationInnerGetMessageRetType) {
- ret, _ = o.GetMessageOk()
- return ret
-}
-
-// GetMessageOk returns a tuple with the Message field value
-// and a boolean to check if the value has been set.
-func (o *ValidationErrorValidationInner) GetMessageOk() (ret ValidationErrorValidationInnerGetMessageRetType, ok bool) {
- return getValidationErrorValidationInnerGetMessageAttributeTypeOk(o.Message)
-}
-
-// SetMessage sets field value
-func (o *ValidationErrorValidationInner) SetMessage(v ValidationErrorValidationInnerGetMessageRetType) {
- setValidationErrorValidationInnerGetMessageAttributeType(&o.Message, v)
-}
-
-func (o ValidationErrorValidationInner) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getValidationErrorValidationInnerGetFieldAttributeTypeOk(o.Field); ok {
- toSerialize["Field"] = val
- }
- if val, ok := getValidationErrorValidationInnerGetMessageAttributeTypeOk(o.Message); ok {
- toSerialize["Message"] = val
- }
- return toSerialize, nil
-}
-
-type NullableValidationErrorValidationInner struct {
- value *ValidationErrorValidationInner
- isSet bool
-}
-
-func (v NullableValidationErrorValidationInner) Get() *ValidationErrorValidationInner {
- return v.value
-}
-
-func (v *NullableValidationErrorValidationInner) Set(val *ValidationErrorValidationInner) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableValidationErrorValidationInner) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableValidationErrorValidationInner) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableValidationErrorValidationInner(val *ValidationErrorValidationInner) *NullableValidationErrorValidationInner {
- return &NullableValidationErrorValidationInner{value: val, isSet: true}
-}
-
-func (v NullableValidationErrorValidationInner) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableValidationErrorValidationInner) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_validation_error_validation_inner_test.go b/pkg/postgresflexalpha/model_validation_error_validation_inner_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_validation_error_validation_inner_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/model_version.go b/pkg/postgresflexalpha/model_version.go
deleted file mode 100644
index d9c6f402..00000000
--- a/pkg/postgresflexalpha/model_version.go
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the Version type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &Version{}
-
-/*
- types and functions for beta
-*/
-
-// isBoolean
-type VersiongetBetaAttributeType = *bool
-type VersiongetBetaArgType = bool
-type VersiongetBetaRetType = bool
-
-func getVersiongetBetaAttributeTypeOk(arg VersiongetBetaAttributeType) (ret VersiongetBetaRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setVersiongetBetaAttributeType(arg *VersiongetBetaAttributeType, val VersiongetBetaRetType) {
- *arg = &val
-}
-
-/*
- types and functions for deprecated
-*/
-
-// isNotNullableString
-type VersionGetDeprecatedAttributeType = *string
-
-func getVersionGetDeprecatedAttributeTypeOk(arg VersionGetDeprecatedAttributeType) (ret VersionGetDeprecatedRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setVersionGetDeprecatedAttributeType(arg *VersionGetDeprecatedAttributeType, val VersionGetDeprecatedRetType) {
- *arg = &val
-}
-
-type VersionGetDeprecatedArgType = string
-type VersionGetDeprecatedRetType = string
-
-/*
- types and functions for recommend
-*/
-
-// isBoolean
-type VersiongetRecommendAttributeType = *bool
-type VersiongetRecommendArgType = bool
-type VersiongetRecommendRetType = bool
-
-func getVersiongetRecommendAttributeTypeOk(arg VersiongetRecommendAttributeType) (ret VersiongetRecommendRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setVersiongetRecommendAttributeType(arg *VersiongetRecommendAttributeType, val VersiongetRecommendRetType) {
- *arg = &val
-}
-
-/*
- types and functions for version
-*/
-
-// isNotNullableString
-type VersionGetVersionAttributeType = *string
-
-func getVersionGetVersionAttributeTypeOk(arg VersionGetVersionAttributeType) (ret VersionGetVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setVersionGetVersionAttributeType(arg *VersionGetVersionAttributeType, val VersionGetVersionRetType) {
- *arg = &val
-}
-
-type VersionGetVersionArgType = string
-type VersionGetVersionRetType = string
-
-// Version The version of the postgres instance and more details.
-type Version struct {
- // Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.
- // REQUIRED
- Beta VersiongetBetaAttributeType `json:"beta" required:"true"`
- // Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.
- // REQUIRED
- Deprecated VersionGetDeprecatedAttributeType `json:"deprecated" required:"true"`
- // Flag if the version is recommend by the STACKIT Team.
- // REQUIRED
- Recommend VersiongetRecommendAttributeType `json:"recommend" required:"true"`
- // The postgres version used for the instance.
- // REQUIRED
- Version VersionGetVersionAttributeType `json:"version" required:"true"`
-}
-
-type _Version Version
-
-// NewVersion instantiates a new Version object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewVersion(beta VersiongetBetaArgType, deprecated VersionGetDeprecatedArgType, recommend VersiongetRecommendArgType, version VersionGetVersionArgType) *Version {
- this := Version{}
- setVersiongetBetaAttributeType(&this.Beta, beta)
- setVersionGetDeprecatedAttributeType(&this.Deprecated, deprecated)
- setVersiongetRecommendAttributeType(&this.Recommend, recommend)
- setVersionGetVersionAttributeType(&this.Version, version)
- return &this
-}
-
-// NewVersionWithDefaults instantiates a new Version object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewVersionWithDefaults() *Version {
- this := Version{}
- return &this
-}
-
-// GetBeta returns the Beta field value
-func (o *Version) GetBeta() (ret VersiongetBetaRetType) {
- ret, _ = o.GetBetaOk()
- return ret
-}
-
-// GetBetaOk returns a tuple with the Beta field value
-// and a boolean to check if the value has been set.
-func (o *Version) GetBetaOk() (ret VersiongetBetaRetType, ok bool) {
- return getVersiongetBetaAttributeTypeOk(o.Beta)
-}
-
-// SetBeta sets field value
-func (o *Version) SetBeta(v VersiongetBetaRetType) {
- setVersiongetBetaAttributeType(&o.Beta, v)
-}
-
-// GetDeprecated returns the Deprecated field value
-func (o *Version) GetDeprecated() (ret VersionGetDeprecatedRetType) {
- ret, _ = o.GetDeprecatedOk()
- return ret
-}
-
-// GetDeprecatedOk returns a tuple with the Deprecated field value
-// and a boolean to check if the value has been set.
-func (o *Version) GetDeprecatedOk() (ret VersionGetDeprecatedRetType, ok bool) {
- return getVersionGetDeprecatedAttributeTypeOk(o.Deprecated)
-}
-
-// SetDeprecated sets field value
-func (o *Version) SetDeprecated(v VersionGetDeprecatedRetType) {
- setVersionGetDeprecatedAttributeType(&o.Deprecated, v)
-}
-
-// GetRecommend returns the Recommend field value
-func (o *Version) GetRecommend() (ret VersiongetRecommendRetType) {
- ret, _ = o.GetRecommendOk()
- return ret
-}
-
-// GetRecommendOk returns a tuple with the Recommend field value
-// and a boolean to check if the value has been set.
-func (o *Version) GetRecommendOk() (ret VersiongetRecommendRetType, ok bool) {
- return getVersiongetRecommendAttributeTypeOk(o.Recommend)
-}
-
-// SetRecommend sets field value
-func (o *Version) SetRecommend(v VersiongetRecommendRetType) {
- setVersiongetRecommendAttributeType(&o.Recommend, v)
-}
-
-// GetVersion returns the Version field value
-func (o *Version) GetVersion() (ret VersionGetVersionRetType) {
- ret, _ = o.GetVersionOk()
- return ret
-}
-
-// GetVersionOk returns a tuple with the Version field value
-// and a boolean to check if the value has been set.
-func (o *Version) GetVersionOk() (ret VersionGetVersionRetType, ok bool) {
- return getVersionGetVersionAttributeTypeOk(o.Version)
-}
-
-// SetVersion sets field value
-func (o *Version) SetVersion(v VersionGetVersionRetType) {
- setVersionGetVersionAttributeType(&o.Version, v)
-}
-
-func (o Version) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getVersiongetBetaAttributeTypeOk(o.Beta); ok {
- toSerialize["Beta"] = val
- }
- if val, ok := getVersionGetDeprecatedAttributeTypeOk(o.Deprecated); ok {
- toSerialize["Deprecated"] = val
- }
- if val, ok := getVersiongetRecommendAttributeTypeOk(o.Recommend); ok {
- toSerialize["Recommend"] = val
- }
- if val, ok := getVersionGetVersionAttributeTypeOk(o.Version); ok {
- toSerialize["Version"] = val
- }
- return toSerialize, nil
-}
-
-type NullableVersion struct {
- value *Version
- isSet bool
-}
-
-func (v NullableVersion) Get() *Version {
- return v.value
-}
-
-func (v *NullableVersion) Set(val *Version) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableVersion) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableVersion) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableVersion(val *Version) *NullableVersion {
- return &NullableVersion{value: val, isSet: true}
-}
-
-func (v NullableVersion) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableVersion) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/postgresflexalpha/model_version_test.go b/pkg/postgresflexalpha/model_version_test.go
deleted file mode 100644
index e1ff850e..00000000
--- a/pkg/postgresflexalpha/model_version_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
diff --git a/pkg/postgresflexalpha/utils.go b/pkg/postgresflexalpha/utils.go
deleted file mode 100644
index 0517a2ed..00000000
--- a/pkg/postgresflexalpha/utils.go
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
-PostgreSQL Flex API
-
-This is the documentation for the STACKIT Postgres Flex service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package postgresflexalpha
-
-import (
- "encoding/json"
- "math/rand"
- "reflect"
- "time"
-)
-
-// PtrBool is a helper routine that returns a pointer to given boolean value.
-func PtrBool(v bool) *bool { return &v }
-
-// PtrInt is a helper routine that returns a pointer to given integer value.
-func PtrInt(v int) *int { return &v }
-
-// PtrInt32 is a helper routine that returns a pointer to given integer value.
-func PtrInt32(v int32) *int32 { return &v }
-
-// PtrInt64 is a helper routine that returns a pointer to given integer value.
-func PtrInt64(v int64) *int64 { return &v }
-
-// PtrFloat32 is a helper routine that returns a pointer to given float value.
-func PtrFloat32(v float32) *float32 { return &v }
-
-// PtrFloat64 is a helper routine that returns a pointer to given float value.
-func PtrFloat64(v float64) *float64 { return &v }
-
-// PtrString is a helper routine that returns a pointer to given string value.
-func PtrString(v string) *string { return &v }
-
-// PtrTime is helper routine that returns a pointer to given Time value.
-func PtrTime(v time.Time) *time.Time { return &v }
-
-type NullableValue[T any] struct {
- value *T
- isSet bool
-}
-
-func (v NullableValue[T]) Get() *T {
- return v.value
-}
-
-func (v *NullableValue[T]) Set(val *T) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableValue[T]) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableValue[T]) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-type NullableBool struct {
- value *bool
- isSet bool
-}
-
-func (v NullableBool) Get() *bool {
- return v.value
-}
-
-func (v *NullableBool) Set(val *bool) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableBool) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableBool) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableBool(val *bool) *NullableBool {
- return &NullableBool{value: val, isSet: true}
-}
-
-func (v NullableBool) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableBool) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableInt struct {
- value *int
- isSet bool
-}
-
-func (v NullableInt) Get() *int {
- return v.value
-}
-
-func (v *NullableInt) Set(val *int) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInt) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInt) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInt(val *int) *NullableInt {
- return &NullableInt{value: val, isSet: true}
-}
-
-func (v NullableInt) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInt) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableInt32 struct {
- value *int32
- isSet bool
-}
-
-func (v NullableInt32) Get() *int32 {
- return v.value
-}
-
-func (v *NullableInt32) Set(val *int32) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInt32) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInt32) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInt32(val *int32) *NullableInt32 {
- return &NullableInt32{value: val, isSet: true}
-}
-
-func (v NullableInt32) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInt32) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableInt64 struct {
- value *int64
- isSet bool
-}
-
-func (v NullableInt64) Get() *int64 {
- return v.value
-}
-
-func (v *NullableInt64) Set(val *int64) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInt64) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInt64) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInt64(val *int64) *NullableInt64 {
- return &NullableInt64{value: val, isSet: true}
-}
-
-func (v NullableInt64) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInt64) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableFloat32 struct {
- value *float32
- isSet bool
-}
-
-func (v NullableFloat32) Get() *float32 {
- return v.value
-}
-
-func (v *NullableFloat32) Set(val *float32) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableFloat32) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableFloat32) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableFloat32(val *float32) *NullableFloat32 {
- return &NullableFloat32{value: val, isSet: true}
-}
-
-func (v NullableFloat32) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableFloat32) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableFloat64 struct {
- value *float64
- isSet bool
-}
-
-func (v NullableFloat64) Get() *float64 {
- return v.value
-}
-
-func (v *NullableFloat64) Set(val *float64) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableFloat64) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableFloat64) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableFloat64(val *float64) *NullableFloat64 {
- return &NullableFloat64{value: val, isSet: true}
-}
-
-func (v NullableFloat64) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableFloat64) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableString struct {
- value *string
- isSet bool
-}
-
-func (v NullableString) Get() *string {
- return v.value
-}
-
-func (v *NullableString) Set(val *string) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableString) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableString) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableString(val *string) *NullableString {
- return &NullableString{value: val, isSet: true}
-}
-
-func (v NullableString) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableString) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableTime struct {
- value *time.Time
- isSet bool
-}
-
-func (v NullableTime) Get() *time.Time {
- return v.value
-}
-
-func (v *NullableTime) Set(val *time.Time) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableTime) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableTime) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableTime(val *time.Time) *NullableTime {
- return &NullableTime{value: val, isSet: true}
-}
-
-func (v NullableTime) MarshalJSON() ([]byte, error) {
- return v.value.MarshalJSON()
-}
-
-func (v *NullableTime) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-// IsNil checks if an input is nil
-func IsNil(i interface{}) bool {
- if i == nil {
- return true
- }
- if t, ok := i.(interface{ IsSet() bool }); ok {
- return !t.IsSet()
- }
- switch reflect.TypeOf(i).Kind() {
- case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice:
- return reflect.ValueOf(i).IsNil()
- case reflect.Array:
- return reflect.ValueOf(i).IsZero()
- }
- return false
-}
-
-type MappedNullable interface {
- ToMap() (map[string]interface{}, error)
-}
-
-const letterRunes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-
-// randString returns a random string with a specified length. It panics if n <= 0.
-func randString(n int) string {
- b := make([]byte, n)
- for i := range b {
- b[i] = letterRunes[rand.Intn(len(letterRunes))]
- }
- return string(b)
-}
diff --git a/pkg/postgresflexalpha/wait/wait.go b/pkg/postgresflexalpha/wait/wait.go
deleted file mode 100644
index 283cb315..00000000
--- a/pkg/postgresflexalpha/wait/wait.go
+++ /dev/null
@@ -1,170 +0,0 @@
-package wait
-
-import (
- "context"
- "fmt"
- "time"
-
- postgresflex "github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha"
-
- "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
- "github.com/stackitcloud/stackit-sdk-go/core/wait"
-)
-
-const (
- InstanceStateEmpty = ""
- InstanceStateProgressing = "Progressing"
- InstanceStateSuccess = "Ready"
- InstanceStateFailed = "Failure"
- InstanceStateDeleted = "Deleted"
-)
-
-// Interface needed for tests
-type APIClientInstanceInterface interface {
- GetInstanceRequestExecute(ctx context.Context, projectId, region, instanceId string) (*postgresflex.GetInstanceResponse, error)
- ListUsersRequestExecute(ctx context.Context, projectId, region, instanceId string) (*postgresflex.ListUserResponse, error)
-}
-
-// Interface needed for tests
-type APIClientUserInterface interface {
- GetUserRequestExecute(ctx context.Context, projectId, region, instanceId string, userId int64) (*postgresflex.GetUserResponse, error)
-}
-
-// CreateInstanceWaitHandler will wait for instance creation
-func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, region, instanceId string) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse] {
- instanceCreated := false
- var instanceGetResponse *postgresflex.GetInstanceResponse
-
- handler := wait.New(func() (waitFinished bool, response *postgresflex.GetInstanceResponse, err error) {
- if !instanceCreated {
- s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
- if err != nil {
- return false, nil, err
- }
- if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
- return false, nil, nil
- }
- switch *s.Status {
- default:
- return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
- case InstanceStateEmpty:
- return false, nil, nil
- case InstanceStateProgressing:
- return false, nil, nil
- case InstanceStateSuccess:
- instanceCreated = true
- instanceGetResponse = s
- case InstanceStateFailed:
- return true, s, fmt.Errorf("create failed for instance with id %s", instanceId)
- }
- }
-
- // User operations aren't available right after an instance is deemed successful
- // To check if they are, perform a users request
- _, err = a.ListUsersRequestExecute(ctx, projectId, region, instanceId)
- if err == nil {
- return true, instanceGetResponse, nil
- }
- oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
- if !ok {
- return false, nil, err
- }
- if oapiErr.StatusCode < 500 {
- return true, instanceGetResponse, fmt.Errorf("users request after instance creation returned %d status code", oapiErr.StatusCode)
- }
- return false, nil, nil
- })
- // Sleep before wait is set because sometimes API returns 404 right after creation request
- handler.SetTimeout(45 * time.Minute).SetSleepBeforeWait(15 * time.Second)
- return handler
-}
-
-// PartialUpdateInstanceWaitHandler will wait for instance update
-func PartialUpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, region, instanceId string) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse] {
- handler := wait.New(func() (waitFinished bool, response *postgresflex.GetInstanceResponse, err error) {
- s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
- if err != nil {
- return false, nil, err
- }
- if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
- return false, nil, nil
- }
- switch *s.Status {
- default:
- return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
- case InstanceStateEmpty:
- return false, nil, nil
- case InstanceStateProgressing:
- return false, nil, nil
- case InstanceStateSuccess:
- return true, s, nil
- case InstanceStateFailed:
- return true, s, fmt.Errorf("update failed for instance with id %s", instanceId)
- }
- })
- handler.SetTimeout(45 * time.Minute)
- return handler
-}
-
-// DeleteInstanceWaitHandler will wait for instance deletion
-func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, region, instanceId string) *wait.AsyncActionHandler[struct{}] {
- handler := wait.New(func() (waitFinished bool, response *struct{}, err error) {
- s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
- if err != nil {
- return false, nil, err
- }
- if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
- return false, nil, nil
- }
- switch *s.Status {
- default:
- return true, nil, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
- case InstanceStateSuccess:
- return false, nil, nil
- case InstanceStateDeleted:
- return true, nil, nil
- }
- })
- handler.SetTimeout(5 * time.Minute)
- return handler
-}
-
-// ForceDeleteInstanceWaitHandler will wait for instance deletion
-func ForceDeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, region, instanceId string) *wait.AsyncActionHandler[struct{}] {
- handler := wait.New(func() (waitFinished bool, response *struct{}, err error) {
- _, err = a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
- if err == nil {
- return false, nil, nil
- }
- oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
- if !ok {
- return false, nil, err
- }
- if oapiErr.StatusCode != 404 {
- return false, nil, err
- }
- return true, nil, nil
- })
- handler.SetTimeout(15 * time.Minute)
- return handler
-}
-
-// DeleteUserWaitHandler will wait for delete
-func DeleteUserWaitHandler(ctx context.Context, a APIClientUserInterface, projectId, region, instanceId string, userId int64) *wait.AsyncActionHandler[struct{}] {
- handler := wait.New(func() (waitFinished bool, response *struct{}, err error) {
- _, err = a.GetUserRequestExecute(ctx, projectId, region, instanceId, userId)
- if err == nil {
- return false, nil, nil
- }
- oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
- if !ok {
- return false, nil, err
- }
- if oapiErr.StatusCode != 404 {
- return false, nil, err
- }
- return true, nil, nil
- })
- handler.SetTimeout(1 * time.Minute)
- return handler
-}
diff --git a/pkg/postgresflexalpha/wait/wait_test.go b/pkg/postgresflexalpha/wait/wait_test.go
deleted file mode 100644
index a0270001..00000000
--- a/pkg/postgresflexalpha/wait/wait_test.go
+++ /dev/null
@@ -1,389 +0,0 @@
-package wait
-
-import (
- "context"
- "testing"
- "time"
-
- "github.com/google/go-cmp/cmp"
- "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
- "github.com/stackitcloud/stackit-sdk-go/core/utils"
- postgresflex "github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha"
-)
-
-// Used for testing instance operations
-type apiClientInstanceMocked struct {
- instanceId string
- instanceState string
- instanceIsForceDeleted bool
- instanceGetFails bool
- usersGetErrorStatus int
-}
-
-func (a *apiClientInstanceMocked) GetInstanceRequestExecute(_ context.Context, _, _, _ string) (*postgresflex.GetInstanceResponse, error) {
- if a.instanceGetFails {
- return nil, &oapierror.GenericOpenAPIError{
- StatusCode: 500,
- }
- }
-
- if a.instanceIsForceDeleted {
- return nil, &oapierror.GenericOpenAPIError{
- StatusCode: 404,
- }
- }
-
- return &postgresflex.GetInstanceResponse{
- Id: &a.instanceId,
- Status: postgresflex.GetInstanceResponseGetStatusAttributeType(&a.instanceState),
- }, nil
-}
-
-func (a *apiClientInstanceMocked) ListUsersRequestExecute(_ context.Context, _, _, _ string) (*postgresflex.ListUserResponse, error) {
- if a.usersGetErrorStatus != 0 {
- return nil, &oapierror.GenericOpenAPIError{
- StatusCode: a.usersGetErrorStatus,
- }
- }
-
- aux := int64(0)
- return &postgresflex.ListUserResponse{
- Pagination: &postgresflex.Pagination{
- TotalRows: &aux,
- },
- Users: &[]postgresflex.ListUser{},
- }, nil
-}
-
-// Used for testing user operations
-type apiClientUserMocked struct {
- getFails bool
- userId int64
- isUserDeleted bool
-}
-
-func (a *apiClientUserMocked) GetUserRequestExecute(_ context.Context, _, _, _ string, _ int64) (*postgresflex.GetUserResponse, error) {
- if a.getFails {
- return nil, &oapierror.GenericOpenAPIError{
- StatusCode: 500,
- }
- }
-
- if a.isUserDeleted {
- return nil, &oapierror.GenericOpenAPIError{
- StatusCode: 404,
- }
- }
-
- return &postgresflex.GetUserResponse{
- Id: &a.userId,
- }, nil
-}
-
-func TestCreateInstanceWaitHandler(t *testing.T) {
- tests := []struct {
- desc string
- instanceGetFails bool
- instanceState string
- usersGetErrorStatus int
- wantErr bool
- wantResp bool
- }{
- {
- desc: "create_succeeded",
- instanceGetFails: false,
- instanceState: InstanceStateSuccess,
- wantErr: false,
- wantResp: true,
- },
- {
- desc: "create_failed",
- instanceGetFails: false,
- instanceState: InstanceStateFailed,
- wantErr: true,
- wantResp: true,
- },
- {
- desc: "create_failed_2",
- instanceGetFails: false,
- instanceState: InstanceStateEmpty,
- wantErr: true,
- wantResp: false,
- },
- {
- desc: "instance_get_fails",
- instanceGetFails: true,
- wantErr: true,
- wantResp: false,
- },
- {
- desc: "users_get_fails",
- instanceGetFails: false,
- instanceState: InstanceStateSuccess,
- usersGetErrorStatus: 500,
- wantErr: true,
- wantResp: false,
- },
- {
- desc: "users_get_fails_2",
- instanceGetFails: false,
- instanceState: InstanceStateSuccess,
- usersGetErrorStatus: 400,
- wantErr: true,
- wantResp: true,
- },
- {
- desc: "timeout",
- instanceGetFails: false,
- instanceState: InstanceStateProgressing,
- wantErr: true,
- wantResp: false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.desc, func(t *testing.T) {
- instanceId := "foo-bar"
-
- apiClient := &apiClientInstanceMocked{
- instanceId: instanceId,
- instanceState: tt.instanceState,
- instanceGetFails: tt.instanceGetFails,
- usersGetErrorStatus: tt.usersGetErrorStatus,
- }
-
- var wantRes *postgresflex.GetInstanceResponse
- if tt.wantResp {
- wantRes = &postgresflex.GetInstanceResponse{
- Id: &instanceId,
- Status: postgresflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(tt.instanceState)),
- }
- }
-
- handler := CreateInstanceWaitHandler(context.Background(), apiClient, "", "", instanceId)
-
- gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
-
- if (err != nil) != tt.wantErr {
- t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
- }
- if !cmp.Equal(gotRes, wantRes) {
- t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
- }
- })
- }
-}
-
-func TestUpdateInstanceWaitHandler(t *testing.T) {
- tests := []struct {
- desc string
- instanceGetFails bool
- instanceState string
- wantErr bool
- wantResp bool
- }{
- {
- desc: "update_succeeded",
- instanceGetFails: false,
- instanceState: InstanceStateSuccess,
- wantErr: false,
- wantResp: true,
- },
- {
- desc: "update_failed",
- instanceGetFails: false,
- instanceState: InstanceStateFailed,
- wantErr: true,
- wantResp: true,
- },
- {
- desc: "update_failed_2",
- instanceGetFails: false,
- instanceState: InstanceStateEmpty,
- wantErr: true,
- wantResp: false,
- },
- {
- desc: "get_fails",
- instanceGetFails: true,
- wantErr: true,
- wantResp: false,
- },
- {
- desc: "timeout",
- instanceGetFails: false,
- instanceState: InstanceStateProgressing,
- wantErr: true,
- wantResp: false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.desc, func(t *testing.T) {
- instanceId := "foo-bar"
-
- apiClient := &apiClientInstanceMocked{
- instanceId: instanceId,
- instanceState: tt.instanceState,
- instanceGetFails: tt.instanceGetFails,
- }
-
- var wantRes *postgresflex.GetInstanceResponse
- if tt.wantResp {
- wantRes = &postgresflex.GetInstanceResponse{
- Id: &instanceId,
- Status: postgresflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(tt.instanceState)),
- }
- }
-
- handler := PartialUpdateInstanceWaitHandler(context.Background(), apiClient, "", "", instanceId)
-
- gotRes, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
-
- if (err != nil) != tt.wantErr {
- t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
- }
- if !cmp.Equal(gotRes, wantRes) {
- t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
- }
- })
- }
-}
-
-func TestDeleteInstanceWaitHandler(t *testing.T) {
- tests := []struct {
- desc string
- instanceGetFails bool
- instanceState string
- wantErr bool
- }{
- {
- desc: "delete_succeeded",
- instanceGetFails: false,
- instanceState: InstanceStateDeleted,
- wantErr: false,
- },
- {
- desc: "delete_failed",
- instanceGetFails: false,
- instanceState: InstanceStateFailed,
- wantErr: true,
- },
- {
- desc: "get_fails",
- instanceGetFails: true,
- wantErr: true,
- },
- }
- for _, tt := range tests {
- t.Run(tt.desc, func(t *testing.T) {
- instanceId := "foo-bar"
-
- apiClient := &apiClientInstanceMocked{
- instanceGetFails: tt.instanceGetFails,
- instanceId: instanceId,
- instanceState: tt.instanceState,
- }
-
- handler := DeleteInstanceWaitHandler(context.Background(), apiClient, "", "", instanceId)
-
- _, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
-
- if (err != nil) != tt.wantErr {
- t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
-}
-
-func TestForceDeleteInstanceWaitHandler(t *testing.T) {
- tests := []struct {
- desc string
- instanceGetFails bool
- instanceState string
- wantErr bool
- }{
- {
- desc: "delete_succeeded",
- instanceGetFails: false,
- instanceState: InstanceStateDeleted,
- wantErr: false,
- },
- {
- desc: "delete_failed",
- instanceGetFails: false,
- instanceState: InstanceStateFailed,
- wantErr: true,
- },
- {
- desc: "get_fails",
- instanceGetFails: true,
- wantErr: true,
- },
- }
- for _, tt := range tests {
- t.Run(tt.desc, func(t *testing.T) {
- instanceId := "foo-bar"
-
- apiClient := &apiClientInstanceMocked{
- instanceGetFails: tt.instanceGetFails,
- instanceIsForceDeleted: tt.instanceState == InstanceStateDeleted,
- instanceId: instanceId,
- instanceState: tt.instanceState,
- }
-
- handler := ForceDeleteInstanceWaitHandler(context.Background(), apiClient, "", "", instanceId)
-
- _, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
-
- if (err != nil) != tt.wantErr {
- t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
-}
-
-func TestDeleteUserWaitHandler(t *testing.T) {
- tests := []struct {
- desc string
- deleteFails bool
- getFails bool
- wantErr bool
- }{
- {
- desc: "delete_succeeded",
- deleteFails: false,
- getFails: false,
- wantErr: false,
- },
- {
- desc: "delete_failed",
- deleteFails: true,
- getFails: false,
- wantErr: true,
- },
- {
- desc: "get_fails",
- deleteFails: false,
- getFails: true,
- wantErr: true,
- },
- }
- for _, tt := range tests {
- t.Run(tt.desc, func(t *testing.T) {
- userId := int64(1001)
-
- apiClient := &apiClientUserMocked{
- getFails: tt.getFails,
- userId: userId,
- isUserDeleted: !tt.deleteFails,
- }
-
- handler := DeleteUserWaitHandler(context.Background(), apiClient, "", "", "", userId)
-
- _, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
-
- if (err != nil) != tt.wantErr {
- t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
-}
diff --git a/pkg/sqlserverflexalpha/.openapi-generator/VERSION b/pkg/sqlserverflexalpha/.openapi-generator/VERSION
deleted file mode 100644
index cd802a1e..00000000
--- a/pkg/sqlserverflexalpha/.openapi-generator/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-6.6.0
\ No newline at end of file
diff --git a/pkg/sqlserverflexalpha/api_default.go b/pkg/sqlserverflexalpha/api_default.go
deleted file mode 100644
index 08774fd3..00000000
--- a/pkg/sqlserverflexalpha/api_default.go
+++ /dev/null
@@ -1,6176 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "bytes"
- "context"
- "fmt"
- "io"
- "net/http"
- "net/url"
- "strings"
-
- "github.com/stackitcloud/stackit-sdk-go/core/config"
- "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
-)
-
-type DefaultApi interface {
- /*
- CreateDatabaseRequest Create Database
- Create database for a user. Note: The name of a valid user must be provided in the 'options' map field using the key 'owner'
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiCreateDatabaseRequestRequest
- */
- CreateDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string) ApiCreateDatabaseRequestRequest
- /*
- CreateDatabaseRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return CreateDatabaseResponse
-
- */
- CreateDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*CreateDatabaseResponse, error)
- /*
- CreateInstanceRequest Create Instance
- Create a new instance of a sqlserver database instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiCreateInstanceRequestRequest
- */
- CreateInstanceRequest(ctx context.Context, projectId string, region string) ApiCreateInstanceRequestRequest
- /*
- CreateInstanceRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return CreateInstanceResponse
-
- */
- CreateInstanceRequestExecute(ctx context.Context, projectId string, region string) (*CreateInstanceResponse, error)
- /*
- CreateUserRequest Create User
- Create user for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiCreateUserRequestRequest
- */
- CreateUserRequest(ctx context.Context, projectId string, region string, instanceId string) ApiCreateUserRequestRequest
- /*
- CreateUserRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return CreateUserResponse
-
- */
- CreateUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*CreateUserResponse, error)
- /*
- DeleteDatabaseRequest Delete Database
- Delete database for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseName The name of the database.
- @return ApiDeleteDatabaseRequestRequest
- */
- DeleteDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string, databaseName string) ApiDeleteDatabaseRequestRequest
- /*
- DeleteDatabaseRequestExecute executes the request
-
- */
- DeleteDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseName string) error
- /*
- DeleteInstanceRequest Delete Instance
- Delete an available sqlserver instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiDeleteInstanceRequestRequest
- */
- DeleteInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiDeleteInstanceRequestRequest
- /*
- DeleteInstanceRequestExecute executes the request
-
- */
- DeleteInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error
- /*
- DeleteUserRequest Delete User
- Delete an user from a specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiDeleteUserRequestRequest
- */
- DeleteUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiDeleteUserRequestRequest
- /*
- DeleteUserRequestExecute executes the request
-
- */
- DeleteUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) error
- /*
- GetBackupRequest Get specific backup
- Get information about a specific backup for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param backupId The ID of the backup.
- @return ApiGetBackupRequestRequest
- */
- GetBackupRequest(ctx context.Context, projectId string, region string, instanceId string, backupId int64) ApiGetBackupRequestRequest
- /*
- GetBackupRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param backupId The ID of the backup.
- @return GetBackupResponse
-
- */
- GetBackupRequestExecute(ctx context.Context, projectId string, region string, instanceId string, backupId int64) (*GetBackupResponse, error)
- /*
- GetCollationsRequest Get database collation list
- Returns a list of collations for an instance
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiGetCollationsRequestRequest
- */
- GetCollationsRequest(ctx context.Context, projectId string, region string, instanceId string) ApiGetCollationsRequestRequest
- /*
- GetCollationsRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return GetCollationsResponse
-
- */
- GetCollationsRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*GetCollationsResponse, error)
- /*
- GetDatabaseRequest Get Database
- Get specific available database
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseName The name of the database.
- @return ApiGetDatabaseRequestRequest
- */
- GetDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string, databaseName string) ApiGetDatabaseRequestRequest
- /*
- GetDatabaseRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseName The name of the database.
- @return GetDatabaseResponse
-
- */
- GetDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseName string) (*GetDatabaseResponse, error)
- /*
- GetFlavorsRequest Get Flavors
- Get all available flavors for a project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiGetFlavorsRequestRequest
- */
- GetFlavorsRequest(ctx context.Context, projectId, region string, page, size *int64, sort FlavorSort) ApiGetFlavorsRequestRequest
- /*
- GetFlavorsRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return GetFlavorsResponse
-
- */
- GetFlavorsRequestExecute(ctx context.Context, projectId, region string, page, size *int64, sort FlavorSort) (*GetFlavorsResponse, error)
- /*
- GetInstanceRequest Get Specific Instance
- Get information about a specific available instance
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiGetInstanceRequestRequest
- */
- GetInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiGetInstanceRequestRequest
- /*
- GetInstanceRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return GetInstanceResponse
-
- */
- GetInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*GetInstanceResponse, error)
- /*
- GetStoragesRequest Get Storages
- Get available storages for a specific flavor
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param flavorId The id of an instance flavor.
- @return ApiGetStoragesRequestRequest
- */
- GetStoragesRequest(ctx context.Context, projectId string, region string, flavorId string) ApiGetStoragesRequestRequest
- /*
- GetStoragesRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param flavorId The id of an instance flavor.
- @return GetStoragesResponse
-
- */
- GetStoragesRequestExecute(ctx context.Context, projectId string, region string, flavorId string) (*GetStoragesResponse, error)
- /*
- GetUserRequest Get User
- Get a specific available user for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiGetUserRequestRequest
- */
- GetUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiGetUserRequestRequest
- /*
- GetUserRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return GetUserResponse
-
- */
- GetUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) (*GetUserResponse, error)
- /*
- GetVersionsRequest Get Versions
- Get the sqlserver available versions for the project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiGetVersionsRequestRequest
- */
- GetVersionsRequest(ctx context.Context, projectId string, region string) ApiGetVersionsRequestRequest
- /*
- GetVersionsRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return GetVersionsResponse
-
- */
- GetVersionsRequestExecute(ctx context.Context, projectId string, region string) (*GetVersionsResponse, error)
- /*
- ListBackupsRequest List backups
- List all backups which are available for a specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListBackupsRequestRequest
- */
- ListBackupsRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListBackupsRequestRequest
- /*
- ListBackupsRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ListBackupResponse
-
- */
- ListBackupsRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListBackupResponse, error)
- /*
- ListCompatibilitiesRequest Get database compatibility list
- Returns a list of compatibility levels for creating a new database
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListCompatibilitiesRequestRequest
- */
- ListCompatibilitiesRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListCompatibilitiesRequestRequest
- /*
- ListCompatibilitiesRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ListCompatibilityResponse
-
- */
- ListCompatibilitiesRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListCompatibilityResponse, error)
- /*
- ListCurrentRunningRestoreJobs List current running restore jobs
- List all currently running restore jobs which are available for a specific instance
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListCurrentRunningRestoreJobsRequest
- */
- ListCurrentRunningRestoreJobs(ctx context.Context, projectId string, region string, instanceId string) ApiListCurrentRunningRestoreJobsRequest
- /*
- ListCurrentRunningRestoreJobsExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ListCurrentRunningRestoreJobs
-
- */
- ListCurrentRunningRestoreJobsExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListCurrentRunningRestoreJobs, error)
- /*
- ListDatabasesRequest List Databases
- List available databases for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListDatabasesRequestRequest
- */
- ListDatabasesRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListDatabasesRequestRequest
- /*
- ListDatabasesRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ListDatabasesResponse
-
- */
- ListDatabasesRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListDatabasesResponse, error)
- /*
- ListInstancesRequest List Instances
- List all available instances for your project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiListInstancesRequestRequest
- */
- ListInstancesRequest(ctx context.Context, projectId string, region string) ApiListInstancesRequestRequest
- /*
- ListInstancesRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ListInstancesResponse
-
- */
- ListInstancesRequestExecute(ctx context.Context, projectId string, region string) (*ListInstancesResponse, error)
- /*
- ListRolesRequest List Roles
- List available roles for an instance that can be assigned to a user
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListRolesRequestRequest
- */
- ListRolesRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListRolesRequestRequest
- /*
- ListRolesRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ListRolesResponse
-
- */
- ListRolesRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListRolesResponse, error)
- /*
- ListUsersRequest List Users
- List available users for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListUsersRequestRequest
- */
- ListUsersRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListUsersRequestRequest
- /*
- ListUsersRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ListUserResponse
-
- */
- ListUsersRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListUserResponse, error)
- /*
- ProtectInstanceRequest Protect Instance
- Toggle the deletion protection for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiProtectInstanceRequestRequest
- */
- ProtectInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiProtectInstanceRequestRequest
- /*
- ProtectInstanceRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ProtectInstanceResponse
-
- */
- ProtectInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ProtectInstanceResponse, error)
- /*
- ResetUserRequest Reset User
- Reset an user from an specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiResetUserRequestRequest
- */
- ResetUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiResetUserRequestRequest
- /*
- ResetUserRequestExecute executes the request
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ResetUserResponse
-
- */
- ResetUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) (*ResetUserResponse, error)
- /*
- TriggerBackupRequest Trigger backup for a specific Database
- Trigger backup for a specific database
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseName The name of the database.
- @return ApiTriggerBackupRequestRequest
- */
- TriggerBackupRequest(ctx context.Context, projectId string, region string, instanceId string, databaseName string) ApiTriggerBackupRequestRequest
- /*
- TriggerBackupRequestExecute executes the request
-
- */
- TriggerBackupRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseName string) error
- /*
- TriggerRestoreRequest Trigger restore for a specific Database
- Trigger restore for a specific Database
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseName The name of the database.
- @return ApiTriggerRestoreRequestRequest
- */
- TriggerRestoreRequest(ctx context.Context, projectId string, region string, instanceId string, databaseName string) ApiTriggerRestoreRequestRequest
- /*
- TriggerRestoreRequestExecute executes the request
-
- */
- TriggerRestoreRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseName string) error
- /*
- UpdateInstancePartiallyRequest Update Instance Partially
- Update an available instance of a mssql database. No fields are required.
-
- **Please note that any changes applied via PUT or PATCH requests will initiate a reboot of the SQL Server Flex Instance.**
-
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiUpdateInstancePartiallyRequestRequest
- */
- UpdateInstancePartiallyRequest(ctx context.Context, projectId string, region string, instanceId string) ApiUpdateInstancePartiallyRequestRequest
- /*
- UpdateInstancePartiallyRequestExecute executes the request
-
- */
- UpdateInstancePartiallyRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error
- /*
- UpdateInstanceRequest Update Instance
- Updates an available instance of a sqlserver database
-
- **Please note that any changes applied via PUT or PATCH requests will initiate a reboot of the SQL Server Flex Instance.**
-
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiUpdateInstanceRequestRequest
- */
- UpdateInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiUpdateInstanceRequestRequest
- /*
- UpdateInstanceRequestExecute executes the request
-
- */
- UpdateInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error
-}
-
-type ApiCreateDatabaseRequestRequest interface {
- // The request body containing the information for the new database.
- CreateDatabaseRequestPayload(createDatabaseRequestPayload CreateDatabaseRequestPayload) ApiCreateDatabaseRequestRequest
- Execute() (*CreateDatabaseResponse, error)
-}
-
-type ApiCreateInstanceRequestRequest interface {
- // The request body with the parameters for the instance creation. Every parameter is required.
- CreateInstanceRequestPayload(createInstanceRequestPayload CreateInstanceRequestPayload) ApiCreateInstanceRequestRequest
- Execute() (*CreateInstanceResponse, error)
-}
-
-type ApiCreateUserRequestRequest interface {
- // The request body containing the user details.
- CreateUserRequestPayload(createUserRequestPayload CreateUserRequestPayload) ApiCreateUserRequestRequest
- Execute() (*CreateUserResponse, error)
-}
-
-type ApiDeleteDatabaseRequestRequest interface {
- Execute() error
-}
-
-type ApiDeleteInstanceRequestRequest interface {
- Execute() error
-}
-
-type ApiDeleteUserRequestRequest interface {
- Execute() error
-}
-
-type ApiGetBackupRequestRequest interface {
- Execute() (*GetBackupResponse, error)
-}
-
-type ApiGetCollationsRequestRequest interface {
- Execute() (*GetCollationsResponse, error)
-}
-
-type ApiGetDatabaseRequestRequest interface {
- Execute() (*GetDatabaseResponse, error)
-}
-
-type ApiGetFlavorsRequestRequest interface {
- // Number of the page of items list to be returned.
- Page(page int64) ApiGetFlavorsRequestRequest
- // Number of items to be returned on each page.
- Size(size int64) ApiGetFlavorsRequestRequest
- // Sorting of the flavors to be returned on each page.
- Sort(sort FlavorSort) ApiGetFlavorsRequestRequest
- Execute() (*GetFlavorsResponse, error)
-}
-
-type ApiGetInstanceRequestRequest interface {
- Execute() (*GetInstanceResponse, error)
-}
-
-type ApiGetStoragesRequestRequest interface {
- Execute() (*GetStoragesResponse, error)
-}
-
-type ApiGetUserRequestRequest interface {
- Execute() (*GetUserResponse, error)
-}
-
-type ApiGetVersionsRequestRequest interface {
- Execute() (*GetVersionsResponse, error)
-}
-
-type ApiListBackupsRequestRequest interface {
- // Number of the page of items list to be returned.
- Page(page int64) ApiListBackupsRequestRequest
- // Number of items to be returned on each page.
- Size(size int64) ApiListBackupsRequestRequest
- // Sorting of the backups to be returned on each page.
- Sort(sort BackupSort) ApiListBackupsRequestRequest
- Execute() (*ListBackupResponse, error)
-}
-
-type ApiListCompatibilitiesRequestRequest interface {
- Execute() (*ListCompatibilityResponse, error)
-}
-
-type ApiListCurrentRunningRestoreJobsRequest interface {
- Execute() (*ListCurrentRunningRestoreJobs, error)
-}
-
-type ApiListDatabasesRequestRequest interface {
- // Number of the page of items list to be returned.
- Page(page int64) ApiListDatabasesRequestRequest
- // Number of items to be returned on each page.
- Size(size int64) ApiListDatabasesRequestRequest
- // Sorting of the databases to be returned on each page.
- Sort(sort DatabaseSort) ApiListDatabasesRequestRequest
- Execute() (*ListDatabasesResponse, error)
-}
-
-type ApiListInstancesRequestRequest interface {
- // Number of the page of items list to be returned.
- Page(page int64) ApiListInstancesRequestRequest
- // Number of items to be returned on each page.
- Size(size int64) ApiListInstancesRequestRequest
- // Sorting of the items to be returned on each page.
- Sort(sort InstanceSort) ApiListInstancesRequestRequest
- Execute() (*ListInstancesResponse, error)
-}
-
-type ApiListRolesRequestRequest interface {
- Execute() (*ListRolesResponse, error)
-}
-
-type ApiListUsersRequestRequest interface {
- // Number of the page of items list to be returned.
- Page(page int64) ApiListUsersRequestRequest
- // Number of items to be returned on each page.
- Size(size int64) ApiListUsersRequestRequest
- // Sorting of the users to be returned on each page.
- Sort(sort UserSort) ApiListUsersRequestRequest
- Execute() (*ListUserResponse, error)
-}
-
-type ApiProtectInstanceRequestRequest interface {
- // The request body with flag isDeletable. Parameter is required.
- ProtectInstanceRequestPayload(protectInstanceRequestPayload ProtectInstanceRequestPayload) ApiProtectInstanceRequestRequest
- Execute() (*ProtectInstanceResponse, error)
-}
-
-type ApiResetUserRequestRequest interface {
- Execute() (*ResetUserResponse, error)
-}
-
-type ApiTriggerBackupRequestRequest interface {
- Execute() error
-}
-
-type ApiTriggerRestoreRequestRequest interface {
- // The request body with the parameters for the database restore.
- TriggerRestoreRequestPayload(triggerRestoreRequestPayload TriggerRestoreRequestPayload) ApiTriggerRestoreRequestRequest
- Execute() error
-}
-
-type ApiUpdateInstancePartiallyRequestRequest interface {
- // The request body with the parameters for updating the instance.
- UpdateInstancePartiallyRequestPayload(updateInstancePartiallyRequestPayload UpdateInstancePartiallyRequestPayload) ApiUpdateInstancePartiallyRequestRequest
- Execute() error
-}
-
-type ApiUpdateInstanceRequestRequest interface {
- // The request body with the parameters for updating the instance
- UpdateInstanceRequestPayload(updateInstanceRequestPayload UpdateInstanceRequestPayload) ApiUpdateInstanceRequestRequest
- Execute() error
-}
-
-// DefaultApiService DefaultApi service
-type DefaultApiService service
-
-type CreateDatabaseRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- createDatabaseRequestPayload *CreateDatabaseRequestPayload
-}
-
-// The request body containing the information for the new database.
-
-func (r CreateDatabaseRequestRequest) CreateDatabaseRequestPayload(createDatabaseRequestPayload CreateDatabaseRequestPayload) ApiCreateDatabaseRequestRequest {
- r.createDatabaseRequestPayload = &createDatabaseRequestPayload
- return r
-}
-
-func (r CreateDatabaseRequestRequest) Execute() (*CreateDatabaseResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *CreateDatabaseResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateDatabaseRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.createDatabaseRequestPayload == nil {
- return localVarReturnValue, fmt.Errorf("createDatabaseRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.createDatabaseRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-CreateDatabaseRequest: Create Database
-
-Create database for a user. Note: The name of a valid user must be provided in the 'options' map field using the key 'owner'
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiCreateDatabaseRequestRequest
-*/
-func (a *APIClient) CreateDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string) ApiCreateDatabaseRequestRequest {
- return CreateDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) CreateDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*CreateDatabaseResponse, error) {
- r := CreateDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type CreateInstanceRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- createInstanceRequestPayload *CreateInstanceRequestPayload
-}
-
-// The request body with the parameters for the instance creation. Every parameter is required.
-
-func (r CreateInstanceRequestRequest) CreateInstanceRequestPayload(createInstanceRequestPayload CreateInstanceRequestPayload) ApiCreateInstanceRequestRequest {
- r.createInstanceRequestPayload = &createInstanceRequestPayload
- return r
-}
-
-func (r CreateInstanceRequestRequest) Execute() (*CreateInstanceResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *CreateInstanceResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateInstanceRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.createInstanceRequestPayload == nil {
- return localVarReturnValue, fmt.Errorf("createInstanceRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.createInstanceRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-CreateInstanceRequest: Create Instance
-
-Create a new instance of a sqlserver database instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiCreateInstanceRequestRequest
-*/
-func (a *APIClient) CreateInstanceRequest(ctx context.Context, projectId string, region string) ApiCreateInstanceRequestRequest {
- return CreateInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
-}
-
-func (a *APIClient) CreateInstanceRequestExecute(ctx context.Context, projectId string, region string) (*CreateInstanceResponse, error) {
- r := CreateInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
- return r.Execute()
-}
-
-type CreateUserRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- createUserRequestPayload *CreateUserRequestPayload
-}
-
-// The request body containing the user details.
-
-func (r CreateUserRequestRequest) CreateUserRequestPayload(createUserRequestPayload CreateUserRequestPayload) ApiCreateUserRequestRequest {
- r.createUserRequestPayload = &createUserRequestPayload
- return r
-}
-
-func (r CreateUserRequestRequest) Execute() (*CreateUserResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *CreateUserResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateUserRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.createUserRequestPayload == nil {
- return localVarReturnValue, fmt.Errorf("createUserRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.createUserRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-CreateUserRequest: Create User
-
-Create user for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiCreateUserRequestRequest
-*/
-func (a *APIClient) CreateUserRequest(ctx context.Context, projectId string, region string, instanceId string) ApiCreateUserRequestRequest {
- return CreateUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) CreateUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*CreateUserResponse, error) {
- r := CreateUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type DeleteDatabaseRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- databaseName string
-}
-
-func (r DeleteDatabaseRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodDelete
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteDatabaseRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(r.databaseName, "databaseName")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-DeleteDatabaseRequest: Delete Database
-
-Delete database for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseName The name of the database.
- @return ApiDeleteDatabaseRequestRequest
-*/
-func (a *APIClient) DeleteDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string, databaseName string) ApiDeleteDatabaseRequestRequest {
- return DeleteDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseName: databaseName,
- }
-}
-
-func (a *APIClient) DeleteDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseName string) error {
- r := DeleteDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseName: databaseName,
- }
- return r.Execute()
-}
-
-type DeleteInstanceRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
-}
-
-func (r DeleteInstanceRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodDelete
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteInstanceRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-DeleteInstanceRequest: Delete Instance
-
-Delete an available sqlserver instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiDeleteInstanceRequestRequest
-*/
-func (a *APIClient) DeleteInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiDeleteInstanceRequestRequest {
- return DeleteInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) DeleteInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error {
- r := DeleteInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type DeleteUserRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- userId int64
-}
-
-func (r DeleteUserRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodDelete
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteUserRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(r.userId, "userId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-DeleteUserRequest: Delete User
-
-Delete an user from a specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiDeleteUserRequestRequest
-*/
-func (a *APIClient) DeleteUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiDeleteUserRequestRequest {
- return DeleteUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
-}
-
-func (a *APIClient) DeleteUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) error {
- r := DeleteUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
- return r.Execute()
-}
-
-type GetBackupRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- backupId int64
-}
-
-func (r GetBackupRequestRequest) Execute() (*GetBackupResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetBackupResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetBackupRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/{backupId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"backupId"+"}", url.PathEscape(ParameterValueToString(r.backupId, "backupId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetBackupRequest: Get specific backup
-
-Get information about a specific backup for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param backupId The ID of the backup.
- @return ApiGetBackupRequestRequest
-*/
-func (a *APIClient) GetBackupRequest(ctx context.Context, projectId string, region string, instanceId string, backupId int64) ApiGetBackupRequestRequest {
- return GetBackupRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- backupId: backupId,
- }
-}
-
-func (a *APIClient) GetBackupRequestExecute(ctx context.Context, projectId string, region string, instanceId string, backupId int64) (*GetBackupResponse, error) {
- r := GetBackupRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- backupId: backupId,
- }
- return r.Execute()
-}
-
-type GetCollationsRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
-}
-
-func (r GetCollationsRequestRequest) Execute() (*GetCollationsResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetCollationsResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetCollationsRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/collations"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetCollationsRequest: Get database collation list
-
-Returns a list of collations for an instance
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiGetCollationsRequestRequest
-*/
-func (a *APIClient) GetCollationsRequest(ctx context.Context, projectId string, region string, instanceId string) ApiGetCollationsRequestRequest {
- return GetCollationsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) GetCollationsRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*GetCollationsResponse, error) {
- r := GetCollationsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type GetDatabaseRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- databaseName string
-}
-
-func (r GetDatabaseRequestRequest) Execute() (*GetDatabaseResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetDatabaseResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetDatabaseRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(r.databaseName, "databaseName")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetDatabaseRequest: Get Database
-
-Get specific available database
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseName The name of the database.
- @return ApiGetDatabaseRequestRequest
-*/
-func (a *APIClient) GetDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string, databaseName string) ApiGetDatabaseRequestRequest {
- return GetDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseName: databaseName,
- }
-}
-
-func (a *APIClient) GetDatabaseRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseName string) (*GetDatabaseResponse, error) {
- r := GetDatabaseRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseName: databaseName,
- }
- return r.Execute()
-}
-
-type GetFlavorsRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- page *int64
- size *int64
- sort *FlavorSort
-}
-
-// Number of the page of items list to be returned.
-
-func (r GetFlavorsRequestRequest) Page(page int64) ApiGetFlavorsRequestRequest {
- r.page = &page
- return r
-}
-
-// Number of items to be returned on each page.
-
-func (r GetFlavorsRequestRequest) Size(size int64) ApiGetFlavorsRequestRequest {
- r.size = &size
- return r
-}
-
-// Sorting of the flavors to be returned on each page.
-
-func (r GetFlavorsRequestRequest) Sort(sort FlavorSort) ApiGetFlavorsRequestRequest {
- r.sort = &sort
- return r
-}
-
-func (r GetFlavorsRequestRequest) Execute() (*GetFlavorsResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetFlavorsResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetFlavorsRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/flavors"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- if r.page != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "")
- }
- if r.size != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "size", r.size, "")
- }
- if r.sort != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "")
- }
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetFlavorsRequest: Get Flavors
-
-Get all available flavors for a project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiGetFlavorsRequestRequest
-*/
-func (a *APIClient) GetFlavorsRequest(ctx context.Context, projectId, region string, page, size *int64, sort FlavorSort) ApiGetFlavorsRequestRequest {
- return GetFlavorsRequestRequest{
- ctx: ctx,
- apiService: a.defaultApi,
- projectId: projectId,
- region: region,
- page: page,
- size: size,
- sort: &sort,
- }
-}
-
-func (a *APIClient) GetFlavorsRequestExecute(ctx context.Context, projectId, region string, page, size *int64, sort FlavorSort) (*GetFlavorsResponse, error) {
- r := GetFlavorsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- page: page,
- size: size,
- sort: &sort,
- }
- return r.Execute()
-}
-
-type GetInstanceRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
-}
-
-func (r GetInstanceRequestRequest) Execute() (*GetInstanceResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetInstanceResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetInstanceRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetInstanceRequest: Get Specific Instance
-
-Get information about a specific available instance
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiGetInstanceRequestRequest
-*/
-func (a *APIClient) GetInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiGetInstanceRequestRequest {
- return GetInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) GetInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*GetInstanceResponse, error) {
- r := GetInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type GetStoragesRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- flavorId string
-}
-
-func (r GetStoragesRequestRequest) Execute() (*GetStoragesResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetStoragesResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetStoragesRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/storages/{flavorId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"flavorId"+"}", url.PathEscape(ParameterValueToString(r.flavorId, "flavorId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetStoragesRequest: Get Storages
-
-Get available storages for a specific flavor
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param flavorId The id of an instance flavor.
- @return ApiGetStoragesRequestRequest
-*/
-func (a *APIClient) GetStoragesRequest(ctx context.Context, projectId string, region string, flavorId string) ApiGetStoragesRequestRequest {
- return GetStoragesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- flavorId: flavorId,
- }
-}
-
-func (a *APIClient) GetStoragesRequestExecute(ctx context.Context, projectId string, region string, flavorId string) (*GetStoragesResponse, error) {
- r := GetStoragesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- flavorId: flavorId,
- }
- return r.Execute()
-}
-
-type GetUserRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- userId int64
-}
-
-func (r GetUserRequestRequest) Execute() (*GetUserResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetUserResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetUserRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(r.userId, "userId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetUserRequest: Get User
-
-Get a specific available user for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiGetUserRequestRequest
-*/
-func (a *APIClient) GetUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiGetUserRequestRequest {
- return GetUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
-}
-
-func (a *APIClient) GetUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) (*GetUserResponse, error) {
- r := GetUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
- return r.Execute()
-}
-
-type GetVersionsRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
-}
-
-func (r GetVersionsRequestRequest) Execute() (*GetVersionsResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *GetVersionsResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetVersionsRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/versions"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-GetVersionsRequest: Get Versions
-
-Get the sqlserver available versions for the project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiGetVersionsRequestRequest
-*/
-func (a *APIClient) GetVersionsRequest(ctx context.Context, projectId string, region string) ApiGetVersionsRequestRequest {
- return GetVersionsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
-}
-
-func (a *APIClient) GetVersionsRequestExecute(ctx context.Context, projectId string, region string) (*GetVersionsResponse, error) {
- r := GetVersionsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
- return r.Execute()
-}
-
-type ListBackupsRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- page *int64
- size *int64
- sort *BackupSort
-}
-
-// Number of the page of items list to be returned.
-
-func (r ListBackupsRequestRequest) Page(page int64) ApiListBackupsRequestRequest {
- r.page = &page
- return r
-}
-
-// Number of items to be returned on each page.
-
-func (r ListBackupsRequestRequest) Size(size int64) ApiListBackupsRequestRequest {
- r.size = &size
- return r
-}
-
-// Sorting of the backups to be returned on each page.
-
-func (r ListBackupsRequestRequest) Sort(sort BackupSort) ApiListBackupsRequestRequest {
- r.sort = &sort
- return r
-}
-
-func (r ListBackupsRequestRequest) Execute() (*ListBackupResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListBackupResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListBackupsRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- if r.page != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "")
- }
- if r.size != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "size", r.size, "")
- }
- if r.sort != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "")
- }
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListBackupsRequest: List backups
-
-List all backups which are available for a specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListBackupsRequestRequest
-*/
-func (a *APIClient) ListBackupsRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListBackupsRequestRequest {
- return ListBackupsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ListBackupsRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListBackupResponse, error) {
- r := ListBackupsRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ListCompatibilitiesRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
-}
-
-func (r ListCompatibilitiesRequestRequest) Execute() (*ListCompatibilityResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListCompatibilityResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListCompatibilitiesRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/compatibility"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListCompatibilitiesRequest: Get database compatibility list
-
-Returns a list of compatibility levels for creating a new database
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListCompatibilitiesRequestRequest
-*/
-func (a *APIClient) ListCompatibilitiesRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListCompatibilitiesRequestRequest {
- return ListCompatibilitiesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ListCompatibilitiesRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListCompatibilityResponse, error) {
- r := ListCompatibilitiesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ListCurrentRunningRestoreJobsRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
-}
-
-func (r ListCurrentRunningRestoreJobsRequest) Execute() (*ListCurrentRunningRestoreJobs, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListCurrentRunningRestoreJobs
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListCurrentRunningRestoreJobs")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/restore-jobs"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListCurrentRunningRestoreJobs: List current running restore jobs
-
-List all currently running restore jobs which are available for a specific instance
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListCurrentRunningRestoreJobsRequest
-*/
-func (a *APIClient) ListCurrentRunningRestoreJobs(ctx context.Context, projectId string, region string, instanceId string) ApiListCurrentRunningRestoreJobsRequest {
- return ListCurrentRunningRestoreJobsRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ListCurrentRunningRestoreJobsExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListCurrentRunningRestoreJobs, error) {
- r := ListCurrentRunningRestoreJobsRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ListDatabasesRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- page *int64
- size *int64
- sort *DatabaseSort
-}
-
-// Number of the page of items list to be returned.
-
-func (r ListDatabasesRequestRequest) Page(page int64) ApiListDatabasesRequestRequest {
- r.page = &page
- return r
-}
-
-// Number of items to be returned on each page.
-
-func (r ListDatabasesRequestRequest) Size(size int64) ApiListDatabasesRequestRequest {
- r.size = &size
- return r
-}
-
-// Sorting of the databases to be returned on each page.
-
-func (r ListDatabasesRequestRequest) Sort(sort DatabaseSort) ApiListDatabasesRequestRequest {
- r.sort = &sort
- return r
-}
-
-func (r ListDatabasesRequestRequest) Execute() (*ListDatabasesResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListDatabasesResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListDatabasesRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- if r.page != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "")
- }
- if r.size != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "size", r.size, "")
- }
- if r.sort != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "")
- }
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListDatabasesRequest: List Databases
-
-List available databases for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListDatabasesRequestRequest
-*/
-func (a *APIClient) ListDatabasesRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListDatabasesRequestRequest {
- return ListDatabasesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ListDatabasesRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListDatabasesResponse, error) {
- r := ListDatabasesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ListInstancesRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- page *int64
- size *int64
- sort *InstanceSort
-}
-
-// Number of the page of items list to be returned.
-
-func (r ListInstancesRequestRequest) Page(page int64) ApiListInstancesRequestRequest {
- r.page = &page
- return r
-}
-
-// Number of items to be returned on each page.
-
-func (r ListInstancesRequestRequest) Size(size int64) ApiListInstancesRequestRequest {
- r.size = &size
- return r
-}
-
-// Sorting of the items to be returned on each page.
-
-func (r ListInstancesRequestRequest) Sort(sort InstanceSort) ApiListInstancesRequestRequest {
- r.sort = &sort
- return r
-}
-
-func (r ListInstancesRequestRequest) Execute() (*ListInstancesResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListInstancesResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListInstancesRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- if r.page != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "")
- }
- if r.size != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "size", r.size, "")
- }
- if r.sort != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "")
- }
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListInstancesRequest: List Instances
-
-List all available instances for your project.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @return ApiListInstancesRequestRequest
-*/
-func (a *APIClient) ListInstancesRequest(ctx context.Context, projectId string, region string) ApiListInstancesRequestRequest {
- return ListInstancesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
-}
-
-func (a *APIClient) ListInstancesRequestExecute(ctx context.Context, projectId string, region string) (*ListInstancesResponse, error) {
- r := ListInstancesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- }
- return r.Execute()
-}
-
-type ListRolesRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
-}
-
-func (r ListRolesRequestRequest) Execute() (*ListRolesResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListRolesResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListRolesRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/roles"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListRolesRequest: List Roles
-
-List available roles for an instance that can be assigned to a user
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListRolesRequestRequest
-*/
-func (a *APIClient) ListRolesRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListRolesRequestRequest {
- return ListRolesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ListRolesRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListRolesResponse, error) {
- r := ListRolesRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ListUsersRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- page *int64
- size *int64
- sort *UserSort
-}
-
-// Number of the page of items list to be returned.
-
-func (r ListUsersRequestRequest) Page(page int64) ApiListUsersRequestRequest {
- r.page = &page
- return r
-}
-
-// Number of items to be returned on each page.
-
-func (r ListUsersRequestRequest) Size(size int64) ApiListUsersRequestRequest {
- r.size = &size
- return r
-}
-
-// Sorting of the users to be returned on each page.
-
-func (r ListUsersRequestRequest) Sort(sort UserSort) ApiListUsersRequestRequest {
- r.sort = &sort
- return r
-}
-
-func (r ListUsersRequestRequest) Execute() (*ListUserResponse, error) {
- var (
- localVarHTTPMethod = http.MethodGet
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ListUserResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListUsersRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- if r.page != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "")
- }
- if r.size != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "size", r.size, "")
- }
- if r.sort != nil {
- parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "")
- }
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ListUsersRequest: List Users
-
-List available users for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiListUsersRequestRequest
-*/
-func (a *APIClient) ListUsersRequest(ctx context.Context, projectId string, region string, instanceId string) ApiListUsersRequestRequest {
- return ListUsersRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ListUsersRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ListUserResponse, error) {
- r := ListUsersRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ProtectInstanceRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- protectInstanceRequestPayload *ProtectInstanceRequestPayload
-}
-
-// The request body with flag isDeletable. Parameter is required.
-
-func (r ProtectInstanceRequestRequest) ProtectInstanceRequestPayload(protectInstanceRequestPayload ProtectInstanceRequestPayload) ApiProtectInstanceRequestRequest {
- r.protectInstanceRequestPayload = &protectInstanceRequestPayload
- return r
-}
-
-func (r ProtectInstanceRequestRequest) Execute() (*ProtectInstanceResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ProtectInstanceResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ProtectInstanceRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/protections"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.protectInstanceRequestPayload == nil {
- return localVarReturnValue, fmt.Errorf("protectInstanceRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.protectInstanceRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ProtectInstanceRequest: Protect Instance
-
-Toggle the deletion protection for an instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiProtectInstanceRequestRequest
-*/
-func (a *APIClient) ProtectInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiProtectInstanceRequestRequest {
- return ProtectInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) ProtectInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) (*ProtectInstanceResponse, error) {
- r := ProtectInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type ResetUserRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- userId int64
-}
-
-func (r ResetUserRequestRequest) Execute() (*ResetUserResponse, error) {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- localVarReturnValue *ResetUserResponse
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ResetUserRequest")
- if err != nil {
- return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}/reset"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(r.userId, "userId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return localVarReturnValue, err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return localVarReturnValue, err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return localVarReturnValue, err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return localVarReturnValue, newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return localVarReturnValue, newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return localVarReturnValue, newErr
- }
-
- err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: err.Error(),
- }
- return localVarReturnValue, newErr
- }
-
- return localVarReturnValue, nil
-}
-
-/*
-ResetUserRequest: Reset User
-
-Reset an user from an specific instance.
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param userId The ID of the user.
- @return ApiResetUserRequestRequest
-*/
-func (a *APIClient) ResetUserRequest(ctx context.Context, projectId string, region string, instanceId string, userId int64) ApiResetUserRequestRequest {
- return ResetUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
-}
-
-func (a *APIClient) ResetUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) (*ResetUserResponse, error) {
- r := ResetUserRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- userId: userId,
- }
- return r.Execute()
-}
-
-type TriggerBackupRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- databaseName string
-}
-
-func (r TriggerBackupRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.TriggerBackupRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/databases/{databaseName}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(r.databaseName, "databaseName")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-TriggerBackupRequest: Trigger backup for a specific Database
-
-Trigger backup for a specific database
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseName The name of the database.
- @return ApiTriggerBackupRequestRequest
-*/
-func (a *APIClient) TriggerBackupRequest(ctx context.Context, projectId string, region string, instanceId string, databaseName string) ApiTriggerBackupRequestRequest {
- return TriggerBackupRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseName: databaseName,
- }
-}
-
-func (a *APIClient) TriggerBackupRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseName string) error {
- r := TriggerBackupRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseName: databaseName,
- }
- return r.Execute()
-}
-
-type TriggerRestoreRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- databaseName string
- triggerRestoreRequestPayload *TriggerRestoreRequestPayload
-}
-
-// The request body with the parameters for the database restore.
-
-func (r TriggerRestoreRequestRequest) TriggerRestoreRequestPayload(triggerRestoreRequestPayload TriggerRestoreRequestPayload) ApiTriggerRestoreRequestRequest {
- r.triggerRestoreRequestPayload = &triggerRestoreRequestPayload
- return r
-}
-
-func (r TriggerRestoreRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodPost
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.TriggerRestoreRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/databases/{databaseName}/restores"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(r.databaseName, "databaseName")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.triggerRestoreRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 501 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-TriggerRestoreRequest: Trigger restore for a specific Database
-
-Trigger restore for a specific Database
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @param databaseName The name of the database.
- @return ApiTriggerRestoreRequestRequest
-*/
-func (a *APIClient) TriggerRestoreRequest(ctx context.Context, projectId string, region string, instanceId string, databaseName string) ApiTriggerRestoreRequestRequest {
- return TriggerRestoreRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseName: databaseName,
- }
-}
-
-func (a *APIClient) TriggerRestoreRequestExecute(ctx context.Context, projectId string, region string, instanceId string, databaseName string) error {
- r := TriggerRestoreRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- databaseName: databaseName,
- }
- return r.Execute()
-}
-
-type UpdateInstancePartiallyRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- updateInstancePartiallyRequestPayload *UpdateInstancePartiallyRequestPayload
-}
-
-// The request body with the parameters for updating the instance.
-
-func (r UpdateInstancePartiallyRequestRequest) UpdateInstancePartiallyRequestPayload(updateInstancePartiallyRequestPayload UpdateInstancePartiallyRequestPayload) ApiUpdateInstancePartiallyRequestRequest {
- r.updateInstancePartiallyRequestPayload = &updateInstancePartiallyRequestPayload
- return r
-}
-
-func (r UpdateInstancePartiallyRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodPatch
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateInstancePartiallyRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.updateInstancePartiallyRequestPayload == nil {
- return fmt.Errorf("updateInstancePartiallyRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.updateInstancePartiallyRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-UpdateInstancePartiallyRequest: Update Instance Partially
-
-Update an available instance of a mssql database. No fields are required.
-
-**Please note that any changes applied via PUT or PATCH requests will initiate a reboot of the SQL Server Flex Instance.**
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiUpdateInstancePartiallyRequestRequest
-*/
-func (a *APIClient) UpdateInstancePartiallyRequest(ctx context.Context, projectId string, region string, instanceId string) ApiUpdateInstancePartiallyRequestRequest {
- return UpdateInstancePartiallyRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) UpdateInstancePartiallyRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error {
- r := UpdateInstancePartiallyRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
-
-type UpdateInstanceRequestRequest struct {
- ctx context.Context
- apiService *DefaultApiService
- projectId string
- region string
- instanceId string
- updateInstanceRequestPayload *UpdateInstanceRequestPayload
-}
-
-// The request body with the parameters for updating the instance
-
-func (r UpdateInstanceRequestRequest) UpdateInstanceRequestPayload(updateInstanceRequestPayload UpdateInstanceRequestPayload) ApiUpdateInstanceRequestRequest {
- r.updateInstanceRequestPayload = &updateInstanceRequestPayload
- return r
-}
-
-func (r UpdateInstanceRequestRequest) Execute() error {
- var (
- localVarHTTPMethod = http.MethodPut
- localVarPostBody interface{}
- formFiles []formFile
- )
- a := r.apiService
- client, ok := a.client.(*APIClient)
- if !ok {
- return fmt.Errorf("could not parse client to type APIClient")
- }
- localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateInstanceRequest")
- if err != nil {
- return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
- }
-
- localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
- localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
-
- localVarHeaderParams := make(map[string]string)
- localVarQueryParams := url.Values{}
- localVarFormParams := url.Values{}
- if r.updateInstanceRequestPayload == nil {
- return fmt.Errorf("updateInstanceRequestPayload is required and must be specified")
- }
-
- // to determine the Content-Type header
- localVarHTTPContentTypes := []string{"application/json"}
-
- // set Content-Type header
- localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
- if localVarHTTPContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHTTPContentType
- }
-
- // to determine the Accept header
- localVarHTTPHeaderAccepts := []string{"application/json"}
-
- // set Accept header
- localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
- if localVarHTTPHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
- }
- // body params
- localVarPostBody = r.updateInstanceRequestPayload
- req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
- if err != nil {
- return err
- }
-
- contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
- if ok {
- *contextHTTPRequest = req
- }
-
- localVarHTTPResponse, err := client.callAPI(req)
- contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
- if ok {
- *contextHTTPResponse = localVarHTTPResponse
- }
- if err != nil || localVarHTTPResponse == nil {
- return err
- }
-
- localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
- localVarHTTPResponse.Body.Close()
- localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
- if err != nil {
- return err
- }
-
- if localVarHTTPResponse.StatusCode >= 300 {
- newErr := &oapierror.GenericOpenAPIError{
- StatusCode: localVarHTTPResponse.StatusCode,
- Body: localVarBody,
- ErrorMessage: localVarHTTPResponse.Status,
- }
- if localVarHTTPResponse.StatusCode == 400 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 401 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 403 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 404 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 422 {
- var v ValidationError
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- return newErr
- }
- if localVarHTTPResponse.StatusCode == 500 {
- var v Error
- err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
- if err != nil {
- newErr.ErrorMessage = err.Error()
- return newErr
- }
- newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
- newErr.Model = v
- }
- return newErr
- }
-
- return nil
-}
-
-/*
-UpdateInstanceRequest: Update Instance
-
-# Updates an available instance of a sqlserver database
-
-**Please note that any changes applied via PUT or PATCH requests will initiate a reboot of the SQL Server Flex Instance.**
-
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param projectId The STACKIT project ID.
- @param region The region which should be addressed
- @param instanceId The ID of the instance.
- @return ApiUpdateInstanceRequestRequest
-*/
-func (a *APIClient) UpdateInstanceRequest(ctx context.Context, projectId string, region string, instanceId string) ApiUpdateInstanceRequestRequest {
- return UpdateInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
-}
-
-func (a *APIClient) UpdateInstanceRequestExecute(ctx context.Context, projectId string, region string, instanceId string) error {
- r := UpdateInstanceRequestRequest{
- apiService: a.defaultApi,
- ctx: ctx,
- projectId: projectId,
- region: region,
- instanceId: instanceId,
- }
- return r.Execute()
-}
diff --git a/pkg/sqlserverflexalpha/api_default_test.go b/pkg/sqlserverflexalpha/api_default_test.go
deleted file mode 100644
index 217f3399..00000000
--- a/pkg/sqlserverflexalpha/api_default_test.go
+++ /dev/null
@@ -1,1570 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-Testing DefaultApiService
-
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech);
-
-package sqlserverflexalpha
-
-import (
- "context"
- "encoding/json"
- "net/http"
- "net/http/httptest"
- "net/url"
- "strings"
- "testing"
-
- "github.com/stackitcloud/stackit-sdk-go/core/config"
-)
-
-func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
-
- t.Run("Test DefaultApiService CreateDatabaseRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := CreateDatabaseResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- createDatabaseRequestPayload := CreateDatabaseRequestPayload{}
-
- resp, reqErr := apiClient.CreateDatabaseRequest(context.Background(), projectId, region, instanceId).CreateDatabaseRequestPayload(createDatabaseRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService CreateInstanceRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := CreateInstanceResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- createInstanceRequestPayload := CreateInstanceRequestPayload{}
-
- resp, reqErr := apiClient.CreateInstanceRequest(context.Background(), projectId, region).CreateInstanceRequestPayload(createInstanceRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService CreateUserRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := CreateUserResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- createUserRequestPayload := CreateUserRequestPayload{}
-
- resp, reqErr := apiClient.CreateUserRequest(context.Background(), projectId, region, instanceId).CreateUserRequestPayload(createUserRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService DeleteDatabaseRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- databaseNameValue := "databaseName-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- databaseName := databaseNameValue
-
- reqErr := apiClient.DeleteDatabaseRequest(context.Background(), projectId, region, instanceId, databaseName).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService DeleteInstanceRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- reqErr := apiClient.DeleteInstanceRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService DeleteUserRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- userIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- userId := userIdValue
-
- reqErr := apiClient.DeleteUserRequest(context.Background(), projectId, region, instanceId, userId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService GetBackupRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/{backupId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- backupIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"backupId"+"}", url.PathEscape(ParameterValueToString(backupIdValue, "backupId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetBackupResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- backupId := backupIdValue
-
- resp, reqErr := apiClient.GetBackupRequest(context.Background(), projectId, region, instanceId, backupId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetCollationsRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/collations"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetCollationsResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.GetCollationsRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetDatabaseRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- databaseNameValue := "databaseName-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetDatabaseResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- databaseName := databaseNameValue
-
- resp, reqErr := apiClient.GetDatabaseRequest(context.Background(), projectId, region, instanceId, databaseName).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetFlavorsRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/flavors"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetFlavorsResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
-
- page := int64(1)
- size := int64(10)
- resp, reqErr := apiClient.GetFlavorsRequest(context.Background(), projectId, region, &page, &size, FLAVORSORT_ID_DESC).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetInstanceRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetInstanceResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.GetInstanceRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetStoragesRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/storages/{flavorId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- flavorIdValue := "flavorId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"flavorId"+"}", url.PathEscape(ParameterValueToString(flavorIdValue, "flavorId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetStoragesResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- flavorId := flavorIdValue
-
- resp, reqErr := apiClient.GetStoragesRequest(context.Background(), projectId, region, flavorId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetUserRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- userIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetUserResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- userId := userIdValue
-
- resp, reqErr := apiClient.GetUserRequest(context.Background(), projectId, region, instanceId, userId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService GetVersionsRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/versions"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := GetVersionsResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
-
- resp, reqErr := apiClient.GetVersionsRequest(context.Background(), projectId, region).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListBackupsRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListBackupResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.ListBackupsRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListCompatibilitiesRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/compatibility"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListCompatibilityResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.ListCompatibilitiesRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListCurrentRunningRestoreJobs", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/restore-jobs"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListCurrentRunningRestoreJobs{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.ListCurrentRunningRestoreJobs(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListDatabasesRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListDatabasesResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.ListDatabasesRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListInstancesRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListInstancesResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
-
- resp, reqErr := apiClient.ListInstancesRequest(context.Background(), projectId, region).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListRolesRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/roles"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListRolesResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.ListRolesRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ListUsersRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ListUserResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
-
- resp, reqErr := apiClient.ListUsersRequest(context.Background(), projectId, region, instanceId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ProtectInstanceRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/protections"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ProtectInstanceResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- protectInstanceRequestPayload := ProtectInstanceRequestPayload{}
-
- resp, reqErr := apiClient.ProtectInstanceRequest(context.Background(), projectId, region, instanceId).ProtectInstanceRequestPayload(protectInstanceRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService ResetUserRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}/reset"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- userIdValue := int64(123)
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- data := ResetUserResponse{}
- w.Header().Add("Content-Type", "application/json")
- json.NewEncoder(w).Encode(data)
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- userId := userIdValue
-
- resp, reqErr := apiClient.ResetUserRequest(context.Background(), projectId, region, instanceId, userId).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- if IsNil(resp) {
- t.Fatalf("response not present")
- }
- })
-
- t.Run("Test DefaultApiService TriggerBackupRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/databases/{databaseName}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- databaseNameValue := "databaseName-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- databaseName := databaseNameValue
-
- reqErr := apiClient.TriggerBackupRequest(context.Background(), projectId, region, instanceId, databaseName).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService TriggerRestoreRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/databases/{databaseName}/restores"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
- databaseNameValue := "databaseName-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- databaseName := databaseNameValue
-
- reqErr := apiClient.TriggerRestoreRequest(context.Background(), projectId, region, instanceId, databaseName).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService UpdateInstancePartiallyRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- updateInstancePartiallyRequestPayload := UpdateInstancePartiallyRequestPayload{}
-
- reqErr := apiClient.UpdateInstancePartiallyRequest(context.Background(), projectId, region, instanceId).UpdateInstancePartiallyRequestPayload(updateInstancePartiallyRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
- t.Run("Test DefaultApiService UpdateInstanceRequest", func(t *testing.T) {
- _apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
- projectIdValue := "projectId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
- regionValue := "region-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
- instanceIdValue := "instanceId-value"
- _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
-
- testDefaultApiServeMux := http.NewServeMux()
- testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
- })
- testServer := httptest.NewServer(testDefaultApiServeMux)
- defer testServer.Close()
-
- configuration := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "OpenAPI-Generator/1.0.0/go",
- Debug: false,
- Region: "test_region",
- Servers: config.ServerConfigurations{
- {
- URL: testServer.URL,
- Description: "Localhost for sqlserverflexalpha_DefaultApi",
- Variables: map[string]config.ServerVariable{
- "region": {
- DefaultValue: "test_region.",
- EnumValues: []string{
- "test_region.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
- if err != nil {
- t.Fatalf("creating API client: %v", err)
- }
-
- projectId := projectIdValue
- region := regionValue
- instanceId := instanceIdValue
- updateInstanceRequestPayload := UpdateInstanceRequestPayload{}
-
- reqErr := apiClient.UpdateInstanceRequest(context.Background(), projectId, region, instanceId).UpdateInstanceRequestPayload(updateInstanceRequestPayload).Execute()
-
- if reqErr != nil {
- t.Fatalf("error in call: %v", reqErr)
- }
- })
-
-}
diff --git a/pkg/sqlserverflexalpha/client.go b/pkg/sqlserverflexalpha/client.go
deleted file mode 100644
index f8a9ddbe..00000000
--- a/pkg/sqlserverflexalpha/client.go
+++ /dev/null
@@ -1,631 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "bytes"
- "context"
- "encoding/json"
- "encoding/xml"
- "fmt"
- "io"
- "log"
- "mime/multipart"
- "net/http"
- "net/http/httputil"
- "net/url"
- "os"
- "path/filepath"
- "reflect"
- "regexp"
- "strconv"
- "strings"
- "time"
- "unicode/utf8"
-
- "github.com/stackitcloud/stackit-sdk-go/core/auth"
- "github.com/stackitcloud/stackit-sdk-go/core/config"
-)
-
-var (
- jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`)
- xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`)
- queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
- queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]")
-)
-
-// APIClient manages communication with the STACKIT MSSQL Service API API v3alpha1
-// In most cases there should be only one, shared, APIClient.
-type APIClient struct {
- cfg *config.Configuration
- common service // Reuse a single struct instead of allocating one for each service on the heap.
- defaultApi *DefaultApiService
-}
-
-type service struct {
- client DefaultApi
-}
-
-// NewAPIClient creates a new API client.
-// Optionally receives configuration options
-func NewAPIClient(opts ...config.ConfigurationOption) (*APIClient, error) {
- cfg := NewConfiguration()
-
- for _, option := range opts {
- err := option(cfg)
- if err != nil {
- return nil, fmt.Errorf("configuring the client: %w", err)
- }
- }
-
- err := config.ConfigureRegion(cfg)
- if err != nil {
- return nil, fmt.Errorf("configuring region: %w", err)
- }
-
- if cfg.HTTPClient == nil {
- cfg.HTTPClient = &http.Client{}
- }
-
- authRoundTripper, err := auth.SetupAuth(cfg)
- if err != nil {
- return nil, fmt.Errorf("setting up authentication: %w", err)
- }
-
- roundTripper := authRoundTripper
- if cfg.Middleware != nil {
- roundTripper = config.ChainMiddleware(roundTripper, cfg.Middleware...)
- }
-
- cfg.HTTPClient.Transport = roundTripper
-
- c := &APIClient{}
- c.cfg = cfg
- c.common.client = c
- c.defaultApi = (*DefaultApiService)(&c.common)
-
- return c, nil
-}
-
-func atoi(in string) (int, error) {
- return strconv.Atoi(in)
-}
-
-// selectHeaderContentType select a content type from the available list.
-func selectHeaderContentType(contentTypes []string) string {
- if len(contentTypes) == 0 {
- return ""
- }
- if contains(contentTypes, "application/json") {
- return "application/json"
- }
- return contentTypes[0] // use the first content type specified in 'consumes'
-}
-
-// selectHeaderAccept join all accept types and return
-func selectHeaderAccept(accepts []string) string {
- if len(accepts) == 0 {
- return ""
- }
-
- if contains(accepts, "application/json") {
- return "application/json"
- }
-
- return strings.Join(accepts, ",")
-}
-
-// contains is a case insensitive match, finding needle in a haystack
-func contains(haystack []string, needle string) bool {
- for _, a := range haystack {
- if strings.EqualFold(a, needle) {
- return true
- }
- }
- return false
-}
-
-// Verify optional parameters are of the correct type.
-func typeCheckParameter(obj interface{}, expected string, name string) error {
- // Make sure there is an object.
- if obj == nil {
- return nil
- }
-
- // Check the type is as expected.
- if reflect.TypeOf(obj).String() != expected {
- return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String())
- }
- return nil
-}
-
-func ParameterValueToString(obj interface{}, key string) string {
- if reflect.TypeOf(obj).Kind() != reflect.Ptr {
- return fmt.Sprintf("%v", obj)
- }
- var param, ok = obj.(MappedNullable)
- if !ok {
- return ""
- }
- dataMap, err := param.ToMap()
- if err != nil {
- return ""
- }
- return fmt.Sprintf("%v", dataMap[key])
-}
-
-// parameterAddToHeaderOrQuery adds the provided object to the request header or url query
-// supporting deep object syntax
-func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
- var v = reflect.ValueOf(obj)
- var value = ""
- if v == reflect.ValueOf(nil) {
- value = "null"
- } else {
- switch v.Kind() {
- case reflect.Invalid:
- value = "invalid"
-
- case reflect.Struct:
- if t, ok := obj.(MappedNullable); ok {
- dataMap, err := t.ToMap()
- if err != nil {
- return
- }
- parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, collectionType)
- return
- }
- if t, ok := obj.(time.Time); ok {
- parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339), collectionType)
- return
- }
- value = v.Type().String() + " value"
- case reflect.Slice:
- var indValue = reflect.ValueOf(obj)
- if indValue == reflect.ValueOf(nil) {
- return
- }
- var lenIndValue = indValue.Len()
- for i := 0; i < lenIndValue; i++ {
- var arrayValue = indValue.Index(i)
- parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, arrayValue.Interface(), collectionType)
- }
- return
-
- case reflect.Map:
- var indValue = reflect.ValueOf(obj)
- if indValue == reflect.ValueOf(nil) {
- return
- }
- iter := indValue.MapRange()
- for iter.Next() {
- k, v := iter.Key(), iter.Value()
- parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), collectionType)
- }
- return
-
- case reflect.Interface:
- fallthrough
- case reflect.Ptr:
- parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), collectionType)
- return
-
- case reflect.Int, reflect.Int8, reflect.Int16,
- reflect.Int32, reflect.Int64:
- value = strconv.FormatInt(v.Int(), 10)
- case reflect.Uint, reflect.Uint8, reflect.Uint16,
- reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- value = strconv.FormatUint(v.Uint(), 10)
- case reflect.Float32, reflect.Float64:
- value = strconv.FormatFloat(v.Float(), 'g', -1, 32)
- case reflect.Bool:
- value = strconv.FormatBool(v.Bool())
- case reflect.String:
- value = v.String()
- default:
- value = v.Type().String() + " value"
- }
- }
-
- switch valuesMap := headerOrQueryParams.(type) {
- case url.Values:
- if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" {
- valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix)+","+value)
- } else {
- valuesMap.Add(keyPrefix, value)
- }
- break
- case map[string]string:
- valuesMap[keyPrefix] = value
- break
- }
-}
-
-// helper for converting interface{} parameters to json strings
-func parameterToJson(obj interface{}) (string, error) {
- jsonBuf, err := json.Marshal(obj)
- if err != nil {
- return "", err
- }
- return string(jsonBuf), err
-}
-
-// callAPI do the request.
-func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
- if c.cfg.Debug {
- dump, err := httputil.DumpRequestOut(request, true)
- if err != nil {
- return nil, err
- }
- log.Printf("\n%s\n", string(dump))
- }
-
- resp, err := c.cfg.HTTPClient.Do(request)
- if err != nil {
- return resp, err
- }
-
- if c.cfg.Debug {
- dump, err := httputil.DumpResponse(resp, true)
- if err != nil {
- return resp, err
- }
- log.Printf("\n%s\n", string(dump))
- }
- return resp, err
-}
-
-// Allow modification of underlying config for alternate implementations and testing
-// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
-func (c *APIClient) GetConfig() *config.Configuration {
- return c.cfg
-}
-
-type formFile struct {
- fileBytes []byte
- fileName string
- formFileName string
-}
-
-// prepareRequest build the request
-func (c *APIClient) prepareRequest(
- ctx context.Context,
- path string, method string,
- postBody interface{},
- headerParams map[string]string,
- queryParams url.Values,
- formParams url.Values,
- formFiles []formFile) (localVarRequest *http.Request, err error) {
-
- var body *bytes.Buffer
-
- // Detect postBody type and post.
- if !IsNil(postBody) {
- contentType := headerParams["Content-Type"]
- if contentType == "" {
- contentType = detectContentType(postBody)
- headerParams["Content-Type"] = contentType
- }
-
- body, err = setBody(postBody, contentType)
- if err != nil {
- return nil, err
- }
- }
-
- // add form parameters and file if available.
- if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) {
- if body != nil {
- return nil, fmt.Errorf("cannot specify postBody and multipart form at the same time.")
- }
- body = &bytes.Buffer{}
- w := multipart.NewWriter(body)
-
- for k, v := range formParams {
- for _, iv := range v {
- if strings.HasPrefix(k, "@") { // file
- err = addFile(w, k[1:], iv)
- if err != nil {
- return nil, err
- }
- } else { // form value
- w.WriteField(k, iv)
- }
- }
- }
- for _, formFile := range formFiles {
- if len(formFile.fileBytes) > 0 && formFile.fileName != "" {
- w.Boundary()
- part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName))
- if err != nil {
- return nil, err
- }
- _, err = part.Write(formFile.fileBytes)
- if err != nil {
- return nil, err
- }
- }
- }
-
- // Set the Boundary in the Content-Type
- headerParams["Content-Type"] = w.FormDataContentType()
-
- // Set Content-Length
- headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
- w.Close()
- }
-
- if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 {
- if body != nil {
- return nil, fmt.Errorf("cannot specify postBody and x-www-form-urlencoded form at the same time.")
- }
- body = &bytes.Buffer{}
- body.WriteString(formParams.Encode())
- // Set Content-Length
- headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
- }
-
- // Setup path and query parameters
- url, err := url.Parse(path)
- if err != nil {
- return nil, err
- }
-
- // Override request host, if applicable
- if c.cfg.Host != "" {
- url.Host = c.cfg.Host
- }
-
- // Override request scheme, if applicable
- if c.cfg.Scheme != "" {
- url.Scheme = c.cfg.Scheme
- }
-
- // Adding Query Param
- query := url.Query()
- for k, v := range queryParams {
- for _, iv := range v {
- query.Add(k, iv)
- }
- }
-
- // Encode the parameters.
- url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string {
- pieces := strings.Split(s, "=")
- pieces[0] = queryDescape.Replace(pieces[0])
- return strings.Join(pieces, "=")
- })
-
- // Generate a new request
- if body != nil {
- localVarRequest, err = http.NewRequest(method, url.String(), body)
- } else {
- localVarRequest, err = http.NewRequest(method, url.String(), nil)
- }
- if err != nil {
- return nil, err
- }
-
- // add header parameters, if any
- if len(headerParams) > 0 {
- headers := http.Header{}
- for h, v := range headerParams {
- headers[h] = []string{v}
- }
- localVarRequest.Header = headers
- }
-
- // Add the user agent to the request.
- localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
-
- if ctx != nil {
- // add context to the request
- localVarRequest = localVarRequest.WithContext(ctx)
-
- // Walk through any authentication.
-
- }
-
- for header, value := range c.cfg.DefaultHeader {
- localVarRequest.Header.Add(header, value)
- }
- return localVarRequest, nil
-}
-
-func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
- if len(b) == 0 {
- return nil
- }
- if s, ok := v.(*string); ok {
- *s = string(b)
- return nil
- }
- if f, ok := v.(*os.File); ok {
- f, err = os.CreateTemp("", "HttpClientFile")
- if err != nil {
- return
- }
- _, err = f.Write(b)
- if err != nil {
- return
- }
- _, err = f.Seek(0, io.SeekStart)
- return
- }
- if f, ok := v.(**os.File); ok {
- *f, err = os.CreateTemp("", "HttpClientFile")
- if err != nil {
- return
- }
- _, err = (*f).Write(b)
- if err != nil {
- return
- }
- _, err = (*f).Seek(0, io.SeekStart)
- return
- }
- if xmlCheck.MatchString(contentType) {
- if err = xml.Unmarshal(b, v); err != nil {
- return err
- }
- return nil
- }
- if jsonCheck.MatchString(contentType) {
- if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas
- if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined
- if err = unmarshalObj.UnmarshalJSON(b); err != nil {
- return err
- }
- } else {
- return fmt.Errorf("unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined")
- }
- } else if err = json.Unmarshal(b, v); err != nil { // simple model
- return err
- }
- return nil
- }
- return fmt.Errorf("undefined response type")
-}
-
-// Add a file to the multipart request
-func addFile(w *multipart.Writer, fieldName, path string) error {
- file, err := os.Open(filepath.Clean(path))
- if err != nil {
- return err
- }
- err = file.Close()
- if err != nil {
- return err
- }
-
- part, err := w.CreateFormFile(fieldName, filepath.Base(path))
- if err != nil {
- return err
- }
- _, err = io.Copy(part, file)
-
- return err
-}
-
-// A wrapper for strict JSON decoding
-func newStrictDecoder(data []byte) *json.Decoder {
- dec := json.NewDecoder(bytes.NewBuffer(data))
- dec.DisallowUnknownFields()
- return dec
-}
-
-// Set request body from an interface{}
-func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
- if bodyBuf == nil {
- bodyBuf = &bytes.Buffer{}
- }
-
- if reader, ok := body.(io.Reader); ok {
- _, err = bodyBuf.ReadFrom(reader)
- } else if fp, ok := body.(*os.File); ok {
- _, err = bodyBuf.ReadFrom(fp)
- } else if b, ok := body.([]byte); ok {
- _, err = bodyBuf.Write(b)
- } else if s, ok := body.(string); ok {
- _, err = bodyBuf.WriteString(s)
- } else if s, ok := body.(*string); ok {
- _, err = bodyBuf.WriteString(*s)
- } else if jsonCheck.MatchString(contentType) {
- err = json.NewEncoder(bodyBuf).Encode(body)
- } else if xmlCheck.MatchString(contentType) {
- err = xml.NewEncoder(bodyBuf).Encode(body)
- }
-
- if err != nil {
- return nil, err
- }
-
- if bodyBuf.Len() == 0 {
- err = fmt.Errorf("invalid body type %s", contentType)
- return nil, err
- }
- return bodyBuf, nil
-}
-
-// detectContentType method is used to figure out `Request.Body` content type for request header
-func detectContentType(body interface{}) string {
- contentType := "text/plain; charset=utf-8"
- kind := reflect.TypeOf(body).Kind()
-
- switch kind {
- case reflect.Struct, reflect.Map, reflect.Ptr:
- contentType = "application/json; charset=utf-8"
- case reflect.String:
- contentType = "text/plain; charset=utf-8"
- default:
- if b, ok := body.([]byte); ok {
- contentType = http.DetectContentType(b)
- } else if kind == reflect.Slice {
- contentType = "application/json; charset=utf-8"
- }
- }
-
- return contentType
-}
-
-// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go
-type cacheControl map[string]string
-
-func parseCacheControl(headers http.Header) cacheControl {
- cc := cacheControl{}
- ccHeader := headers.Get("Cache-Control")
- for _, part := range strings.Split(ccHeader, ",") {
- part = strings.Trim(part, " ")
- if part == "" {
- continue
- }
- if strings.ContainsRune(part, '=') {
- keyval := strings.Split(part, "=")
- cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",")
- } else {
- cc[part] = ""
- }
- }
- return cc
-}
-
-// CacheExpires helper function to determine remaining time before repeating a request.
-func CacheExpires(r *http.Response) time.Time {
- // Figure out when the cache expires.
- var expires time.Time
- now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
- if err != nil {
- return time.Now()
- }
- respCacheControl := parseCacheControl(r.Header)
-
- if maxAge, ok := respCacheControl["max-age"]; ok {
- lifetime, err := time.ParseDuration(maxAge + "s")
- if err != nil {
- expires = now
- } else {
- expires = now.Add(lifetime)
- }
- } else {
- expiresHeader := r.Header.Get("Expires")
- if expiresHeader != "" {
- expires, err = time.Parse(time.RFC1123, expiresHeader)
- if err != nil {
- expires = now
- }
- }
- }
- return expires
-}
-
-func strlen(s string) int {
- return utf8.RuneCountInString(s)
-}
diff --git a/pkg/sqlserverflexalpha/configuration.go b/pkg/sqlserverflexalpha/configuration.go
deleted file mode 100644
index e6150bdf..00000000
--- a/pkg/sqlserverflexalpha/configuration.go
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "github.com/stackitcloud/stackit-sdk-go/core/config"
-)
-
-// NewConfiguration returns a new Configuration object
-func NewConfiguration() *config.Configuration {
- cfg := &config.Configuration{
- DefaultHeader: make(map[string]string),
- UserAgent: "stackit-sdk-go/sqlserverflexalpha",
- Debug: false,
- Servers: config.ServerConfigurations{
- {
- URL: "https://mssql-flex-service.api.{region}stackit.cloud",
- Description: "No description provided",
- Variables: map[string]config.ServerVariable{
- "region": {
- Description: "No description provided",
- DefaultValue: "eu01.",
- EnumValues: []string{
- "eu01.",
- },
- },
- },
- },
- },
- OperationServers: map[string]config.ServerConfigurations{},
- }
- return cfg
-}
diff --git a/pkg/sqlserverflexalpha/model_backup_running_restore.go b/pkg/sqlserverflexalpha/model_backup_running_restore.go
deleted file mode 100644
index e226d582..00000000
--- a/pkg/sqlserverflexalpha/model_backup_running_restore.go
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the BackupRunningRestore type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &BackupRunningRestore{}
-
-/*
- types and functions for command
-*/
-
-// isNotNullableString
-type BackupRunningRestoreGetCommandAttributeType = *string
-
-func getBackupRunningRestoreGetCommandAttributeTypeOk(arg BackupRunningRestoreGetCommandAttributeType) (ret BackupRunningRestoreGetCommandRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setBackupRunningRestoreGetCommandAttributeType(arg *BackupRunningRestoreGetCommandAttributeType, val BackupRunningRestoreGetCommandRetType) {
- *arg = &val
-}
-
-type BackupRunningRestoreGetCommandArgType = string
-type BackupRunningRestoreGetCommandRetType = string
-
-/*
- types and functions for database_name
-*/
-
-// isNotNullableString
-type BackupRunningRestoreGetDatabaseNameAttributeType = *string
-
-func getBackupRunningRestoreGetDatabaseNameAttributeTypeOk(arg BackupRunningRestoreGetDatabaseNameAttributeType) (ret BackupRunningRestoreGetDatabaseNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setBackupRunningRestoreGetDatabaseNameAttributeType(arg *BackupRunningRestoreGetDatabaseNameAttributeType, val BackupRunningRestoreGetDatabaseNameRetType) {
- *arg = &val
-}
-
-type BackupRunningRestoreGetDatabaseNameArgType = string
-type BackupRunningRestoreGetDatabaseNameRetType = string
-
-/*
- types and functions for estimated_completion_time
-*/
-
-// isNotNullableString
-type BackupRunningRestoreGetEstimatedCompletionTimeAttributeType = *string
-
-func getBackupRunningRestoreGetEstimatedCompletionTimeAttributeTypeOk(arg BackupRunningRestoreGetEstimatedCompletionTimeAttributeType) (ret BackupRunningRestoreGetEstimatedCompletionTimeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setBackupRunningRestoreGetEstimatedCompletionTimeAttributeType(arg *BackupRunningRestoreGetEstimatedCompletionTimeAttributeType, val BackupRunningRestoreGetEstimatedCompletionTimeRetType) {
- *arg = &val
-}
-
-type BackupRunningRestoreGetEstimatedCompletionTimeArgType = string
-type BackupRunningRestoreGetEstimatedCompletionTimeRetType = string
-
-/*
- types and functions for percent_complete
-*/
-
-// isInteger
-type BackupRunningRestoreGetPercentCompleteAttributeType = *int64
-type BackupRunningRestoreGetPercentCompleteArgType = int64
-type BackupRunningRestoreGetPercentCompleteRetType = int64
-
-func getBackupRunningRestoreGetPercentCompleteAttributeTypeOk(arg BackupRunningRestoreGetPercentCompleteAttributeType) (ret BackupRunningRestoreGetPercentCompleteRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setBackupRunningRestoreGetPercentCompleteAttributeType(arg *BackupRunningRestoreGetPercentCompleteAttributeType, val BackupRunningRestoreGetPercentCompleteRetType) {
- *arg = &val
-}
-
-/*
- types and functions for start_time
-*/
-
-// isNotNullableString
-type BackupRunningRestoreGetStartTimeAttributeType = *string
-
-func getBackupRunningRestoreGetStartTimeAttributeTypeOk(arg BackupRunningRestoreGetStartTimeAttributeType) (ret BackupRunningRestoreGetStartTimeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setBackupRunningRestoreGetStartTimeAttributeType(arg *BackupRunningRestoreGetStartTimeAttributeType, val BackupRunningRestoreGetStartTimeRetType) {
- *arg = &val
-}
-
-type BackupRunningRestoreGetStartTimeArgType = string
-type BackupRunningRestoreGetStartTimeRetType = string
-
-// BackupRunningRestore struct for BackupRunningRestore
-type BackupRunningRestore struct {
- // the command that was executed
- // REQUIRED
- Command BackupRunningRestoreGetCommandAttributeType `json:"command" required:"true" validate:"required,restoreCommand"`
- // the name of the database that is being restored
- // REQUIRED
- DatabaseName BackupRunningRestoreGetDatabaseNameAttributeType `json:"database_name" required:"true" validate:"required,databaseName"`
- // the projected time when the restore should be completed
- // REQUIRED
- EstimatedCompletionTime BackupRunningRestoreGetEstimatedCompletionTimeAttributeType `json:"estimated_completion_time" required:"true" validate:"required,time"`
- // the percentage of the current running restore job
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- PercentComplete BackupRunningRestoreGetPercentCompleteAttributeType `json:"percent_complete" required:"true" validate:"required,min=0,max=100"`
- // the start time of the current running restore job
- // REQUIRED
- StartTime BackupRunningRestoreGetStartTimeAttributeType `json:"start_time" required:"true" validate:"required,time"`
-}
-
-type _BackupRunningRestore BackupRunningRestore
-
-// NewBackupRunningRestore instantiates a new BackupRunningRestore object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewBackupRunningRestore(command BackupRunningRestoreGetCommandArgType, databaseName BackupRunningRestoreGetDatabaseNameArgType, estimatedCompletionTime BackupRunningRestoreGetEstimatedCompletionTimeArgType, percentComplete BackupRunningRestoreGetPercentCompleteArgType, startTime BackupRunningRestoreGetStartTimeArgType) *BackupRunningRestore {
- this := BackupRunningRestore{}
- setBackupRunningRestoreGetCommandAttributeType(&this.Command, command)
- setBackupRunningRestoreGetDatabaseNameAttributeType(&this.DatabaseName, databaseName)
- setBackupRunningRestoreGetEstimatedCompletionTimeAttributeType(&this.EstimatedCompletionTime, estimatedCompletionTime)
- setBackupRunningRestoreGetPercentCompleteAttributeType(&this.PercentComplete, percentComplete)
- setBackupRunningRestoreGetStartTimeAttributeType(&this.StartTime, startTime)
- return &this
-}
-
-// NewBackupRunningRestoreWithDefaults instantiates a new BackupRunningRestore object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewBackupRunningRestoreWithDefaults() *BackupRunningRestore {
- this := BackupRunningRestore{}
- return &this
-}
-
-// GetCommand returns the Command field value
-func (o *BackupRunningRestore) GetCommand() (ret BackupRunningRestoreGetCommandRetType) {
- ret, _ = o.GetCommandOk()
- return ret
-}
-
-// GetCommandOk returns a tuple with the Command field value
-// and a boolean to check if the value has been set.
-func (o *BackupRunningRestore) GetCommandOk() (ret BackupRunningRestoreGetCommandRetType, ok bool) {
- return getBackupRunningRestoreGetCommandAttributeTypeOk(o.Command)
-}
-
-// SetCommand sets field value
-func (o *BackupRunningRestore) SetCommand(v BackupRunningRestoreGetCommandRetType) {
- setBackupRunningRestoreGetCommandAttributeType(&o.Command, v)
-}
-
-// GetDatabaseName returns the DatabaseName field value
-func (o *BackupRunningRestore) GetDatabaseName() (ret BackupRunningRestoreGetDatabaseNameRetType) {
- ret, _ = o.GetDatabaseNameOk()
- return ret
-}
-
-// GetDatabaseNameOk returns a tuple with the DatabaseName field value
-// and a boolean to check if the value has been set.
-func (o *BackupRunningRestore) GetDatabaseNameOk() (ret BackupRunningRestoreGetDatabaseNameRetType, ok bool) {
- return getBackupRunningRestoreGetDatabaseNameAttributeTypeOk(o.DatabaseName)
-}
-
-// SetDatabaseName sets field value
-func (o *BackupRunningRestore) SetDatabaseName(v BackupRunningRestoreGetDatabaseNameRetType) {
- setBackupRunningRestoreGetDatabaseNameAttributeType(&o.DatabaseName, v)
-}
-
-// GetEstimatedCompletionTime returns the EstimatedCompletionTime field value
-func (o *BackupRunningRestore) GetEstimatedCompletionTime() (ret BackupRunningRestoreGetEstimatedCompletionTimeRetType) {
- ret, _ = o.GetEstimatedCompletionTimeOk()
- return ret
-}
-
-// GetEstimatedCompletionTimeOk returns a tuple with the EstimatedCompletionTime field value
-// and a boolean to check if the value has been set.
-func (o *BackupRunningRestore) GetEstimatedCompletionTimeOk() (ret BackupRunningRestoreGetEstimatedCompletionTimeRetType, ok bool) {
- return getBackupRunningRestoreGetEstimatedCompletionTimeAttributeTypeOk(o.EstimatedCompletionTime)
-}
-
-// SetEstimatedCompletionTime sets field value
-func (o *BackupRunningRestore) SetEstimatedCompletionTime(v BackupRunningRestoreGetEstimatedCompletionTimeRetType) {
- setBackupRunningRestoreGetEstimatedCompletionTimeAttributeType(&o.EstimatedCompletionTime, v)
-}
-
-// GetPercentComplete returns the PercentComplete field value
-func (o *BackupRunningRestore) GetPercentComplete() (ret BackupRunningRestoreGetPercentCompleteRetType) {
- ret, _ = o.GetPercentCompleteOk()
- return ret
-}
-
-// GetPercentCompleteOk returns a tuple with the PercentComplete field value
-// and a boolean to check if the value has been set.
-func (o *BackupRunningRestore) GetPercentCompleteOk() (ret BackupRunningRestoreGetPercentCompleteRetType, ok bool) {
- return getBackupRunningRestoreGetPercentCompleteAttributeTypeOk(o.PercentComplete)
-}
-
-// SetPercentComplete sets field value
-func (o *BackupRunningRestore) SetPercentComplete(v BackupRunningRestoreGetPercentCompleteRetType) {
- setBackupRunningRestoreGetPercentCompleteAttributeType(&o.PercentComplete, v)
-}
-
-// GetStartTime returns the StartTime field value
-func (o *BackupRunningRestore) GetStartTime() (ret BackupRunningRestoreGetStartTimeRetType) {
- ret, _ = o.GetStartTimeOk()
- return ret
-}
-
-// GetStartTimeOk returns a tuple with the StartTime field value
-// and a boolean to check if the value has been set.
-func (o *BackupRunningRestore) GetStartTimeOk() (ret BackupRunningRestoreGetStartTimeRetType, ok bool) {
- return getBackupRunningRestoreGetStartTimeAttributeTypeOk(o.StartTime)
-}
-
-// SetStartTime sets field value
-func (o *BackupRunningRestore) SetStartTime(v BackupRunningRestoreGetStartTimeRetType) {
- setBackupRunningRestoreGetStartTimeAttributeType(&o.StartTime, v)
-}
-
-func (o BackupRunningRestore) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getBackupRunningRestoreGetCommandAttributeTypeOk(o.Command); ok {
- toSerialize["Command"] = val
- }
- if val, ok := getBackupRunningRestoreGetDatabaseNameAttributeTypeOk(o.DatabaseName); ok {
- toSerialize["DatabaseName"] = val
- }
- if val, ok := getBackupRunningRestoreGetEstimatedCompletionTimeAttributeTypeOk(o.EstimatedCompletionTime); ok {
- toSerialize["EstimatedCompletionTime"] = val
- }
- if val, ok := getBackupRunningRestoreGetPercentCompleteAttributeTypeOk(o.PercentComplete); ok {
- toSerialize["PercentComplete"] = val
- }
- if val, ok := getBackupRunningRestoreGetStartTimeAttributeTypeOk(o.StartTime); ok {
- toSerialize["StartTime"] = val
- }
- return toSerialize, nil
-}
-
-type NullableBackupRunningRestore struct {
- value *BackupRunningRestore
- isSet bool
-}
-
-func (v NullableBackupRunningRestore) Get() *BackupRunningRestore {
- return v.value
-}
-
-func (v *NullableBackupRunningRestore) Set(val *BackupRunningRestore) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableBackupRunningRestore) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableBackupRunningRestore) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableBackupRunningRestore(val *BackupRunningRestore) *NullableBackupRunningRestore {
- return &NullableBackupRunningRestore{value: val, isSet: true}
-}
-
-func (v NullableBackupRunningRestore) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableBackupRunningRestore) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_backup_running_restore_test.go b/pkg/sqlserverflexalpha/model_backup_running_restore_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_backup_running_restore_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_backup_sort.go b/pkg/sqlserverflexalpha/model_backup_sort.go
deleted file mode 100644
index 3a7a9669..00000000
--- a/pkg/sqlserverflexalpha/model_backup_sort.go
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// BackupSort the model 'BackupSort'
-type BackupSort string
-
-// List of backup.sort
-const (
- BACKUPSORT_END_TIME_DESC BackupSort = "end_time.desc"
- BACKUPSORT_END_TIME_ASC BackupSort = "end_time.asc"
- BACKUPSORT_INDEX_DESC BackupSort = "index.desc"
- BACKUPSORT_INDEX_ASC BackupSort = "index.asc"
- BACKUPSORT_NAME_DESC BackupSort = "name.desc"
- BACKUPSORT_NAME_ASC BackupSort = "name.asc"
- BACKUPSORT_RETAINED_UNTIL_DESC BackupSort = "retained_until.desc"
- BACKUPSORT_RETAINED_UNTIL_ASC BackupSort = "retained_until.asc"
- BACKUPSORT_SIZE_DESC BackupSort = "size.desc"
- BACKUPSORT_SIZE_ASC BackupSort = "size.asc"
- BACKUPSORT_TYPE_DESC BackupSort = "type.desc"
- BACKUPSORT_TYPE_ASC BackupSort = "type.asc"
-)
-
-// All allowed values of BackupSort enum
-var AllowedBackupSortEnumValues = []BackupSort{
- "end_time.desc",
- "end_time.asc",
- "index.desc",
- "index.asc",
- "name.desc",
- "name.asc",
- "retained_until.desc",
- "retained_until.asc",
- "size.desc",
- "size.asc",
- "type.desc",
- "type.asc",
-}
-
-func (v *BackupSort) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := BackupSort(value)
- for _, existing := range AllowedBackupSortEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid BackupSort", value)
-}
-
-// NewBackupSortFromValue returns a pointer to a valid BackupSort
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewBackupSortFromValue(v string) (*BackupSort, error) {
- ev := BackupSort(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for BackupSort: valid values are %v", v, AllowedBackupSortEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v BackupSort) IsValid() bool {
- for _, existing := range AllowedBackupSortEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to backup.sort value
-func (v BackupSort) Ptr() *BackupSort {
- return &v
-}
-
-type NullableBackupSort struct {
- value *BackupSort
- isSet bool
-}
-
-func (v NullableBackupSort) Get() *BackupSort {
- return v.value
-}
-
-func (v *NullableBackupSort) Set(val *BackupSort) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableBackupSort) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableBackupSort) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableBackupSort(val *BackupSort) *NullableBackupSort {
- return &NullableBackupSort{value: val, isSet: true}
-}
-
-func (v NullableBackupSort) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableBackupSort) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_backup_sort_test.go b/pkg/sqlserverflexalpha/model_backup_sort_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_backup_sort_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_create_database_request_payload.go b/pkg/sqlserverflexalpha/model_create_database_request_payload.go
deleted file mode 100644
index 84fe2798..00000000
--- a/pkg/sqlserverflexalpha/model_create_database_request_payload.go
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateDatabaseRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateDatabaseRequestPayload{}
-
-/*
- types and functions for collation
-*/
-
-// isNotNullableString
-type CreateDatabaseRequestPayloadGetCollationAttributeType = *string
-
-func getCreateDatabaseRequestPayloadGetCollationAttributeTypeOk(arg CreateDatabaseRequestPayloadGetCollationAttributeType) (ret CreateDatabaseRequestPayloadGetCollationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateDatabaseRequestPayloadGetCollationAttributeType(arg *CreateDatabaseRequestPayloadGetCollationAttributeType, val CreateDatabaseRequestPayloadGetCollationRetType) {
- *arg = &val
-}
-
-type CreateDatabaseRequestPayloadGetCollationArgType = string
-type CreateDatabaseRequestPayloadGetCollationRetType = string
-
-/*
- types and functions for compatibility
-*/
-
-// isInteger
-type CreateDatabaseRequestPayloadGetCompatibilityAttributeType = *int64
-type CreateDatabaseRequestPayloadGetCompatibilityArgType = int64
-type CreateDatabaseRequestPayloadGetCompatibilityRetType = int64
-
-func getCreateDatabaseRequestPayloadGetCompatibilityAttributeTypeOk(arg CreateDatabaseRequestPayloadGetCompatibilityAttributeType) (ret CreateDatabaseRequestPayloadGetCompatibilityRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateDatabaseRequestPayloadGetCompatibilityAttributeType(arg *CreateDatabaseRequestPayloadGetCompatibilityAttributeType, val CreateDatabaseRequestPayloadGetCompatibilityRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type CreateDatabaseRequestPayloadGetNameAttributeType = *string
-
-func getCreateDatabaseRequestPayloadGetNameAttributeTypeOk(arg CreateDatabaseRequestPayloadGetNameAttributeType) (ret CreateDatabaseRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateDatabaseRequestPayloadGetNameAttributeType(arg *CreateDatabaseRequestPayloadGetNameAttributeType, val CreateDatabaseRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type CreateDatabaseRequestPayloadGetNameArgType = string
-type CreateDatabaseRequestPayloadGetNameRetType = string
-
-/*
- types and functions for owner
-*/
-
-// isNotNullableString
-type CreateDatabaseRequestPayloadGetOwnerAttributeType = *string
-
-func getCreateDatabaseRequestPayloadGetOwnerAttributeTypeOk(arg CreateDatabaseRequestPayloadGetOwnerAttributeType) (ret CreateDatabaseRequestPayloadGetOwnerRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateDatabaseRequestPayloadGetOwnerAttributeType(arg *CreateDatabaseRequestPayloadGetOwnerAttributeType, val CreateDatabaseRequestPayloadGetOwnerRetType) {
- *arg = &val
-}
-
-type CreateDatabaseRequestPayloadGetOwnerArgType = string
-type CreateDatabaseRequestPayloadGetOwnerRetType = string
-
-// CreateDatabaseRequestPayload struct for CreateDatabaseRequestPayload
-type CreateDatabaseRequestPayload struct {
- // The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.
- Collation CreateDatabaseRequestPayloadGetCollationAttributeType `json:"collation,omitempty"`
- // CompatibilityLevel of the Database.
- // Can be cast to int32 without loss of precision.
- Compatibility CreateDatabaseRequestPayloadGetCompatibilityAttributeType `json:"compatibility,omitempty"`
- // The name of the database.
- // REQUIRED
- Name CreateDatabaseRequestPayloadGetNameAttributeType `json:"name" required:"true"`
- // The owner of the database.
- // REQUIRED
- Owner CreateDatabaseRequestPayloadGetOwnerAttributeType `json:"owner" required:"true"`
-}
-
-type _CreateDatabaseRequestPayload CreateDatabaseRequestPayload
-
-// NewCreateDatabaseRequestPayload instantiates a new CreateDatabaseRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateDatabaseRequestPayload(name CreateDatabaseRequestPayloadGetNameArgType, owner CreateDatabaseRequestPayloadGetOwnerArgType) *CreateDatabaseRequestPayload {
- this := CreateDatabaseRequestPayload{}
- setCreateDatabaseRequestPayloadGetNameAttributeType(&this.Name, name)
- setCreateDatabaseRequestPayloadGetOwnerAttributeType(&this.Owner, owner)
- return &this
-}
-
-// NewCreateDatabaseRequestPayloadWithDefaults instantiates a new CreateDatabaseRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateDatabaseRequestPayloadWithDefaults() *CreateDatabaseRequestPayload {
- this := CreateDatabaseRequestPayload{}
- return &this
-}
-
-// GetCollation returns the Collation field value if set, zero value otherwise.
-func (o *CreateDatabaseRequestPayload) GetCollation() (res CreateDatabaseRequestPayloadGetCollationRetType) {
- res, _ = o.GetCollationOk()
- return
-}
-
-// GetCollationOk returns a tuple with the Collation field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *CreateDatabaseRequestPayload) GetCollationOk() (ret CreateDatabaseRequestPayloadGetCollationRetType, ok bool) {
- return getCreateDatabaseRequestPayloadGetCollationAttributeTypeOk(o.Collation)
-}
-
-// HasCollation returns a boolean if a field has been set.
-func (o *CreateDatabaseRequestPayload) HasCollation() bool {
- _, ok := o.GetCollationOk()
- return ok
-}
-
-// SetCollation gets a reference to the given string and assigns it to the Collation field.
-func (o *CreateDatabaseRequestPayload) SetCollation(v CreateDatabaseRequestPayloadGetCollationRetType) {
- setCreateDatabaseRequestPayloadGetCollationAttributeType(&o.Collation, v)
-}
-
-// GetCompatibility returns the Compatibility field value if set, zero value otherwise.
-func (o *CreateDatabaseRequestPayload) GetCompatibility() (res CreateDatabaseRequestPayloadGetCompatibilityRetType) {
- res, _ = o.GetCompatibilityOk()
- return
-}
-
-// GetCompatibilityOk returns a tuple with the Compatibility field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *CreateDatabaseRequestPayload) GetCompatibilityOk() (ret CreateDatabaseRequestPayloadGetCompatibilityRetType, ok bool) {
- return getCreateDatabaseRequestPayloadGetCompatibilityAttributeTypeOk(o.Compatibility)
-}
-
-// HasCompatibility returns a boolean if a field has been set.
-func (o *CreateDatabaseRequestPayload) HasCompatibility() bool {
- _, ok := o.GetCompatibilityOk()
- return ok
-}
-
-// SetCompatibility gets a reference to the given int64 and assigns it to the Compatibility field.
-func (o *CreateDatabaseRequestPayload) SetCompatibility(v CreateDatabaseRequestPayloadGetCompatibilityRetType) {
- setCreateDatabaseRequestPayloadGetCompatibilityAttributeType(&o.Compatibility, v)
-}
-
-// GetName returns the Name field value
-func (o *CreateDatabaseRequestPayload) GetName() (ret CreateDatabaseRequestPayloadGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *CreateDatabaseRequestPayload) GetNameOk() (ret CreateDatabaseRequestPayloadGetNameRetType, ok bool) {
- return getCreateDatabaseRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *CreateDatabaseRequestPayload) SetName(v CreateDatabaseRequestPayloadGetNameRetType) {
- setCreateDatabaseRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetOwner returns the Owner field value
-func (o *CreateDatabaseRequestPayload) GetOwner() (ret CreateDatabaseRequestPayloadGetOwnerRetType) {
- ret, _ = o.GetOwnerOk()
- return ret
-}
-
-// GetOwnerOk returns a tuple with the Owner field value
-// and a boolean to check if the value has been set.
-func (o *CreateDatabaseRequestPayload) GetOwnerOk() (ret CreateDatabaseRequestPayloadGetOwnerRetType, ok bool) {
- return getCreateDatabaseRequestPayloadGetOwnerAttributeTypeOk(o.Owner)
-}
-
-// SetOwner sets field value
-func (o *CreateDatabaseRequestPayload) SetOwner(v CreateDatabaseRequestPayloadGetOwnerRetType) {
- setCreateDatabaseRequestPayloadGetOwnerAttributeType(&o.Owner, v)
-}
-
-func (o CreateDatabaseRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateDatabaseRequestPayloadGetCollationAttributeTypeOk(o.Collation); ok {
- toSerialize["Collation"] = val
- }
- if val, ok := getCreateDatabaseRequestPayloadGetCompatibilityAttributeTypeOk(o.Compatibility); ok {
- toSerialize["Compatibility"] = val
- }
- if val, ok := getCreateDatabaseRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getCreateDatabaseRequestPayloadGetOwnerAttributeTypeOk(o.Owner); ok {
- toSerialize["Owner"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateDatabaseRequestPayload struct {
- value *CreateDatabaseRequestPayload
- isSet bool
-}
-
-func (v NullableCreateDatabaseRequestPayload) Get() *CreateDatabaseRequestPayload {
- return v.value
-}
-
-func (v *NullableCreateDatabaseRequestPayload) Set(val *CreateDatabaseRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateDatabaseRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateDatabaseRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateDatabaseRequestPayload(val *CreateDatabaseRequestPayload) *NullableCreateDatabaseRequestPayload {
- return &NullableCreateDatabaseRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableCreateDatabaseRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateDatabaseRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_create_database_request_payload_test.go b/pkg/sqlserverflexalpha/model_create_database_request_payload_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_create_database_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_create_database_response.go b/pkg/sqlserverflexalpha/model_create_database_response.go
deleted file mode 100644
index 6473bb5e..00000000
--- a/pkg/sqlserverflexalpha/model_create_database_response.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateDatabaseResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateDatabaseResponse{}
-
-/*
- types and functions for id
-*/
-
-// isLong
-type CreateDatabaseResponseGetIdAttributeType = *int64
-type CreateDatabaseResponseGetIdArgType = int64
-type CreateDatabaseResponseGetIdRetType = int64
-
-func getCreateDatabaseResponseGetIdAttributeTypeOk(arg CreateDatabaseResponseGetIdAttributeType) (ret CreateDatabaseResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateDatabaseResponseGetIdAttributeType(arg *CreateDatabaseResponseGetIdAttributeType, val CreateDatabaseResponseGetIdRetType) {
- *arg = &val
-}
-
-// CreateDatabaseResponse struct for CreateDatabaseResponse
-type CreateDatabaseResponse struct {
- // The id of the database.
- // REQUIRED
- Id CreateDatabaseResponseGetIdAttributeType `json:"id" required:"true"`
-}
-
-type _CreateDatabaseResponse CreateDatabaseResponse
-
-// NewCreateDatabaseResponse instantiates a new CreateDatabaseResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateDatabaseResponse(id CreateDatabaseResponseGetIdArgType) *CreateDatabaseResponse {
- this := CreateDatabaseResponse{}
- setCreateDatabaseResponseGetIdAttributeType(&this.Id, id)
- return &this
-}
-
-// NewCreateDatabaseResponseWithDefaults instantiates a new CreateDatabaseResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateDatabaseResponseWithDefaults() *CreateDatabaseResponse {
- this := CreateDatabaseResponse{}
- return &this
-}
-
-// GetId returns the Id field value
-func (o *CreateDatabaseResponse) GetId() (ret CreateDatabaseResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *CreateDatabaseResponse) GetIdOk() (ret CreateDatabaseResponseGetIdRetType, ok bool) {
- return getCreateDatabaseResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *CreateDatabaseResponse) SetId(v CreateDatabaseResponseGetIdRetType) {
- setCreateDatabaseResponseGetIdAttributeType(&o.Id, v)
-}
-
-func (o CreateDatabaseResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateDatabaseResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateDatabaseResponse struct {
- value *CreateDatabaseResponse
- isSet bool
-}
-
-func (v NullableCreateDatabaseResponse) Get() *CreateDatabaseResponse {
- return v.value
-}
-
-func (v *NullableCreateDatabaseResponse) Set(val *CreateDatabaseResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateDatabaseResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateDatabaseResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateDatabaseResponse(val *CreateDatabaseResponse) *NullableCreateDatabaseResponse {
- return &NullableCreateDatabaseResponse{value: val, isSet: true}
-}
-
-func (v NullableCreateDatabaseResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateDatabaseResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_create_database_response_test.go b/pkg/sqlserverflexalpha/model_create_database_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_create_database_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_create_instance_request_payload.go b/pkg/sqlserverflexalpha/model_create_instance_request_payload.go
deleted file mode 100644
index ff990d79..00000000
--- a/pkg/sqlserverflexalpha/model_create_instance_request_payload.go
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateInstanceRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateInstanceRequestPayload{}
-
-/*
- types and functions for acl
-*/
-
-// isArray
-type CreateInstanceRequestPayloadGetAclAttributeType = *[]string
-type CreateInstanceRequestPayloadGetAclArgType = []string
-type CreateInstanceRequestPayloadGetAclRetType = []string
-
-func getCreateInstanceRequestPayloadGetAclAttributeTypeOk(arg CreateInstanceRequestPayloadGetAclAttributeType) (ret CreateInstanceRequestPayloadGetAclRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetAclAttributeType(arg *CreateInstanceRequestPayloadGetAclAttributeType, val CreateInstanceRequestPayloadGetAclRetType) {
- *arg = &val
-}
-
-/*
- types and functions for backupSchedule
-*/
-
-// isNotNullableString
-type CreateInstanceRequestPayloadGetBackupScheduleAttributeType = *string
-
-func getCreateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(arg CreateInstanceRequestPayloadGetBackupScheduleAttributeType) (ret CreateInstanceRequestPayloadGetBackupScheduleRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetBackupScheduleAttributeType(arg *CreateInstanceRequestPayloadGetBackupScheduleAttributeType, val CreateInstanceRequestPayloadGetBackupScheduleRetType) {
- *arg = &val
-}
-
-type CreateInstanceRequestPayloadGetBackupScheduleArgType = string
-type CreateInstanceRequestPayloadGetBackupScheduleRetType = string
-
-/*
- types and functions for encryption
-*/
-
-// isModel
-type CreateInstanceRequestPayloadGetEncryptionAttributeType = *InstanceEncryption
-type CreateInstanceRequestPayloadGetEncryptionArgType = InstanceEncryption
-type CreateInstanceRequestPayloadGetEncryptionRetType = InstanceEncryption
-
-func getCreateInstanceRequestPayloadGetEncryptionAttributeTypeOk(arg CreateInstanceRequestPayloadGetEncryptionAttributeType) (ret CreateInstanceRequestPayloadGetEncryptionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetEncryptionAttributeType(arg *CreateInstanceRequestPayloadGetEncryptionAttributeType, val CreateInstanceRequestPayloadGetEncryptionRetType) {
- *arg = &val
-}
-
-/*
- types and functions for flavorId
-*/
-
-// isNotNullableString
-type CreateInstanceRequestPayloadGetFlavorIdAttributeType = *string
-
-func getCreateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(arg CreateInstanceRequestPayloadGetFlavorIdAttributeType) (ret CreateInstanceRequestPayloadGetFlavorIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetFlavorIdAttributeType(arg *CreateInstanceRequestPayloadGetFlavorIdAttributeType, val CreateInstanceRequestPayloadGetFlavorIdRetType) {
- *arg = &val
-}
-
-type CreateInstanceRequestPayloadGetFlavorIdArgType = string
-type CreateInstanceRequestPayloadGetFlavorIdRetType = string
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type CreateInstanceRequestPayloadGetNameAttributeType = *string
-
-func getCreateInstanceRequestPayloadGetNameAttributeTypeOk(arg CreateInstanceRequestPayloadGetNameAttributeType) (ret CreateInstanceRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetNameAttributeType(arg *CreateInstanceRequestPayloadGetNameAttributeType, val CreateInstanceRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type CreateInstanceRequestPayloadGetNameArgType = string
-type CreateInstanceRequestPayloadGetNameRetType = string
-
-/*
- types and functions for network
-*/
-
-// isModel
-type CreateInstanceRequestPayloadGetNetworkAttributeType = *CreateInstanceRequestPayloadNetwork
-type CreateInstanceRequestPayloadGetNetworkArgType = CreateInstanceRequestPayloadNetwork
-type CreateInstanceRequestPayloadGetNetworkRetType = CreateInstanceRequestPayloadNetwork
-
-func getCreateInstanceRequestPayloadGetNetworkAttributeTypeOk(arg CreateInstanceRequestPayloadGetNetworkAttributeType) (ret CreateInstanceRequestPayloadGetNetworkRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetNetworkAttributeType(arg *CreateInstanceRequestPayloadGetNetworkAttributeType, val CreateInstanceRequestPayloadGetNetworkRetType) {
- *arg = &val
-}
-
-/*
- types and functions for retentionDays
-*/
-
-// isInteger
-type CreateInstanceRequestPayloadGetRetentionDaysAttributeType = *int64
-type CreateInstanceRequestPayloadGetRetentionDaysArgType = int64
-type CreateInstanceRequestPayloadGetRetentionDaysRetType = int64
-
-func getCreateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(arg CreateInstanceRequestPayloadGetRetentionDaysAttributeType) (ret CreateInstanceRequestPayloadGetRetentionDaysRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetRetentionDaysAttributeType(arg *CreateInstanceRequestPayloadGetRetentionDaysAttributeType, val CreateInstanceRequestPayloadGetRetentionDaysRetType) {
- *arg = &val
-}
-
-/*
- types and functions for storage
-*/
-
-// isModel
-type CreateInstanceRequestPayloadGetStorageAttributeType = *StorageCreate
-type CreateInstanceRequestPayloadGetStorageArgType = StorageCreate
-type CreateInstanceRequestPayloadGetStorageRetType = StorageCreate
-
-func getCreateInstanceRequestPayloadGetStorageAttributeTypeOk(arg CreateInstanceRequestPayloadGetStorageAttributeType) (ret CreateInstanceRequestPayloadGetStorageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetStorageAttributeType(arg *CreateInstanceRequestPayloadGetStorageAttributeType, val CreateInstanceRequestPayloadGetStorageRetType) {
- *arg = &val
-}
-
-/*
- types and functions for version
-*/
-
-// isEnumRef
-type CreateInstanceRequestPayloadGetVersionAttributeType = *InstanceVersion
-type CreateInstanceRequestPayloadGetVersionArgType = InstanceVersion
-type CreateInstanceRequestPayloadGetVersionRetType = InstanceVersion
-
-func getCreateInstanceRequestPayloadGetVersionAttributeTypeOk(arg CreateInstanceRequestPayloadGetVersionAttributeType) (ret CreateInstanceRequestPayloadGetVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadGetVersionAttributeType(arg *CreateInstanceRequestPayloadGetVersionAttributeType, val CreateInstanceRequestPayloadGetVersionRetType) {
- *arg = &val
-}
-
-// CreateInstanceRequestPayload struct for CreateInstanceRequestPayload
-type CreateInstanceRequestPayload struct {
- // Deprecated: List of IPV4 cidr.
- // REQUIRED
- Acl CreateInstanceRequestPayloadGetAclAttributeType `json:"acl" required:"true"`
- // The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.
- // REQUIRED
- BackupSchedule CreateInstanceRequestPayloadGetBackupScheduleAttributeType `json:"backupSchedule" required:"true"`
- Encryption CreateInstanceRequestPayloadGetEncryptionAttributeType `json:"encryption,omitempty"`
- // The id of the instance flavor.
- // REQUIRED
- FlavorId CreateInstanceRequestPayloadGetFlavorIdAttributeType `json:"flavorId" required:"true"`
- // The name of the instance.
- // REQUIRED
- Name CreateInstanceRequestPayloadGetNameAttributeType `json:"name" required:"true"`
- Network CreateInstanceRequestPayloadGetNetworkAttributeType `json:"network,omitempty"`
- // The days for how long the backup files should be stored before cleaned up. 30 to 365
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- RetentionDays CreateInstanceRequestPayloadGetRetentionDaysAttributeType `json:"retentionDays" required:"true"`
- // REQUIRED
- Storage CreateInstanceRequestPayloadGetStorageAttributeType `json:"storage" required:"true"`
- // REQUIRED
- Version CreateInstanceRequestPayloadGetVersionAttributeType `json:"version" required:"true"`
-}
-
-type _CreateInstanceRequestPayload CreateInstanceRequestPayload
-
-// NewCreateInstanceRequestPayload instantiates a new CreateInstanceRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateInstanceRequestPayload(acl CreateInstanceRequestPayloadGetAclArgType, backupSchedule CreateInstanceRequestPayloadGetBackupScheduleArgType, flavorId CreateInstanceRequestPayloadGetFlavorIdArgType, name CreateInstanceRequestPayloadGetNameArgType, retentionDays CreateInstanceRequestPayloadGetRetentionDaysArgType, storage CreateInstanceRequestPayloadGetStorageArgType, version CreateInstanceRequestPayloadGetVersionArgType) *CreateInstanceRequestPayload {
- this := CreateInstanceRequestPayload{}
- setCreateInstanceRequestPayloadGetAclAttributeType(&this.Acl, acl)
- setCreateInstanceRequestPayloadGetBackupScheduleAttributeType(&this.BackupSchedule, backupSchedule)
- setCreateInstanceRequestPayloadGetFlavorIdAttributeType(&this.FlavorId, flavorId)
- setCreateInstanceRequestPayloadGetNameAttributeType(&this.Name, name)
- setCreateInstanceRequestPayloadGetRetentionDaysAttributeType(&this.RetentionDays, retentionDays)
- setCreateInstanceRequestPayloadGetStorageAttributeType(&this.Storage, storage)
- setCreateInstanceRequestPayloadGetVersionAttributeType(&this.Version, version)
- return &this
-}
-
-// NewCreateInstanceRequestPayloadWithDefaults instantiates a new CreateInstanceRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateInstanceRequestPayloadWithDefaults() *CreateInstanceRequestPayload {
- this := CreateInstanceRequestPayload{}
- return &this
-}
-
-// GetAcl returns the Acl field value
-// Deprecated
-func (o *CreateInstanceRequestPayload) GetAcl() (ret CreateInstanceRequestPayloadGetAclRetType) {
- ret, _ = o.GetAclOk()
- return ret
-}
-
-// GetAclOk returns a tuple with the Acl field value
-// and a boolean to check if the value has been set.
-// Deprecated
-func (o *CreateInstanceRequestPayload) GetAclOk() (ret CreateInstanceRequestPayloadGetAclRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetAclAttributeTypeOk(o.Acl)
-}
-
-// SetAcl sets field value
-// Deprecated
-func (o *CreateInstanceRequestPayload) SetAcl(v CreateInstanceRequestPayloadGetAclRetType) {
- setCreateInstanceRequestPayloadGetAclAttributeType(&o.Acl, v)
-}
-
-// GetBackupSchedule returns the BackupSchedule field value
-func (o *CreateInstanceRequestPayload) GetBackupSchedule() (ret CreateInstanceRequestPayloadGetBackupScheduleRetType) {
- ret, _ = o.GetBackupScheduleOk()
- return ret
-}
-
-// GetBackupScheduleOk returns a tuple with the BackupSchedule field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetBackupScheduleOk() (ret CreateInstanceRequestPayloadGetBackupScheduleRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule)
-}
-
-// SetBackupSchedule sets field value
-func (o *CreateInstanceRequestPayload) SetBackupSchedule(v CreateInstanceRequestPayloadGetBackupScheduleRetType) {
- setCreateInstanceRequestPayloadGetBackupScheduleAttributeType(&o.BackupSchedule, v)
-}
-
-// GetEncryption returns the Encryption field value if set, zero value otherwise.
-func (o *CreateInstanceRequestPayload) GetEncryption() (res CreateInstanceRequestPayloadGetEncryptionRetType) {
- res, _ = o.GetEncryptionOk()
- return
-}
-
-// GetEncryptionOk returns a tuple with the Encryption field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetEncryptionOk() (ret CreateInstanceRequestPayloadGetEncryptionRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetEncryptionAttributeTypeOk(o.Encryption)
-}
-
-// HasEncryption returns a boolean if a field has been set.
-func (o *CreateInstanceRequestPayload) HasEncryption() bool {
- _, ok := o.GetEncryptionOk()
- return ok
-}
-
-// SetEncryption gets a reference to the given InstanceEncryption and assigns it to the Encryption field.
-func (o *CreateInstanceRequestPayload) SetEncryption(v CreateInstanceRequestPayloadGetEncryptionRetType) {
- setCreateInstanceRequestPayloadGetEncryptionAttributeType(&o.Encryption, v)
-}
-
-// GetFlavorId returns the FlavorId field value
-func (o *CreateInstanceRequestPayload) GetFlavorId() (ret CreateInstanceRequestPayloadGetFlavorIdRetType) {
- ret, _ = o.GetFlavorIdOk()
- return ret
-}
-
-// GetFlavorIdOk returns a tuple with the FlavorId field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetFlavorIdOk() (ret CreateInstanceRequestPayloadGetFlavorIdRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId)
-}
-
-// SetFlavorId sets field value
-func (o *CreateInstanceRequestPayload) SetFlavorId(v CreateInstanceRequestPayloadGetFlavorIdRetType) {
- setCreateInstanceRequestPayloadGetFlavorIdAttributeType(&o.FlavorId, v)
-}
-
-// GetName returns the Name field value
-func (o *CreateInstanceRequestPayload) GetName() (ret CreateInstanceRequestPayloadGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetNameOk() (ret CreateInstanceRequestPayloadGetNameRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *CreateInstanceRequestPayload) SetName(v CreateInstanceRequestPayloadGetNameRetType) {
- setCreateInstanceRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetNetwork returns the Network field value if set, zero value otherwise.
-func (o *CreateInstanceRequestPayload) GetNetwork() (res CreateInstanceRequestPayloadGetNetworkRetType) {
- res, _ = o.GetNetworkOk()
- return
-}
-
-// GetNetworkOk returns a tuple with the Network field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetNetworkOk() (ret CreateInstanceRequestPayloadGetNetworkRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetNetworkAttributeTypeOk(o.Network)
-}
-
-// HasNetwork returns a boolean if a field has been set.
-func (o *CreateInstanceRequestPayload) HasNetwork() bool {
- _, ok := o.GetNetworkOk()
- return ok
-}
-
-// SetNetwork gets a reference to the given CreateInstanceRequestPayloadNetwork and assigns it to the Network field.
-func (o *CreateInstanceRequestPayload) SetNetwork(v CreateInstanceRequestPayloadGetNetworkRetType) {
- setCreateInstanceRequestPayloadGetNetworkAttributeType(&o.Network, v)
-}
-
-// GetRetentionDays returns the RetentionDays field value
-func (o *CreateInstanceRequestPayload) GetRetentionDays() (ret CreateInstanceRequestPayloadGetRetentionDaysRetType) {
- ret, _ = o.GetRetentionDaysOk()
- return ret
-}
-
-// GetRetentionDaysOk returns a tuple with the RetentionDays field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetRetentionDaysOk() (ret CreateInstanceRequestPayloadGetRetentionDaysRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays)
-}
-
-// SetRetentionDays sets field value
-func (o *CreateInstanceRequestPayload) SetRetentionDays(v CreateInstanceRequestPayloadGetRetentionDaysRetType) {
- setCreateInstanceRequestPayloadGetRetentionDaysAttributeType(&o.RetentionDays, v)
-}
-
-// GetStorage returns the Storage field value
-func (o *CreateInstanceRequestPayload) GetStorage() (ret CreateInstanceRequestPayloadGetStorageRetType) {
- ret, _ = o.GetStorageOk()
- return ret
-}
-
-// GetStorageOk returns a tuple with the Storage field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetStorageOk() (ret CreateInstanceRequestPayloadGetStorageRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetStorageAttributeTypeOk(o.Storage)
-}
-
-// SetStorage sets field value
-func (o *CreateInstanceRequestPayload) SetStorage(v CreateInstanceRequestPayloadGetStorageRetType) {
- setCreateInstanceRequestPayloadGetStorageAttributeType(&o.Storage, v)
-}
-
-// GetVersion returns the Version field value
-func (o *CreateInstanceRequestPayload) GetVersion() (ret CreateInstanceRequestPayloadGetVersionRetType) {
- ret, _ = o.GetVersionOk()
- return ret
-}
-
-// GetVersionOk returns a tuple with the Version field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayload) GetVersionOk() (ret CreateInstanceRequestPayloadGetVersionRetType, ok bool) {
- return getCreateInstanceRequestPayloadGetVersionAttributeTypeOk(o.Version)
-}
-
-// SetVersion sets field value
-func (o *CreateInstanceRequestPayload) SetVersion(v CreateInstanceRequestPayloadGetVersionRetType) {
- setCreateInstanceRequestPayloadGetVersionAttributeType(&o.Version, v)
-}
-
-func (o CreateInstanceRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateInstanceRequestPayloadGetAclAttributeTypeOk(o.Acl); ok {
- toSerialize["Acl"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule); ok {
- toSerialize["BackupSchedule"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetEncryptionAttributeTypeOk(o.Encryption); ok {
- toSerialize["Encryption"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId); ok {
- toSerialize["FlavorId"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetNetworkAttributeTypeOk(o.Network); ok {
- toSerialize["Network"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays); ok {
- toSerialize["RetentionDays"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetStorageAttributeTypeOk(o.Storage); ok {
- toSerialize["Storage"] = val
- }
- if val, ok := getCreateInstanceRequestPayloadGetVersionAttributeTypeOk(o.Version); ok {
- toSerialize["Version"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateInstanceRequestPayload struct {
- value *CreateInstanceRequestPayload
- isSet bool
-}
-
-func (v NullableCreateInstanceRequestPayload) Get() *CreateInstanceRequestPayload {
- return v.value
-}
-
-func (v *NullableCreateInstanceRequestPayload) Set(val *CreateInstanceRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateInstanceRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateInstanceRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateInstanceRequestPayload(val *CreateInstanceRequestPayload) *NullableCreateInstanceRequestPayload {
- return &NullableCreateInstanceRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableCreateInstanceRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateInstanceRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_create_instance_request_payload_network.go b/pkg/sqlserverflexalpha/model_create_instance_request_payload_network.go
deleted file mode 100644
index 816601d3..00000000
--- a/pkg/sqlserverflexalpha/model_create_instance_request_payload_network.go
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateInstanceRequestPayloadNetwork type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateInstanceRequestPayloadNetwork{}
-
-/*
- types and functions for accessScope
-*/
-
-// isEnumRef
-type CreateInstanceRequestPayloadNetworkGetAccessScopeAttributeType = *InstanceNetworkAccessScope
-type CreateInstanceRequestPayloadNetworkGetAccessScopeArgType = InstanceNetworkAccessScope
-type CreateInstanceRequestPayloadNetworkGetAccessScopeRetType = InstanceNetworkAccessScope
-
-func getCreateInstanceRequestPayloadNetworkGetAccessScopeAttributeTypeOk(arg CreateInstanceRequestPayloadNetworkGetAccessScopeAttributeType) (ret CreateInstanceRequestPayloadNetworkGetAccessScopeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceRequestPayloadNetworkGetAccessScopeAttributeType(arg *CreateInstanceRequestPayloadNetworkGetAccessScopeAttributeType, val CreateInstanceRequestPayloadNetworkGetAccessScopeRetType) {
- *arg = &val
-}
-
-// CreateInstanceRequestPayloadNetwork the network configuration of the instance.
-type CreateInstanceRequestPayloadNetwork struct {
- AccessScope CreateInstanceRequestPayloadNetworkGetAccessScopeAttributeType `json:"accessScope,omitempty"`
-}
-
-// NewCreateInstanceRequestPayloadNetwork instantiates a new CreateInstanceRequestPayloadNetwork object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateInstanceRequestPayloadNetwork() *CreateInstanceRequestPayloadNetwork {
- this := CreateInstanceRequestPayloadNetwork{}
- return &this
-}
-
-// NewCreateInstanceRequestPayloadNetworkWithDefaults instantiates a new CreateInstanceRequestPayloadNetwork object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateInstanceRequestPayloadNetworkWithDefaults() *CreateInstanceRequestPayloadNetwork {
- this := CreateInstanceRequestPayloadNetwork{}
- var accessScope InstanceNetworkAccessScope = INSTANCENETWORKACCESSSCOPE_PUBLIC
- this.AccessScope = &accessScope
- return &this
-}
-
-// GetAccessScope returns the AccessScope field value if set, zero value otherwise.
-func (o *CreateInstanceRequestPayloadNetwork) GetAccessScope() (res CreateInstanceRequestPayloadNetworkGetAccessScopeRetType) {
- res, _ = o.GetAccessScopeOk()
- return
-}
-
-// GetAccessScopeOk returns a tuple with the AccessScope field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceRequestPayloadNetwork) GetAccessScopeOk() (ret CreateInstanceRequestPayloadNetworkGetAccessScopeRetType, ok bool) {
- return getCreateInstanceRequestPayloadNetworkGetAccessScopeAttributeTypeOk(o.AccessScope)
-}
-
-// HasAccessScope returns a boolean if a field has been set.
-func (o *CreateInstanceRequestPayloadNetwork) HasAccessScope() bool {
- _, ok := o.GetAccessScopeOk()
- return ok
-}
-
-// SetAccessScope gets a reference to the given InstanceNetworkAccessScope and assigns it to the AccessScope field.
-func (o *CreateInstanceRequestPayloadNetwork) SetAccessScope(v CreateInstanceRequestPayloadNetworkGetAccessScopeRetType) {
- setCreateInstanceRequestPayloadNetworkGetAccessScopeAttributeType(&o.AccessScope, v)
-}
-
-func (o CreateInstanceRequestPayloadNetwork) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateInstanceRequestPayloadNetworkGetAccessScopeAttributeTypeOk(o.AccessScope); ok {
- toSerialize["AccessScope"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateInstanceRequestPayloadNetwork struct {
- value *CreateInstanceRequestPayloadNetwork
- isSet bool
-}
-
-func (v NullableCreateInstanceRequestPayloadNetwork) Get() *CreateInstanceRequestPayloadNetwork {
- return v.value
-}
-
-func (v *NullableCreateInstanceRequestPayloadNetwork) Set(val *CreateInstanceRequestPayloadNetwork) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateInstanceRequestPayloadNetwork) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateInstanceRequestPayloadNetwork) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateInstanceRequestPayloadNetwork(val *CreateInstanceRequestPayloadNetwork) *NullableCreateInstanceRequestPayloadNetwork {
- return &NullableCreateInstanceRequestPayloadNetwork{value: val, isSet: true}
-}
-
-func (v NullableCreateInstanceRequestPayloadNetwork) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateInstanceRequestPayloadNetwork) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_create_instance_request_payload_network_test.go b/pkg/sqlserverflexalpha/model_create_instance_request_payload_network_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_create_instance_request_payload_network_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_create_instance_request_payload_test.go b/pkg/sqlserverflexalpha/model_create_instance_request_payload_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_create_instance_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_create_instance_response.go b/pkg/sqlserverflexalpha/model_create_instance_response.go
deleted file mode 100644
index cce13f0f..00000000
--- a/pkg/sqlserverflexalpha/model_create_instance_response.go
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateInstanceResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateInstanceResponse{}
-
-/*
- types and functions for id
-*/
-
-// isNotNullableString
-type CreateInstanceResponseGetIdAttributeType = *string
-
-func getCreateInstanceResponseGetIdAttributeTypeOk(arg CreateInstanceResponseGetIdAttributeType) (ret CreateInstanceResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateInstanceResponseGetIdAttributeType(arg *CreateInstanceResponseGetIdAttributeType, val CreateInstanceResponseGetIdRetType) {
- *arg = &val
-}
-
-type CreateInstanceResponseGetIdArgType = string
-type CreateInstanceResponseGetIdRetType = string
-
-// CreateInstanceResponse struct for CreateInstanceResponse
-type CreateInstanceResponse struct {
- // The ID of the instance.
- // REQUIRED
- Id CreateInstanceResponseGetIdAttributeType `json:"id" required:"true"`
-}
-
-type _CreateInstanceResponse CreateInstanceResponse
-
-// NewCreateInstanceResponse instantiates a new CreateInstanceResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateInstanceResponse(id CreateInstanceResponseGetIdArgType) *CreateInstanceResponse {
- this := CreateInstanceResponse{}
- setCreateInstanceResponseGetIdAttributeType(&this.Id, id)
- return &this
-}
-
-// NewCreateInstanceResponseWithDefaults instantiates a new CreateInstanceResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateInstanceResponseWithDefaults() *CreateInstanceResponse {
- this := CreateInstanceResponse{}
- return &this
-}
-
-// GetId returns the Id field value
-func (o *CreateInstanceResponse) GetId() (ret CreateInstanceResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *CreateInstanceResponse) GetIdOk() (ret CreateInstanceResponseGetIdRetType, ok bool) {
- return getCreateInstanceResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *CreateInstanceResponse) SetId(v CreateInstanceResponseGetIdRetType) {
- setCreateInstanceResponseGetIdAttributeType(&o.Id, v)
-}
-
-func (o CreateInstanceResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateInstanceResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateInstanceResponse struct {
- value *CreateInstanceResponse
- isSet bool
-}
-
-func (v NullableCreateInstanceResponse) Get() *CreateInstanceResponse {
- return v.value
-}
-
-func (v *NullableCreateInstanceResponse) Set(val *CreateInstanceResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateInstanceResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateInstanceResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateInstanceResponse(val *CreateInstanceResponse) *NullableCreateInstanceResponse {
- return &NullableCreateInstanceResponse{value: val, isSet: true}
-}
-
-func (v NullableCreateInstanceResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateInstanceResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_create_instance_response_test.go b/pkg/sqlserverflexalpha/model_create_instance_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_create_instance_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_create_user_request_payload.go b/pkg/sqlserverflexalpha/model_create_user_request_payload.go
deleted file mode 100644
index 9f169e65..00000000
--- a/pkg/sqlserverflexalpha/model_create_user_request_payload.go
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateUserRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateUserRequestPayload{}
-
-/*
- types and functions for default_database
-*/
-
-// isNotNullableString
-type CreateUserRequestPayloadGetDefaultDatabaseAttributeType = *string
-
-func getCreateUserRequestPayloadGetDefaultDatabaseAttributeTypeOk(arg CreateUserRequestPayloadGetDefaultDatabaseAttributeType) (ret CreateUserRequestPayloadGetDefaultDatabaseRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserRequestPayloadGetDefaultDatabaseAttributeType(arg *CreateUserRequestPayloadGetDefaultDatabaseAttributeType, val CreateUserRequestPayloadGetDefaultDatabaseRetType) {
- *arg = &val
-}
-
-type CreateUserRequestPayloadGetDefaultDatabaseArgType = string
-type CreateUserRequestPayloadGetDefaultDatabaseRetType = string
-
-/*
- types and functions for roles
-*/
-
-// isArray
-type CreateUserRequestPayloadGetRolesAttributeType = *[]UserRole
-type CreateUserRequestPayloadGetRolesArgType = []UserRole
-type CreateUserRequestPayloadGetRolesRetType = []UserRole
-
-func getCreateUserRequestPayloadGetRolesAttributeTypeOk(arg CreateUserRequestPayloadGetRolesAttributeType) (ret CreateUserRequestPayloadGetRolesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserRequestPayloadGetRolesAttributeType(arg *CreateUserRequestPayloadGetRolesAttributeType, val CreateUserRequestPayloadGetRolesRetType) {
- *arg = &val
-}
-
-/*
- types and functions for username
-*/
-
-// isNotNullableString
-type CreateUserRequestPayloadGetUsernameAttributeType = *string
-
-func getCreateUserRequestPayloadGetUsernameAttributeTypeOk(arg CreateUserRequestPayloadGetUsernameAttributeType) (ret CreateUserRequestPayloadGetUsernameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserRequestPayloadGetUsernameAttributeType(arg *CreateUserRequestPayloadGetUsernameAttributeType, val CreateUserRequestPayloadGetUsernameRetType) {
- *arg = &val
-}
-
-type CreateUserRequestPayloadGetUsernameArgType = string
-type CreateUserRequestPayloadGetUsernameRetType = string
-
-// CreateUserRequestPayload struct for CreateUserRequestPayload
-type CreateUserRequestPayload struct {
- // The default database for a user of the instance.
- DefaultDatabase CreateUserRequestPayloadGetDefaultDatabaseAttributeType `json:"default_database,omitempty"`
- // A list containing the user roles for the instance.
- // REQUIRED
- Roles CreateUserRequestPayloadGetRolesAttributeType `json:"roles" required:"true"`
- // The name of the user.
- // REQUIRED
- Username CreateUserRequestPayloadGetUsernameAttributeType `json:"username" required:"true"`
-}
-
-type _CreateUserRequestPayload CreateUserRequestPayload
-
-// NewCreateUserRequestPayload instantiates a new CreateUserRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateUserRequestPayload(roles CreateUserRequestPayloadGetRolesArgType, username CreateUserRequestPayloadGetUsernameArgType) *CreateUserRequestPayload {
- this := CreateUserRequestPayload{}
- setCreateUserRequestPayloadGetRolesAttributeType(&this.Roles, roles)
- setCreateUserRequestPayloadGetUsernameAttributeType(&this.Username, username)
- return &this
-}
-
-// NewCreateUserRequestPayloadWithDefaults instantiates a new CreateUserRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateUserRequestPayloadWithDefaults() *CreateUserRequestPayload {
- this := CreateUserRequestPayload{}
- return &this
-}
-
-// GetDefaultDatabase returns the DefaultDatabase field value if set, zero value otherwise.
-func (o *CreateUserRequestPayload) GetDefaultDatabase() (res CreateUserRequestPayloadGetDefaultDatabaseRetType) {
- res, _ = o.GetDefaultDatabaseOk()
- return
-}
-
-// GetDefaultDatabaseOk returns a tuple with the DefaultDatabase field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *CreateUserRequestPayload) GetDefaultDatabaseOk() (ret CreateUserRequestPayloadGetDefaultDatabaseRetType, ok bool) {
- return getCreateUserRequestPayloadGetDefaultDatabaseAttributeTypeOk(o.DefaultDatabase)
-}
-
-// HasDefaultDatabase returns a boolean if a field has been set.
-func (o *CreateUserRequestPayload) HasDefaultDatabase() bool {
- _, ok := o.GetDefaultDatabaseOk()
- return ok
-}
-
-// SetDefaultDatabase gets a reference to the given string and assigns it to the DefaultDatabase field.
-func (o *CreateUserRequestPayload) SetDefaultDatabase(v CreateUserRequestPayloadGetDefaultDatabaseRetType) {
- setCreateUserRequestPayloadGetDefaultDatabaseAttributeType(&o.DefaultDatabase, v)
-}
-
-// GetRoles returns the Roles field value
-func (o *CreateUserRequestPayload) GetRoles() (ret CreateUserRequestPayloadGetRolesRetType) {
- ret, _ = o.GetRolesOk()
- return ret
-}
-
-// GetRolesOk returns a tuple with the Roles field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserRequestPayload) GetRolesOk() (ret CreateUserRequestPayloadGetRolesRetType, ok bool) {
- return getCreateUserRequestPayloadGetRolesAttributeTypeOk(o.Roles)
-}
-
-// SetRoles sets field value
-func (o *CreateUserRequestPayload) SetRoles(v CreateUserRequestPayloadGetRolesRetType) {
- setCreateUserRequestPayloadGetRolesAttributeType(&o.Roles, v)
-}
-
-// GetUsername returns the Username field value
-func (o *CreateUserRequestPayload) GetUsername() (ret CreateUserRequestPayloadGetUsernameRetType) {
- ret, _ = o.GetUsernameOk()
- return ret
-}
-
-// GetUsernameOk returns a tuple with the Username field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserRequestPayload) GetUsernameOk() (ret CreateUserRequestPayloadGetUsernameRetType, ok bool) {
- return getCreateUserRequestPayloadGetUsernameAttributeTypeOk(o.Username)
-}
-
-// SetUsername sets field value
-func (o *CreateUserRequestPayload) SetUsername(v CreateUserRequestPayloadGetUsernameRetType) {
- setCreateUserRequestPayloadGetUsernameAttributeType(&o.Username, v)
-}
-
-func (o CreateUserRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateUserRequestPayloadGetDefaultDatabaseAttributeTypeOk(o.DefaultDatabase); ok {
- toSerialize["DefaultDatabase"] = val
- }
- if val, ok := getCreateUserRequestPayloadGetRolesAttributeTypeOk(o.Roles); ok {
- toSerialize["Roles"] = val
- }
- if val, ok := getCreateUserRequestPayloadGetUsernameAttributeTypeOk(o.Username); ok {
- toSerialize["Username"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateUserRequestPayload struct {
- value *CreateUserRequestPayload
- isSet bool
-}
-
-func (v NullableCreateUserRequestPayload) Get() *CreateUserRequestPayload {
- return v.value
-}
-
-func (v *NullableCreateUserRequestPayload) Set(val *CreateUserRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateUserRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateUserRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateUserRequestPayload(val *CreateUserRequestPayload) *NullableCreateUserRequestPayload {
- return &NullableCreateUserRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableCreateUserRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateUserRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_create_user_request_payload_test.go b/pkg/sqlserverflexalpha/model_create_user_request_payload_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_create_user_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_create_user_response.go b/pkg/sqlserverflexalpha/model_create_user_response.go
deleted file mode 100644
index b25f632b..00000000
--- a/pkg/sqlserverflexalpha/model_create_user_response.go
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the CreateUserResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &CreateUserResponse{}
-
-/*
- types and functions for default_database
-*/
-
-// isNotNullableString
-type CreateUserResponseGetDefaultDatabaseAttributeType = *string
-
-func getCreateUserResponseGetDefaultDatabaseAttributeTypeOk(arg CreateUserResponseGetDefaultDatabaseAttributeType) (ret CreateUserResponseGetDefaultDatabaseRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetDefaultDatabaseAttributeType(arg *CreateUserResponseGetDefaultDatabaseAttributeType, val CreateUserResponseGetDefaultDatabaseRetType) {
- *arg = &val
-}
-
-type CreateUserResponseGetDefaultDatabaseArgType = string
-type CreateUserResponseGetDefaultDatabaseRetType = string
-
-/*
- types and functions for host
-*/
-
-// isNotNullableString
-type CreateUserResponseGetHostAttributeType = *string
-
-func getCreateUserResponseGetHostAttributeTypeOk(arg CreateUserResponseGetHostAttributeType) (ret CreateUserResponseGetHostRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetHostAttributeType(arg *CreateUserResponseGetHostAttributeType, val CreateUserResponseGetHostRetType) {
- *arg = &val
-}
-
-type CreateUserResponseGetHostArgType = string
-type CreateUserResponseGetHostRetType = string
-
-/*
- types and functions for id
-*/
-
-// isLong
-type CreateUserResponseGetIdAttributeType = *int64
-type CreateUserResponseGetIdArgType = int64
-type CreateUserResponseGetIdRetType = int64
-
-func getCreateUserResponseGetIdAttributeTypeOk(arg CreateUserResponseGetIdAttributeType) (ret CreateUserResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetIdAttributeType(arg *CreateUserResponseGetIdAttributeType, val CreateUserResponseGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for password
-*/
-
-// isNotNullableString
-type CreateUserResponseGetPasswordAttributeType = *string
-
-func getCreateUserResponseGetPasswordAttributeTypeOk(arg CreateUserResponseGetPasswordAttributeType) (ret CreateUserResponseGetPasswordRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetPasswordAttributeType(arg *CreateUserResponseGetPasswordAttributeType, val CreateUserResponseGetPasswordRetType) {
- *arg = &val
-}
-
-type CreateUserResponseGetPasswordArgType = string
-type CreateUserResponseGetPasswordRetType = string
-
-/*
- types and functions for port
-*/
-
-// isInteger
-type CreateUserResponseGetPortAttributeType = *int64
-type CreateUserResponseGetPortArgType = int64
-type CreateUserResponseGetPortRetType = int64
-
-func getCreateUserResponseGetPortAttributeTypeOk(arg CreateUserResponseGetPortAttributeType) (ret CreateUserResponseGetPortRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetPortAttributeType(arg *CreateUserResponseGetPortAttributeType, val CreateUserResponseGetPortRetType) {
- *arg = &val
-}
-
-/*
- types and functions for roles
-*/
-
-// isArray
-type CreateUserResponseGetRolesAttributeType = *[]UserRole
-type CreateUserResponseGetRolesArgType = []UserRole
-type CreateUserResponseGetRolesRetType = []UserRole
-
-func getCreateUserResponseGetRolesAttributeTypeOk(arg CreateUserResponseGetRolesAttributeType) (ret CreateUserResponseGetRolesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetRolesAttributeType(arg *CreateUserResponseGetRolesAttributeType, val CreateUserResponseGetRolesRetType) {
- *arg = &val
-}
-
-/*
- types and functions for status
-*/
-
-// isNotNullableString
-type CreateUserResponseGetStatusAttributeType = *string
-
-func getCreateUserResponseGetStatusAttributeTypeOk(arg CreateUserResponseGetStatusAttributeType) (ret CreateUserResponseGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetStatusAttributeType(arg *CreateUserResponseGetStatusAttributeType, val CreateUserResponseGetStatusRetType) {
- *arg = &val
-}
-
-type CreateUserResponseGetStatusArgType = string
-type CreateUserResponseGetStatusRetType = string
-
-/*
- types and functions for uri
-*/
-
-// isNotNullableString
-type CreateUserResponseGetUriAttributeType = *string
-
-func getCreateUserResponseGetUriAttributeTypeOk(arg CreateUserResponseGetUriAttributeType) (ret CreateUserResponseGetUriRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetUriAttributeType(arg *CreateUserResponseGetUriAttributeType, val CreateUserResponseGetUriRetType) {
- *arg = &val
-}
-
-type CreateUserResponseGetUriArgType = string
-type CreateUserResponseGetUriRetType = string
-
-/*
- types and functions for username
-*/
-
-// isNotNullableString
-type CreateUserResponseGetUsernameAttributeType = *string
-
-func getCreateUserResponseGetUsernameAttributeTypeOk(arg CreateUserResponseGetUsernameAttributeType) (ret CreateUserResponseGetUsernameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setCreateUserResponseGetUsernameAttributeType(arg *CreateUserResponseGetUsernameAttributeType, val CreateUserResponseGetUsernameRetType) {
- *arg = &val
-}
-
-type CreateUserResponseGetUsernameArgType = string
-type CreateUserResponseGetUsernameRetType = string
-
-// CreateUserResponse struct for CreateUserResponse
-type CreateUserResponse struct {
- // The default database for a user of the instance.
- // REQUIRED
- DefaultDatabase CreateUserResponseGetDefaultDatabaseAttributeType `json:"default_database" required:"true"`
- // The host of the instance in which the user belongs to.
- // REQUIRED
- Host CreateUserResponseGetHostAttributeType `json:"host" required:"true"`
- // The ID of the user.
- // REQUIRED
- Id CreateUserResponseGetIdAttributeType `json:"id" required:"true"`
- // The password for the user.
- // REQUIRED
- Password CreateUserResponseGetPasswordAttributeType `json:"password" required:"true"`
- // The port of the instance in which the user belongs to.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- Port CreateUserResponseGetPortAttributeType `json:"port" required:"true"`
- // REQUIRED
- Roles CreateUserResponseGetRolesAttributeType `json:"roles" required:"true"`
- // The current status of the user.
- // REQUIRED
- Status CreateUserResponseGetStatusAttributeType `json:"status" required:"true"`
- // The connection string for the user to the instance.
- // REQUIRED
- Uri CreateUserResponseGetUriAttributeType `json:"uri" required:"true"`
- // The name of the user.
- // REQUIRED
- Username CreateUserResponseGetUsernameAttributeType `json:"username" required:"true"`
-}
-
-type _CreateUserResponse CreateUserResponse
-
-// NewCreateUserResponse instantiates a new CreateUserResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewCreateUserResponse(defaultDatabase CreateUserResponseGetDefaultDatabaseArgType, host CreateUserResponseGetHostArgType, id CreateUserResponseGetIdArgType, password CreateUserResponseGetPasswordArgType, port CreateUserResponseGetPortArgType, roles CreateUserResponseGetRolesArgType, status CreateUserResponseGetStatusArgType, uri CreateUserResponseGetUriArgType, username CreateUserResponseGetUsernameArgType) *CreateUserResponse {
- this := CreateUserResponse{}
- setCreateUserResponseGetDefaultDatabaseAttributeType(&this.DefaultDatabase, defaultDatabase)
- setCreateUserResponseGetHostAttributeType(&this.Host, host)
- setCreateUserResponseGetIdAttributeType(&this.Id, id)
- setCreateUserResponseGetPasswordAttributeType(&this.Password, password)
- setCreateUserResponseGetPortAttributeType(&this.Port, port)
- setCreateUserResponseGetRolesAttributeType(&this.Roles, roles)
- setCreateUserResponseGetStatusAttributeType(&this.Status, status)
- setCreateUserResponseGetUriAttributeType(&this.Uri, uri)
- setCreateUserResponseGetUsernameAttributeType(&this.Username, username)
- return &this
-}
-
-// NewCreateUserResponseWithDefaults instantiates a new CreateUserResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewCreateUserResponseWithDefaults() *CreateUserResponse {
- this := CreateUserResponse{}
- return &this
-}
-
-// GetDefaultDatabase returns the DefaultDatabase field value
-func (o *CreateUserResponse) GetDefaultDatabase() (ret CreateUserResponseGetDefaultDatabaseRetType) {
- ret, _ = o.GetDefaultDatabaseOk()
- return ret
-}
-
-// GetDefaultDatabaseOk returns a tuple with the DefaultDatabase field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetDefaultDatabaseOk() (ret CreateUserResponseGetDefaultDatabaseRetType, ok bool) {
- return getCreateUserResponseGetDefaultDatabaseAttributeTypeOk(o.DefaultDatabase)
-}
-
-// SetDefaultDatabase sets field value
-func (o *CreateUserResponse) SetDefaultDatabase(v CreateUserResponseGetDefaultDatabaseRetType) {
- setCreateUserResponseGetDefaultDatabaseAttributeType(&o.DefaultDatabase, v)
-}
-
-// GetHost returns the Host field value
-func (o *CreateUserResponse) GetHost() (ret CreateUserResponseGetHostRetType) {
- ret, _ = o.GetHostOk()
- return ret
-}
-
-// GetHostOk returns a tuple with the Host field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetHostOk() (ret CreateUserResponseGetHostRetType, ok bool) {
- return getCreateUserResponseGetHostAttributeTypeOk(o.Host)
-}
-
-// SetHost sets field value
-func (o *CreateUserResponse) SetHost(v CreateUserResponseGetHostRetType) {
- setCreateUserResponseGetHostAttributeType(&o.Host, v)
-}
-
-// GetId returns the Id field value
-func (o *CreateUserResponse) GetId() (ret CreateUserResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetIdOk() (ret CreateUserResponseGetIdRetType, ok bool) {
- return getCreateUserResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *CreateUserResponse) SetId(v CreateUserResponseGetIdRetType) {
- setCreateUserResponseGetIdAttributeType(&o.Id, v)
-}
-
-// GetPassword returns the Password field value
-func (o *CreateUserResponse) GetPassword() (ret CreateUserResponseGetPasswordRetType) {
- ret, _ = o.GetPasswordOk()
- return ret
-}
-
-// GetPasswordOk returns a tuple with the Password field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetPasswordOk() (ret CreateUserResponseGetPasswordRetType, ok bool) {
- return getCreateUserResponseGetPasswordAttributeTypeOk(o.Password)
-}
-
-// SetPassword sets field value
-func (o *CreateUserResponse) SetPassword(v CreateUserResponseGetPasswordRetType) {
- setCreateUserResponseGetPasswordAttributeType(&o.Password, v)
-}
-
-// GetPort returns the Port field value
-func (o *CreateUserResponse) GetPort() (ret CreateUserResponseGetPortRetType) {
- ret, _ = o.GetPortOk()
- return ret
-}
-
-// GetPortOk returns a tuple with the Port field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetPortOk() (ret CreateUserResponseGetPortRetType, ok bool) {
- return getCreateUserResponseGetPortAttributeTypeOk(o.Port)
-}
-
-// SetPort sets field value
-func (o *CreateUserResponse) SetPort(v CreateUserResponseGetPortRetType) {
- setCreateUserResponseGetPortAttributeType(&o.Port, v)
-}
-
-// GetRoles returns the Roles field value
-func (o *CreateUserResponse) GetRoles() (ret CreateUserResponseGetRolesRetType) {
- ret, _ = o.GetRolesOk()
- return ret
-}
-
-// GetRolesOk returns a tuple with the Roles field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetRolesOk() (ret CreateUserResponseGetRolesRetType, ok bool) {
- return getCreateUserResponseGetRolesAttributeTypeOk(o.Roles)
-}
-
-// SetRoles sets field value
-func (o *CreateUserResponse) SetRoles(v CreateUserResponseGetRolesRetType) {
- setCreateUserResponseGetRolesAttributeType(&o.Roles, v)
-}
-
-// GetStatus returns the Status field value
-func (o *CreateUserResponse) GetStatus() (ret CreateUserResponseGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetStatusOk() (ret CreateUserResponseGetStatusRetType, ok bool) {
- return getCreateUserResponseGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *CreateUserResponse) SetStatus(v CreateUserResponseGetStatusRetType) {
- setCreateUserResponseGetStatusAttributeType(&o.Status, v)
-}
-
-// GetUri returns the Uri field value
-func (o *CreateUserResponse) GetUri() (ret CreateUserResponseGetUriRetType) {
- ret, _ = o.GetUriOk()
- return ret
-}
-
-// GetUriOk returns a tuple with the Uri field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetUriOk() (ret CreateUserResponseGetUriRetType, ok bool) {
- return getCreateUserResponseGetUriAttributeTypeOk(o.Uri)
-}
-
-// SetUri sets field value
-func (o *CreateUserResponse) SetUri(v CreateUserResponseGetUriRetType) {
- setCreateUserResponseGetUriAttributeType(&o.Uri, v)
-}
-
-// GetUsername returns the Username field value
-func (o *CreateUserResponse) GetUsername() (ret CreateUserResponseGetUsernameRetType) {
- ret, _ = o.GetUsernameOk()
- return ret
-}
-
-// GetUsernameOk returns a tuple with the Username field value
-// and a boolean to check if the value has been set.
-func (o *CreateUserResponse) GetUsernameOk() (ret CreateUserResponseGetUsernameRetType, ok bool) {
- return getCreateUserResponseGetUsernameAttributeTypeOk(o.Username)
-}
-
-// SetUsername sets field value
-func (o *CreateUserResponse) SetUsername(v CreateUserResponseGetUsernameRetType) {
- setCreateUserResponseGetUsernameAttributeType(&o.Username, v)
-}
-
-func (o CreateUserResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getCreateUserResponseGetDefaultDatabaseAttributeTypeOk(o.DefaultDatabase); ok {
- toSerialize["DefaultDatabase"] = val
- }
- if val, ok := getCreateUserResponseGetHostAttributeTypeOk(o.Host); ok {
- toSerialize["Host"] = val
- }
- if val, ok := getCreateUserResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getCreateUserResponseGetPasswordAttributeTypeOk(o.Password); ok {
- toSerialize["Password"] = val
- }
- if val, ok := getCreateUserResponseGetPortAttributeTypeOk(o.Port); ok {
- toSerialize["Port"] = val
- }
- if val, ok := getCreateUserResponseGetRolesAttributeTypeOk(o.Roles); ok {
- toSerialize["Roles"] = val
- }
- if val, ok := getCreateUserResponseGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- if val, ok := getCreateUserResponseGetUriAttributeTypeOk(o.Uri); ok {
- toSerialize["Uri"] = val
- }
- if val, ok := getCreateUserResponseGetUsernameAttributeTypeOk(o.Username); ok {
- toSerialize["Username"] = val
- }
- return toSerialize, nil
-}
-
-type NullableCreateUserResponse struct {
- value *CreateUserResponse
- isSet bool
-}
-
-func (v NullableCreateUserResponse) Get() *CreateUserResponse {
- return v.value
-}
-
-func (v *NullableCreateUserResponse) Set(val *CreateUserResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableCreateUserResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableCreateUserResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableCreateUserResponse(val *CreateUserResponse) *NullableCreateUserResponse {
- return &NullableCreateUserResponse{value: val, isSet: true}
-}
-
-func (v NullableCreateUserResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableCreateUserResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_create_user_response_test.go b/pkg/sqlserverflexalpha/model_create_user_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_create_user_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_database_getcollation.go b/pkg/sqlserverflexalpha/model_database_getcollation.go
deleted file mode 100644
index 892a426f..00000000
--- a/pkg/sqlserverflexalpha/model_database_getcollation.go
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the DatabaseGetcollation type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &DatabaseGetcollation{}
-
-/*
- types and functions for collation_name
-*/
-
-// isNotNullableString
-type DatabaseGetcollationGetCollationNameAttributeType = *string
-
-func getDatabaseGetcollationGetCollationNameAttributeTypeOk(arg DatabaseGetcollationGetCollationNameAttributeType) (ret DatabaseGetcollationGetCollationNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setDatabaseGetcollationGetCollationNameAttributeType(arg *DatabaseGetcollationGetCollationNameAttributeType, val DatabaseGetcollationGetCollationNameRetType) {
- *arg = &val
-}
-
-type DatabaseGetcollationGetCollationNameArgType = string
-type DatabaseGetcollationGetCollationNameRetType = string
-
-/*
- types and functions for description
-*/
-
-// isNotNullableString
-type DatabaseGetcollationGetDescriptionAttributeType = *string
-
-func getDatabaseGetcollationGetDescriptionAttributeTypeOk(arg DatabaseGetcollationGetDescriptionAttributeType) (ret DatabaseGetcollationGetDescriptionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setDatabaseGetcollationGetDescriptionAttributeType(arg *DatabaseGetcollationGetDescriptionAttributeType, val DatabaseGetcollationGetDescriptionRetType) {
- *arg = &val
-}
-
-type DatabaseGetcollationGetDescriptionArgType = string
-type DatabaseGetcollationGetDescriptionRetType = string
-
-// DatabaseGetcollation struct for DatabaseGetcollation
-type DatabaseGetcollation struct {
- CollationName DatabaseGetcollationGetCollationNameAttributeType `json:"collation_name,omitempty"`
- Description DatabaseGetcollationGetDescriptionAttributeType `json:"description,omitempty"`
-}
-
-// NewDatabaseGetcollation instantiates a new DatabaseGetcollation object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewDatabaseGetcollation() *DatabaseGetcollation {
- this := DatabaseGetcollation{}
- return &this
-}
-
-// NewDatabaseGetcollationWithDefaults instantiates a new DatabaseGetcollation object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewDatabaseGetcollationWithDefaults() *DatabaseGetcollation {
- this := DatabaseGetcollation{}
- return &this
-}
-
-// GetCollationName returns the CollationName field value if set, zero value otherwise.
-func (o *DatabaseGetcollation) GetCollationName() (res DatabaseGetcollationGetCollationNameRetType) {
- res, _ = o.GetCollationNameOk()
- return
-}
-
-// GetCollationNameOk returns a tuple with the CollationName field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *DatabaseGetcollation) GetCollationNameOk() (ret DatabaseGetcollationGetCollationNameRetType, ok bool) {
- return getDatabaseGetcollationGetCollationNameAttributeTypeOk(o.CollationName)
-}
-
-// HasCollationName returns a boolean if a field has been set.
-func (o *DatabaseGetcollation) HasCollationName() bool {
- _, ok := o.GetCollationNameOk()
- return ok
-}
-
-// SetCollationName gets a reference to the given string and assigns it to the CollationName field.
-func (o *DatabaseGetcollation) SetCollationName(v DatabaseGetcollationGetCollationNameRetType) {
- setDatabaseGetcollationGetCollationNameAttributeType(&o.CollationName, v)
-}
-
-// GetDescription returns the Description field value if set, zero value otherwise.
-func (o *DatabaseGetcollation) GetDescription() (res DatabaseGetcollationGetDescriptionRetType) {
- res, _ = o.GetDescriptionOk()
- return
-}
-
-// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *DatabaseGetcollation) GetDescriptionOk() (ret DatabaseGetcollationGetDescriptionRetType, ok bool) {
- return getDatabaseGetcollationGetDescriptionAttributeTypeOk(o.Description)
-}
-
-// HasDescription returns a boolean if a field has been set.
-func (o *DatabaseGetcollation) HasDescription() bool {
- _, ok := o.GetDescriptionOk()
- return ok
-}
-
-// SetDescription gets a reference to the given string and assigns it to the Description field.
-func (o *DatabaseGetcollation) SetDescription(v DatabaseGetcollationGetDescriptionRetType) {
- setDatabaseGetcollationGetDescriptionAttributeType(&o.Description, v)
-}
-
-func (o DatabaseGetcollation) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getDatabaseGetcollationGetCollationNameAttributeTypeOk(o.CollationName); ok {
- toSerialize["CollationName"] = val
- }
- if val, ok := getDatabaseGetcollationGetDescriptionAttributeTypeOk(o.Description); ok {
- toSerialize["Description"] = val
- }
- return toSerialize, nil
-}
-
-type NullableDatabaseGetcollation struct {
- value *DatabaseGetcollation
- isSet bool
-}
-
-func (v NullableDatabaseGetcollation) Get() *DatabaseGetcollation {
- return v.value
-}
-
-func (v *NullableDatabaseGetcollation) Set(val *DatabaseGetcollation) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableDatabaseGetcollation) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableDatabaseGetcollation) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableDatabaseGetcollation(val *DatabaseGetcollation) *NullableDatabaseGetcollation {
- return &NullableDatabaseGetcollation{value: val, isSet: true}
-}
-
-func (v NullableDatabaseGetcollation) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableDatabaseGetcollation) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_database_getcollation_test.go b/pkg/sqlserverflexalpha/model_database_getcollation_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_database_getcollation_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_database_getcompatibility.go b/pkg/sqlserverflexalpha/model_database_getcompatibility.go
deleted file mode 100644
index 65dedca7..00000000
--- a/pkg/sqlserverflexalpha/model_database_getcompatibility.go
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the DatabaseGetcompatibility type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &DatabaseGetcompatibility{}
-
-/*
- types and functions for compatibility_level
-*/
-
-// isInteger
-type DatabaseGetcompatibilityGetCompatibilityLevelAttributeType = *int64
-type DatabaseGetcompatibilityGetCompatibilityLevelArgType = int64
-type DatabaseGetcompatibilityGetCompatibilityLevelRetType = int64
-
-func getDatabaseGetcompatibilityGetCompatibilityLevelAttributeTypeOk(arg DatabaseGetcompatibilityGetCompatibilityLevelAttributeType) (ret DatabaseGetcompatibilityGetCompatibilityLevelRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setDatabaseGetcompatibilityGetCompatibilityLevelAttributeType(arg *DatabaseGetcompatibilityGetCompatibilityLevelAttributeType, val DatabaseGetcompatibilityGetCompatibilityLevelRetType) {
- *arg = &val
-}
-
-/*
- types and functions for description
-*/
-
-// isNotNullableString
-type DatabaseGetcompatibilityGetDescriptionAttributeType = *string
-
-func getDatabaseGetcompatibilityGetDescriptionAttributeTypeOk(arg DatabaseGetcompatibilityGetDescriptionAttributeType) (ret DatabaseGetcompatibilityGetDescriptionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setDatabaseGetcompatibilityGetDescriptionAttributeType(arg *DatabaseGetcompatibilityGetDescriptionAttributeType, val DatabaseGetcompatibilityGetDescriptionRetType) {
- *arg = &val
-}
-
-type DatabaseGetcompatibilityGetDescriptionArgType = string
-type DatabaseGetcompatibilityGetDescriptionRetType = string
-
-// DatabaseGetcompatibility struct for DatabaseGetcompatibility
-type DatabaseGetcompatibility struct {
- // Can be cast to int32 without loss of precision.
- CompatibilityLevel DatabaseGetcompatibilityGetCompatibilityLevelAttributeType `json:"compatibility_level,omitempty"`
- Description DatabaseGetcompatibilityGetDescriptionAttributeType `json:"description,omitempty"`
-}
-
-// NewDatabaseGetcompatibility instantiates a new DatabaseGetcompatibility object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewDatabaseGetcompatibility() *DatabaseGetcompatibility {
- this := DatabaseGetcompatibility{}
- return &this
-}
-
-// NewDatabaseGetcompatibilityWithDefaults instantiates a new DatabaseGetcompatibility object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewDatabaseGetcompatibilityWithDefaults() *DatabaseGetcompatibility {
- this := DatabaseGetcompatibility{}
- return &this
-}
-
-// GetCompatibilityLevel returns the CompatibilityLevel field value if set, zero value otherwise.
-func (o *DatabaseGetcompatibility) GetCompatibilityLevel() (res DatabaseGetcompatibilityGetCompatibilityLevelRetType) {
- res, _ = o.GetCompatibilityLevelOk()
- return
-}
-
-// GetCompatibilityLevelOk returns a tuple with the CompatibilityLevel field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *DatabaseGetcompatibility) GetCompatibilityLevelOk() (ret DatabaseGetcompatibilityGetCompatibilityLevelRetType, ok bool) {
- return getDatabaseGetcompatibilityGetCompatibilityLevelAttributeTypeOk(o.CompatibilityLevel)
-}
-
-// HasCompatibilityLevel returns a boolean if a field has been set.
-func (o *DatabaseGetcompatibility) HasCompatibilityLevel() bool {
- _, ok := o.GetCompatibilityLevelOk()
- return ok
-}
-
-// SetCompatibilityLevel gets a reference to the given int64 and assigns it to the CompatibilityLevel field.
-func (o *DatabaseGetcompatibility) SetCompatibilityLevel(v DatabaseGetcompatibilityGetCompatibilityLevelRetType) {
- setDatabaseGetcompatibilityGetCompatibilityLevelAttributeType(&o.CompatibilityLevel, v)
-}
-
-// GetDescription returns the Description field value if set, zero value otherwise.
-func (o *DatabaseGetcompatibility) GetDescription() (res DatabaseGetcompatibilityGetDescriptionRetType) {
- res, _ = o.GetDescriptionOk()
- return
-}
-
-// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *DatabaseGetcompatibility) GetDescriptionOk() (ret DatabaseGetcompatibilityGetDescriptionRetType, ok bool) {
- return getDatabaseGetcompatibilityGetDescriptionAttributeTypeOk(o.Description)
-}
-
-// HasDescription returns a boolean if a field has been set.
-func (o *DatabaseGetcompatibility) HasDescription() bool {
- _, ok := o.GetDescriptionOk()
- return ok
-}
-
-// SetDescription gets a reference to the given string and assigns it to the Description field.
-func (o *DatabaseGetcompatibility) SetDescription(v DatabaseGetcompatibilityGetDescriptionRetType) {
- setDatabaseGetcompatibilityGetDescriptionAttributeType(&o.Description, v)
-}
-
-func (o DatabaseGetcompatibility) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getDatabaseGetcompatibilityGetCompatibilityLevelAttributeTypeOk(o.CompatibilityLevel); ok {
- toSerialize["CompatibilityLevel"] = val
- }
- if val, ok := getDatabaseGetcompatibilityGetDescriptionAttributeTypeOk(o.Description); ok {
- toSerialize["Description"] = val
- }
- return toSerialize, nil
-}
-
-type NullableDatabaseGetcompatibility struct {
- value *DatabaseGetcompatibility
- isSet bool
-}
-
-func (v NullableDatabaseGetcompatibility) Get() *DatabaseGetcompatibility {
- return v.value
-}
-
-func (v *NullableDatabaseGetcompatibility) Set(val *DatabaseGetcompatibility) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableDatabaseGetcompatibility) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableDatabaseGetcompatibility) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableDatabaseGetcompatibility(val *DatabaseGetcompatibility) *NullableDatabaseGetcompatibility {
- return &NullableDatabaseGetcompatibility{value: val, isSet: true}
-}
-
-func (v NullableDatabaseGetcompatibility) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableDatabaseGetcompatibility) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_database_getcompatibility_test.go b/pkg/sqlserverflexalpha/model_database_getcompatibility_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_database_getcompatibility_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_database_roles.go b/pkg/sqlserverflexalpha/model_database_roles.go
deleted file mode 100644
index 8d0a1b7f..00000000
--- a/pkg/sqlserverflexalpha/model_database_roles.go
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the DatabaseRoles type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &DatabaseRoles{}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type DatabaseRolesGetNameAttributeType = *string
-
-func getDatabaseRolesGetNameAttributeTypeOk(arg DatabaseRolesGetNameAttributeType) (ret DatabaseRolesGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setDatabaseRolesGetNameAttributeType(arg *DatabaseRolesGetNameAttributeType, val DatabaseRolesGetNameRetType) {
- *arg = &val
-}
-
-type DatabaseRolesGetNameArgType = string
-type DatabaseRolesGetNameRetType = string
-
-/*
- types and functions for roles
-*/
-
-// isArray
-type DatabaseRolesGetRolesAttributeType = *[]string
-type DatabaseRolesGetRolesArgType = []string
-type DatabaseRolesGetRolesRetType = []string
-
-func getDatabaseRolesGetRolesAttributeTypeOk(arg DatabaseRolesGetRolesAttributeType) (ret DatabaseRolesGetRolesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setDatabaseRolesGetRolesAttributeType(arg *DatabaseRolesGetRolesAttributeType, val DatabaseRolesGetRolesRetType) {
- *arg = &val
-}
-
-// DatabaseRoles The name and the roles for a database for a user.
-type DatabaseRoles struct {
- // The name of the database.
- // REQUIRED
- Name DatabaseRolesGetNameAttributeType `json:"name" required:"true"`
- // The name and the roles for a database
- // REQUIRED
- Roles DatabaseRolesGetRolesAttributeType `json:"roles" required:"true"`
-}
-
-type _DatabaseRoles DatabaseRoles
-
-// NewDatabaseRoles instantiates a new DatabaseRoles object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewDatabaseRoles(name DatabaseRolesGetNameArgType, roles DatabaseRolesGetRolesArgType) *DatabaseRoles {
- this := DatabaseRoles{}
- setDatabaseRolesGetNameAttributeType(&this.Name, name)
- setDatabaseRolesGetRolesAttributeType(&this.Roles, roles)
- return &this
-}
-
-// NewDatabaseRolesWithDefaults instantiates a new DatabaseRoles object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewDatabaseRolesWithDefaults() *DatabaseRoles {
- this := DatabaseRoles{}
- return &this
-}
-
-// GetName returns the Name field value
-func (o *DatabaseRoles) GetName() (ret DatabaseRolesGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *DatabaseRoles) GetNameOk() (ret DatabaseRolesGetNameRetType, ok bool) {
- return getDatabaseRolesGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *DatabaseRoles) SetName(v DatabaseRolesGetNameRetType) {
- setDatabaseRolesGetNameAttributeType(&o.Name, v)
-}
-
-// GetRoles returns the Roles field value
-func (o *DatabaseRoles) GetRoles() (ret DatabaseRolesGetRolesRetType) {
- ret, _ = o.GetRolesOk()
- return ret
-}
-
-// GetRolesOk returns a tuple with the Roles field value
-// and a boolean to check if the value has been set.
-func (o *DatabaseRoles) GetRolesOk() (ret DatabaseRolesGetRolesRetType, ok bool) {
- return getDatabaseRolesGetRolesAttributeTypeOk(o.Roles)
-}
-
-// SetRoles sets field value
-func (o *DatabaseRoles) SetRoles(v DatabaseRolesGetRolesRetType) {
- setDatabaseRolesGetRolesAttributeType(&o.Roles, v)
-}
-
-func (o DatabaseRoles) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getDatabaseRolesGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getDatabaseRolesGetRolesAttributeTypeOk(o.Roles); ok {
- toSerialize["Roles"] = val
- }
- return toSerialize, nil
-}
-
-type NullableDatabaseRoles struct {
- value *DatabaseRoles
- isSet bool
-}
-
-func (v NullableDatabaseRoles) Get() *DatabaseRoles {
- return v.value
-}
-
-func (v *NullableDatabaseRoles) Set(val *DatabaseRoles) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableDatabaseRoles) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableDatabaseRoles) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableDatabaseRoles(val *DatabaseRoles) *NullableDatabaseRoles {
- return &NullableDatabaseRoles{value: val, isSet: true}
-}
-
-func (v NullableDatabaseRoles) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableDatabaseRoles) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_database_roles_test.go b/pkg/sqlserverflexalpha/model_database_roles_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_database_roles_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_database_sort.go b/pkg/sqlserverflexalpha/model_database_sort.go
deleted file mode 100644
index f4e45087..00000000
--- a/pkg/sqlserverflexalpha/model_database_sort.go
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// DatabaseSort the model 'DatabaseSort'
-type DatabaseSort string
-
-// List of database.sort
-const (
- DATABASESORT_CREATED_AT_DESC DatabaseSort = "created_at.desc"
- DATABASESORT_CREATED_AT_ASC DatabaseSort = "created_at.asc"
- DATABASESORT_DATABASE_ID_DESC DatabaseSort = "database_id.desc"
- DATABASESORT_DATABASE_ID_ASC DatabaseSort = "database_id.asc"
- DATABASESORT_DATABASE_NAME_DESC DatabaseSort = "database_name.desc"
- DATABASESORT_DATABASE_NAME_ASC DatabaseSort = "database_name.asc"
- DATABASESORT_DATABASE_OWNER_DESC DatabaseSort = "database_owner.desc"
- DATABASESORT_DATABASE_OWNER_ASC DatabaseSort = "database_owner.asc"
- DATABASESORT_INDEX_ASC DatabaseSort = "index.asc"
- DATABASESORT_INDEX_DESC DatabaseSort = "index.desc"
-)
-
-// All allowed values of DatabaseSort enum
-var AllowedDatabaseSortEnumValues = []DatabaseSort{
- "created_at.desc",
- "created_at.asc",
- "database_id.desc",
- "database_id.asc",
- "database_name.desc",
- "database_name.asc",
- "database_owner.desc",
- "database_owner.asc",
- "index.asc",
- "index.desc",
-}
-
-func (v *DatabaseSort) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := DatabaseSort(value)
- for _, existing := range AllowedDatabaseSortEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid DatabaseSort", value)
-}
-
-// NewDatabaseSortFromValue returns a pointer to a valid DatabaseSort
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewDatabaseSortFromValue(v string) (*DatabaseSort, error) {
- ev := DatabaseSort(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for DatabaseSort: valid values are %v", v, AllowedDatabaseSortEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v DatabaseSort) IsValid() bool {
- for _, existing := range AllowedDatabaseSortEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to database.sort value
-func (v DatabaseSort) Ptr() *DatabaseSort {
- return &v
-}
-
-type NullableDatabaseSort struct {
- value *DatabaseSort
- isSet bool
-}
-
-func (v NullableDatabaseSort) Get() *DatabaseSort {
- return v.value
-}
-
-func (v *NullableDatabaseSort) Set(val *DatabaseSort) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableDatabaseSort) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableDatabaseSort) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableDatabaseSort(val *DatabaseSort) *NullableDatabaseSort {
- return &NullableDatabaseSort{value: val, isSet: true}
-}
-
-func (v NullableDatabaseSort) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableDatabaseSort) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_database_sort_test.go b/pkg/sqlserverflexalpha/model_database_sort_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_database_sort_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_error.go b/pkg/sqlserverflexalpha/model_error.go
deleted file mode 100644
index 31d53693..00000000
--- a/pkg/sqlserverflexalpha/model_error.go
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the Error type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &Error{}
-
-/*
- types and functions for code
-*/
-
-// isInteger
-type ErrorGetCodeAttributeType = *int64
-type ErrorGetCodeArgType = int64
-type ErrorGetCodeRetType = int64
-
-func getErrorGetCodeAttributeTypeOk(arg ErrorGetCodeAttributeType) (ret ErrorGetCodeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setErrorGetCodeAttributeType(arg *ErrorGetCodeAttributeType, val ErrorGetCodeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for message
-*/
-
-// isNotNullableString
-type ErrorGetMessageAttributeType = *string
-
-func getErrorGetMessageAttributeTypeOk(arg ErrorGetMessageAttributeType) (ret ErrorGetMessageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setErrorGetMessageAttributeType(arg *ErrorGetMessageAttributeType, val ErrorGetMessageRetType) {
- *arg = &val
-}
-
-type ErrorGetMessageArgType = string
-type ErrorGetMessageRetType = string
-
-/*
- types and functions for traceId
-*/
-
-// isNotNullableString
-type ErrorGetTraceIdAttributeType = *string
-
-func getErrorGetTraceIdAttributeTypeOk(arg ErrorGetTraceIdAttributeType) (ret ErrorGetTraceIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setErrorGetTraceIdAttributeType(arg *ErrorGetTraceIdAttributeType, val ErrorGetTraceIdRetType) {
- *arg = &val
-}
-
-type ErrorGetTraceIdArgType = string
-type ErrorGetTraceIdRetType = string
-
-/*
- types and functions for type
-*/
-
-// isNotNullableString
-type ErrorGetTypeAttributeType = *string
-
-func getErrorGetTypeAttributeTypeOk(arg ErrorGetTypeAttributeType) (ret ErrorGetTypeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setErrorGetTypeAttributeType(arg *ErrorGetTypeAttributeType, val ErrorGetTypeRetType) {
- *arg = &val
-}
-
-type ErrorGetTypeArgType = string
-type ErrorGetTypeRetType = string
-
-// Error struct for Error
-type Error struct {
- // The http error code of the error.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- Code ErrorGetCodeAttributeType `json:"code" required:"true" validate:"required,errorCode"`
- // More detailed information about the error.
- // REQUIRED
- Message ErrorGetMessageAttributeType `json:"message" required:"true" validate:"required,errorMsg"`
- // The trace id of the request.
- // REQUIRED
- TraceId ErrorGetTraceIdAttributeType `json:"traceId" required:"true" validate:"required,traceID"`
- // Describes in which state the api was when the error happened.
- // REQUIRED
- Type ErrorGetTypeAttributeType `json:"type" required:"true" validate:"required,errorType"`
-}
-
-type _Error Error
-
-// NewError instantiates a new Error object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewError(code ErrorGetCodeArgType, message ErrorGetMessageArgType, traceId ErrorGetTraceIdArgType, types ErrorGetTypeArgType) *Error {
- this := Error{}
- setErrorGetCodeAttributeType(&this.Code, code)
- setErrorGetMessageAttributeType(&this.Message, message)
- setErrorGetTraceIdAttributeType(&this.TraceId, traceId)
- setErrorGetTypeAttributeType(&this.Type, types)
- return &this
-}
-
-// NewErrorWithDefaults instantiates a new Error object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewErrorWithDefaults() *Error {
- this := Error{}
- return &this
-}
-
-// GetCode returns the Code field value
-func (o *Error) GetCode() (ret ErrorGetCodeRetType) {
- ret, _ = o.GetCodeOk()
- return ret
-}
-
-// GetCodeOk returns a tuple with the Code field value
-// and a boolean to check if the value has been set.
-func (o *Error) GetCodeOk() (ret ErrorGetCodeRetType, ok bool) {
- return getErrorGetCodeAttributeTypeOk(o.Code)
-}
-
-// SetCode sets field value
-func (o *Error) SetCode(v ErrorGetCodeRetType) {
- setErrorGetCodeAttributeType(&o.Code, v)
-}
-
-// GetMessage returns the Message field value
-func (o *Error) GetMessage() (ret ErrorGetMessageRetType) {
- ret, _ = o.GetMessageOk()
- return ret
-}
-
-// GetMessageOk returns a tuple with the Message field value
-// and a boolean to check if the value has been set.
-func (o *Error) GetMessageOk() (ret ErrorGetMessageRetType, ok bool) {
- return getErrorGetMessageAttributeTypeOk(o.Message)
-}
-
-// SetMessage sets field value
-func (o *Error) SetMessage(v ErrorGetMessageRetType) {
- setErrorGetMessageAttributeType(&o.Message, v)
-}
-
-// GetTraceId returns the TraceId field value
-func (o *Error) GetTraceId() (ret ErrorGetTraceIdRetType) {
- ret, _ = o.GetTraceIdOk()
- return ret
-}
-
-// GetTraceIdOk returns a tuple with the TraceId field value
-// and a boolean to check if the value has been set.
-func (o *Error) GetTraceIdOk() (ret ErrorGetTraceIdRetType, ok bool) {
- return getErrorGetTraceIdAttributeTypeOk(o.TraceId)
-}
-
-// SetTraceId sets field value
-func (o *Error) SetTraceId(v ErrorGetTraceIdRetType) {
- setErrorGetTraceIdAttributeType(&o.TraceId, v)
-}
-
-// GetType returns the Type field value
-func (o *Error) GetType() (ret ErrorGetTypeRetType) {
- ret, _ = o.GetTypeOk()
- return ret
-}
-
-// GetTypeOk returns a tuple with the Type field value
-// and a boolean to check if the value has been set.
-func (o *Error) GetTypeOk() (ret ErrorGetTypeRetType, ok bool) {
- return getErrorGetTypeAttributeTypeOk(o.Type)
-}
-
-// SetType sets field value
-func (o *Error) SetType(v ErrorGetTypeRetType) {
- setErrorGetTypeAttributeType(&o.Type, v)
-}
-
-func (o Error) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getErrorGetCodeAttributeTypeOk(o.Code); ok {
- toSerialize["Code"] = val
- }
- if val, ok := getErrorGetMessageAttributeTypeOk(o.Message); ok {
- toSerialize["Message"] = val
- }
- if val, ok := getErrorGetTraceIdAttributeTypeOk(o.TraceId); ok {
- toSerialize["TraceId"] = val
- }
- if val, ok := getErrorGetTypeAttributeTypeOk(o.Type); ok {
- toSerialize["Type"] = val
- }
- return toSerialize, nil
-}
-
-type NullableError struct {
- value *Error
- isSet bool
-}
-
-func (v NullableError) Get() *Error {
- return v.value
-}
-
-func (v *NullableError) Set(val *Error) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableError) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableError) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableError(val *Error) *NullableError {
- return &NullableError{value: val, isSet: true}
-}
-
-func (v NullableError) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableError) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_error_test.go b/pkg/sqlserverflexalpha/model_error_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_error_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_flavor_sort.go b/pkg/sqlserverflexalpha/model_flavor_sort.go
deleted file mode 100644
index 65e628ec..00000000
--- a/pkg/sqlserverflexalpha/model_flavor_sort.go
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// FlavorSort the model 'FlavorSort'
-type FlavorSort string
-
-// List of flavor.sort
-const (
- FLAVORSORT_INDEX_DESC FlavorSort = "index.desc"
- FLAVORSORT_INDEX_ASC FlavorSort = "index.asc"
- FLAVORSORT_CPU_DESC FlavorSort = "cpu.desc"
- FLAVORSORT_CPU_ASC FlavorSort = "cpu.asc"
- FLAVORSORT_FLAVOR_DESCRIPTION_ASC FlavorSort = "flavor_description.asc"
- FLAVORSORT_FLAVOR_DESCRIPTION_DESC FlavorSort = "flavor_description.desc"
- FLAVORSORT_ID_DESC FlavorSort = "id.desc"
- FLAVORSORT_ID_ASC FlavorSort = "id.asc"
- FLAVORSORT_SIZE_MAX_DESC FlavorSort = "size_max.desc"
- FLAVORSORT_SIZE_MAX_ASC FlavorSort = "size_max.asc"
- FLAVORSORT_RAM_DESC FlavorSort = "ram.desc"
- FLAVORSORT_RAM_ASC FlavorSort = "ram.asc"
- FLAVORSORT_SIZE_MIN_DESC FlavorSort = "size_min.desc"
- FLAVORSORT_SIZE_MIN_ASC FlavorSort = "size_min.asc"
- FLAVORSORT_STORAGE_CLASS_ASC FlavorSort = "storage_class.asc"
- FLAVORSORT_STORAGE_CLASS_DESC FlavorSort = "storage_class.desc"
- FLAVORSORT_NODE_TYPE_ASC FlavorSort = "node_type.asc"
- FLAVORSORT_NODE_TYPE_DESC FlavorSort = "node_type.desc"
-)
-
-// All allowed values of FlavorSort enum
-var AllowedFlavorSortEnumValues = []FlavorSort{
- "index.desc",
- "index.asc",
- "cpu.desc",
- "cpu.asc",
- "flavor_description.asc",
- "flavor_description.desc",
- "id.desc",
- "id.asc",
- "size_max.desc",
- "size_max.asc",
- "ram.desc",
- "ram.asc",
- "size_min.desc",
- "size_min.asc",
- "storage_class.asc",
- "storage_class.desc",
- "node_type.asc",
- "node_type.desc",
-}
-
-func (v *FlavorSort) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := FlavorSort(value)
- for _, existing := range AllowedFlavorSortEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid FlavorSort", value)
-}
-
-// NewFlavorSortFromValue returns a pointer to a valid FlavorSort
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewFlavorSortFromValue(v string) (*FlavorSort, error) {
- ev := FlavorSort(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for FlavorSort: valid values are %v", v, AllowedFlavorSortEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v FlavorSort) IsValid() bool {
- for _, existing := range AllowedFlavorSortEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to flavor.sort value
-func (v FlavorSort) Ptr() *FlavorSort {
- return &v
-}
-
-type NullableFlavorSort struct {
- value *FlavorSort
- isSet bool
-}
-
-func (v NullableFlavorSort) Get() *FlavorSort {
- return v.value
-}
-
-func (v *NullableFlavorSort) Set(val *FlavorSort) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableFlavorSort) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableFlavorSort) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableFlavorSort(val *FlavorSort) *NullableFlavorSort {
- return &NullableFlavorSort{value: val, isSet: true}
-}
-
-func (v NullableFlavorSort) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableFlavorSort) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_flavor_sort_test.go b/pkg/sqlserverflexalpha/model_flavor_sort_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_flavor_sort_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_flavor_storage_classes_storage_class.go b/pkg/sqlserverflexalpha/model_flavor_storage_classes_storage_class.go
deleted file mode 100644
index aaf1f07e..00000000
--- a/pkg/sqlserverflexalpha/model_flavor_storage_classes_storage_class.go
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the FlavorStorageClassesStorageClass type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &FlavorStorageClassesStorageClass{}
-
-/*
- types and functions for class
-*/
-
-// isNotNullableString
-type FlavorStorageClassesStorageClassGetClassAttributeType = *string
-
-func getFlavorStorageClassesStorageClassGetClassAttributeTypeOk(arg FlavorStorageClassesStorageClassGetClassAttributeType) (ret FlavorStorageClassesStorageClassGetClassRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setFlavorStorageClassesStorageClassGetClassAttributeType(arg *FlavorStorageClassesStorageClassGetClassAttributeType, val FlavorStorageClassesStorageClassGetClassRetType) {
- *arg = &val
-}
-
-type FlavorStorageClassesStorageClassGetClassArgType = string
-type FlavorStorageClassesStorageClassGetClassRetType = string
-
-/*
- types and functions for maxIoPerSec
-*/
-
-// isInteger
-type FlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType = *int64
-type FlavorStorageClassesStorageClassGetMaxIoPerSecArgType = int64
-type FlavorStorageClassesStorageClassGetMaxIoPerSecRetType = int64
-
-func getFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeTypeOk(arg FlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType) (ret FlavorStorageClassesStorageClassGetMaxIoPerSecRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType(arg *FlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType, val FlavorStorageClassesStorageClassGetMaxIoPerSecRetType) {
- *arg = &val
-}
-
-/*
- types and functions for maxThroughInMb
-*/
-
-// isInteger
-type FlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType = *int64
-type FlavorStorageClassesStorageClassGetMaxThroughInMbArgType = int64
-type FlavorStorageClassesStorageClassGetMaxThroughInMbRetType = int64
-
-func getFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeTypeOk(arg FlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType) (ret FlavorStorageClassesStorageClassGetMaxThroughInMbRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType(arg *FlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType, val FlavorStorageClassesStorageClassGetMaxThroughInMbRetType) {
- *arg = &val
-}
-
-// FlavorStorageClassesStorageClass a storageClass defines how efficient the storage can work
-type FlavorStorageClassesStorageClass struct {
- // REQUIRED
- Class FlavorStorageClassesStorageClassGetClassAttributeType `json:"class" required:"true"`
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- MaxIoPerSec FlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType `json:"maxIoPerSec" required:"true"`
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- MaxThroughInMb FlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType `json:"maxThroughInMb" required:"true"`
-}
-
-type _FlavorStorageClassesStorageClass FlavorStorageClassesStorageClass
-
-// NewFlavorStorageClassesStorageClass instantiates a new FlavorStorageClassesStorageClass object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewFlavorStorageClassesStorageClass(class FlavorStorageClassesStorageClassGetClassArgType, maxIoPerSec FlavorStorageClassesStorageClassGetMaxIoPerSecArgType, maxThroughInMb FlavorStorageClassesStorageClassGetMaxThroughInMbArgType) *FlavorStorageClassesStorageClass {
- this := FlavorStorageClassesStorageClass{}
- setFlavorStorageClassesStorageClassGetClassAttributeType(&this.Class, class)
- setFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType(&this.MaxIoPerSec, maxIoPerSec)
- setFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType(&this.MaxThroughInMb, maxThroughInMb)
- return &this
-}
-
-// NewFlavorStorageClassesStorageClassWithDefaults instantiates a new FlavorStorageClassesStorageClass object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewFlavorStorageClassesStorageClassWithDefaults() *FlavorStorageClassesStorageClass {
- this := FlavorStorageClassesStorageClass{}
- return &this
-}
-
-// GetClass returns the Class field value
-func (o *FlavorStorageClassesStorageClass) GetClass() (ret FlavorStorageClassesStorageClassGetClassRetType) {
- ret, _ = o.GetClassOk()
- return ret
-}
-
-// GetClassOk returns a tuple with the Class field value
-// and a boolean to check if the value has been set.
-func (o *FlavorStorageClassesStorageClass) GetClassOk() (ret FlavorStorageClassesStorageClassGetClassRetType, ok bool) {
- return getFlavorStorageClassesStorageClassGetClassAttributeTypeOk(o.Class)
-}
-
-// SetClass sets field value
-func (o *FlavorStorageClassesStorageClass) SetClass(v FlavorStorageClassesStorageClassGetClassRetType) {
- setFlavorStorageClassesStorageClassGetClassAttributeType(&o.Class, v)
-}
-
-// GetMaxIoPerSec returns the MaxIoPerSec field value
-func (o *FlavorStorageClassesStorageClass) GetMaxIoPerSec() (ret FlavorStorageClassesStorageClassGetMaxIoPerSecRetType) {
- ret, _ = o.GetMaxIoPerSecOk()
- return ret
-}
-
-// GetMaxIoPerSecOk returns a tuple with the MaxIoPerSec field value
-// and a boolean to check if the value has been set.
-func (o *FlavorStorageClassesStorageClass) GetMaxIoPerSecOk() (ret FlavorStorageClassesStorageClassGetMaxIoPerSecRetType, ok bool) {
- return getFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeTypeOk(o.MaxIoPerSec)
-}
-
-// SetMaxIoPerSec sets field value
-func (o *FlavorStorageClassesStorageClass) SetMaxIoPerSec(v FlavorStorageClassesStorageClassGetMaxIoPerSecRetType) {
- setFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeType(&o.MaxIoPerSec, v)
-}
-
-// GetMaxThroughInMb returns the MaxThroughInMb field value
-func (o *FlavorStorageClassesStorageClass) GetMaxThroughInMb() (ret FlavorStorageClassesStorageClassGetMaxThroughInMbRetType) {
- ret, _ = o.GetMaxThroughInMbOk()
- return ret
-}
-
-// GetMaxThroughInMbOk returns a tuple with the MaxThroughInMb field value
-// and a boolean to check if the value has been set.
-func (o *FlavorStorageClassesStorageClass) GetMaxThroughInMbOk() (ret FlavorStorageClassesStorageClassGetMaxThroughInMbRetType, ok bool) {
- return getFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeTypeOk(o.MaxThroughInMb)
-}
-
-// SetMaxThroughInMb sets field value
-func (o *FlavorStorageClassesStorageClass) SetMaxThroughInMb(v FlavorStorageClassesStorageClassGetMaxThroughInMbRetType) {
- setFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeType(&o.MaxThroughInMb, v)
-}
-
-func (o FlavorStorageClassesStorageClass) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getFlavorStorageClassesStorageClassGetClassAttributeTypeOk(o.Class); ok {
- toSerialize["Class"] = val
- }
- if val, ok := getFlavorStorageClassesStorageClassGetMaxIoPerSecAttributeTypeOk(o.MaxIoPerSec); ok {
- toSerialize["MaxIoPerSec"] = val
- }
- if val, ok := getFlavorStorageClassesStorageClassGetMaxThroughInMbAttributeTypeOk(o.MaxThroughInMb); ok {
- toSerialize["MaxThroughInMb"] = val
- }
- return toSerialize, nil
-}
-
-type NullableFlavorStorageClassesStorageClass struct {
- value *FlavorStorageClassesStorageClass
- isSet bool
-}
-
-func (v NullableFlavorStorageClassesStorageClass) Get() *FlavorStorageClassesStorageClass {
- return v.value
-}
-
-func (v *NullableFlavorStorageClassesStorageClass) Set(val *FlavorStorageClassesStorageClass) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableFlavorStorageClassesStorageClass) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableFlavorStorageClassesStorageClass) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableFlavorStorageClassesStorageClass(val *FlavorStorageClassesStorageClass) *NullableFlavorStorageClassesStorageClass {
- return &NullableFlavorStorageClassesStorageClass{value: val, isSet: true}
-}
-
-func (v NullableFlavorStorageClassesStorageClass) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableFlavorStorageClassesStorageClass) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_flavor_storage_classes_storage_class_test.go b/pkg/sqlserverflexalpha/model_flavor_storage_classes_storage_class_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_flavor_storage_classes_storage_class_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_flavor_storage_range.go b/pkg/sqlserverflexalpha/model_flavor_storage_range.go
deleted file mode 100644
index 1abfc523..00000000
--- a/pkg/sqlserverflexalpha/model_flavor_storage_range.go
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the FlavorStorageRange type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &FlavorStorageRange{}
-
-/*
- types and functions for max
-*/
-
-// isInteger
-type FlavorStorageRangeGetMaxAttributeType = *int64
-type FlavorStorageRangeGetMaxArgType = int64
-type FlavorStorageRangeGetMaxRetType = int64
-
-func getFlavorStorageRangeGetMaxAttributeTypeOk(arg FlavorStorageRangeGetMaxAttributeType) (ret FlavorStorageRangeGetMaxRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setFlavorStorageRangeGetMaxAttributeType(arg *FlavorStorageRangeGetMaxAttributeType, val FlavorStorageRangeGetMaxRetType) {
- *arg = &val
-}
-
-/*
- types and functions for min
-*/
-
-// isInteger
-type FlavorStorageRangeGetMinAttributeType = *int64
-type FlavorStorageRangeGetMinArgType = int64
-type FlavorStorageRangeGetMinRetType = int64
-
-func getFlavorStorageRangeGetMinAttributeTypeOk(arg FlavorStorageRangeGetMinAttributeType) (ret FlavorStorageRangeGetMinRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setFlavorStorageRangeGetMinAttributeType(arg *FlavorStorageRangeGetMinAttributeType, val FlavorStorageRangeGetMinRetType) {
- *arg = &val
-}
-
-// FlavorStorageRange range of maximum and minimum storage which can be ordered for the flavor in Gigabyte.
-type FlavorStorageRange struct {
- // maximum storage which can be ordered for the flavor in Gigabyte.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- Max FlavorStorageRangeGetMaxAttributeType `json:"max" required:"true"`
- // minimum storage which is required to order in Gigabyte.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- Min FlavorStorageRangeGetMinAttributeType `json:"min" required:"true"`
-}
-
-type _FlavorStorageRange FlavorStorageRange
-
-// NewFlavorStorageRange instantiates a new FlavorStorageRange object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewFlavorStorageRange(max FlavorStorageRangeGetMaxArgType, min FlavorStorageRangeGetMinArgType) *FlavorStorageRange {
- this := FlavorStorageRange{}
- setFlavorStorageRangeGetMaxAttributeType(&this.Max, max)
- setFlavorStorageRangeGetMinAttributeType(&this.Min, min)
- return &this
-}
-
-// NewFlavorStorageRangeWithDefaults instantiates a new FlavorStorageRange object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewFlavorStorageRangeWithDefaults() *FlavorStorageRange {
- this := FlavorStorageRange{}
- return &this
-}
-
-// GetMax returns the Max field value
-func (o *FlavorStorageRange) GetMax() (ret FlavorStorageRangeGetMaxRetType) {
- ret, _ = o.GetMaxOk()
- return ret
-}
-
-// GetMaxOk returns a tuple with the Max field value
-// and a boolean to check if the value has been set.
-func (o *FlavorStorageRange) GetMaxOk() (ret FlavorStorageRangeGetMaxRetType, ok bool) {
- return getFlavorStorageRangeGetMaxAttributeTypeOk(o.Max)
-}
-
-// SetMax sets field value
-func (o *FlavorStorageRange) SetMax(v FlavorStorageRangeGetMaxRetType) {
- setFlavorStorageRangeGetMaxAttributeType(&o.Max, v)
-}
-
-// GetMin returns the Min field value
-func (o *FlavorStorageRange) GetMin() (ret FlavorStorageRangeGetMinRetType) {
- ret, _ = o.GetMinOk()
- return ret
-}
-
-// GetMinOk returns a tuple with the Min field value
-// and a boolean to check if the value has been set.
-func (o *FlavorStorageRange) GetMinOk() (ret FlavorStorageRangeGetMinRetType, ok bool) {
- return getFlavorStorageRangeGetMinAttributeTypeOk(o.Min)
-}
-
-// SetMin sets field value
-func (o *FlavorStorageRange) SetMin(v FlavorStorageRangeGetMinRetType) {
- setFlavorStorageRangeGetMinAttributeType(&o.Min, v)
-}
-
-func (o FlavorStorageRange) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getFlavorStorageRangeGetMaxAttributeTypeOk(o.Max); ok {
- toSerialize["Max"] = val
- }
- if val, ok := getFlavorStorageRangeGetMinAttributeTypeOk(o.Min); ok {
- toSerialize["Min"] = val
- }
- return toSerialize, nil
-}
-
-type NullableFlavorStorageRange struct {
- value *FlavorStorageRange
- isSet bool
-}
-
-func (v NullableFlavorStorageRange) Get() *FlavorStorageRange {
- return v.value
-}
-
-func (v *NullableFlavorStorageRange) Set(val *FlavorStorageRange) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableFlavorStorageRange) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableFlavorStorageRange) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableFlavorStorageRange(val *FlavorStorageRange) *NullableFlavorStorageRange {
- return &NullableFlavorStorageRange{value: val, isSet: true}
-}
-
-func (v NullableFlavorStorageRange) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableFlavorStorageRange) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_flavor_storage_range_test.go b/pkg/sqlserverflexalpha/model_flavor_storage_range_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_flavor_storage_range_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_get_backup_response.go b/pkg/sqlserverflexalpha/model_get_backup_response.go
deleted file mode 100644
index 7875d04e..00000000
--- a/pkg/sqlserverflexalpha/model_get_backup_response.go
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetBackupResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetBackupResponse{}
-
-/*
- types and functions for completionTime
-*/
-
-//// isAny
-//type GetBackupResponseGetCompletionTimeAttributeType = any
-//type GetBackupResponseGetCompletionTimeArgType = any
-//type GetBackupResponseGetCompletionTimeRetType = any
-//
-//func getGetBackupResponseGetCompletionTimeAttributeTypeOk(arg GetBackupResponseGetCompletionTimeAttributeType) (ret GetBackupResponseGetCompletionTimeRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setGetBackupResponseGetCompletionTimeAttributeType(arg *GetBackupResponseGetCompletionTimeAttributeType, val GetBackupResponseGetCompletionTimeRetType) {
-// *arg = &val
-//}
-
-// isModel
-type GetBackupResponseGetCompletionTimeAttributeType = *string
-type GetBackupResponseGetCompletionTimeArgType = string
-type GetBackupResponseGetCompletionTimeRetType = string
-
-func getGetBackupResponseGetCompletionTimeAttributeTypeOk(arg GetBackupResponseGetCompletionTimeAttributeType) (ret GetBackupResponseGetCompletionTimeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetCompletionTimeAttributeType(arg *GetBackupResponseGetCompletionTimeAttributeType, val GetBackupResponseGetCompletionTimeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for id
-*/
-
-//// isAny
-//type GetBackupResponseGetIdAttributeType = any
-//type GetBackupResponseGetIdArgType = any
-//type GetBackupResponseGetIdRetType = any
-//
-//func getGetBackupResponseGetIdAttributeTypeOk(arg GetBackupResponseGetIdAttributeType) (ret GetBackupResponseGetIdRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setGetBackupResponseGetIdAttributeType(arg *GetBackupResponseGetIdAttributeType, val GetBackupResponseGetIdRetType) {
-// *arg = &val
-//}
-
-// isModel
-type GetBackupResponseGetIdAttributeType = *int64
-type GetBackupResponseGetIdArgType = int64
-type GetBackupResponseGetIdRetType = int64
-
-func getGetBackupResponseGetIdAttributeTypeOk(arg GetBackupResponseGetIdAttributeType) (ret GetBackupResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetIdAttributeType(arg *GetBackupResponseGetIdAttributeType, val GetBackupResponseGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-//// isAny
-//type GetBackupResponseGetNameAttributeType = any
-//type GetBackupResponseGetNameArgType = any
-//type GetBackupResponseGetNameRetType = any
-//
-//func getGetBackupResponseGetNameAttributeTypeOk(arg GetBackupResponseGetNameAttributeType) (ret GetBackupResponseGetNameRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setGetBackupResponseGetNameAttributeType(arg *GetBackupResponseGetNameAttributeType, val GetBackupResponseGetNameRetType) {
-// *arg = &val
-//}
-
-// isModel
-type GetBackupResponseGetNameAttributeType = *string
-type GetBackupResponseGetNameArgType = string
-type GetBackupResponseGetNameRetType = string
-
-func getGetBackupResponseGetNameAttributeTypeOk(arg GetBackupResponseGetNameAttributeType) (ret GetBackupResponseGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetNameAttributeType(arg *GetBackupResponseGetNameAttributeType, val GetBackupResponseGetNameRetType) {
- *arg = &val
-}
-
-/*
- types and functions for retainedUntil
-*/
-
-//// isAny
-//type GetBackupResponseGetRetainedUntilAttributeType = any
-//type GetBackupResponseGetRetainedUntilArgType = any
-//type GetBackupResponseGetRetainedUntilRetType = any
-//
-//func getGetBackupResponseGetRetainedUntilAttributeTypeOk(arg GetBackupResponseGetRetainedUntilAttributeType) (ret GetBackupResponseGetRetainedUntilRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setGetBackupResponseGetRetainedUntilAttributeType(arg *GetBackupResponseGetRetainedUntilAttributeType, val GetBackupResponseGetRetainedUntilRetType) {
-// *arg = &val
-//}
-
-// isModel
-type GetBackupResponseGetRetainedUntilAttributeType = *string
-type GetBackupResponseGetRetainedUntilArgType = string
-type GetBackupResponseGetRetainedUntilRetType = string
-
-func getGetBackupResponseGetRetainedUntilAttributeTypeOk(arg GetBackupResponseGetRetainedUntilAttributeType) (ret GetBackupResponseGetRetainedUntilRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetRetainedUntilAttributeType(arg *GetBackupResponseGetRetainedUntilAttributeType, val GetBackupResponseGetRetainedUntilRetType) {
- *arg = &val
-}
-
-/*
- types and functions for size
-*/
-
-//// isAny
-//type GetBackupResponseGetSizeAttributeType = any
-//type GetBackupResponseGetSizeArgType = any
-//type GetBackupResponseGetSizeRetType = any
-//
-//func getGetBackupResponseGetSizeAttributeTypeOk(arg GetBackupResponseGetSizeAttributeType) (ret GetBackupResponseGetSizeRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setGetBackupResponseGetSizeAttributeType(arg *GetBackupResponseGetSizeAttributeType, val GetBackupResponseGetSizeRetType) {
-// *arg = &val
-//}
-
-// isModel
-type GetBackupResponseGetSizeAttributeType = *int64
-type GetBackupResponseGetSizeArgType = int64
-type GetBackupResponseGetSizeRetType = int64
-
-func getGetBackupResponseGetSizeAttributeTypeOk(arg GetBackupResponseGetSizeAttributeType) (ret GetBackupResponseGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetSizeAttributeType(arg *GetBackupResponseGetSizeAttributeType, val GetBackupResponseGetSizeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for type
-*/
-
-//// isAny
-//type GetBackupResponseGetTypeAttributeType = any
-//type GetBackupResponseGetTypeArgType = any
-//type GetBackupResponseGetTypeRetType = any
-//
-//func getGetBackupResponseGetTypeAttributeTypeOk(arg GetBackupResponseGetTypeAttributeType) (ret GetBackupResponseGetTypeRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setGetBackupResponseGetTypeAttributeType(arg *GetBackupResponseGetTypeAttributeType, val GetBackupResponseGetTypeRetType) {
-// *arg = &val
-//}
-
-// isModel
-type GetBackupResponseGetTypeAttributeType = *string
-type GetBackupResponseGetTypeArgType = string
-type GetBackupResponseGetTypeRetType = string
-
-func getGetBackupResponseGetTypeAttributeTypeOk(arg GetBackupResponseGetTypeAttributeType) (ret GetBackupResponseGetTypeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetBackupResponseGetTypeAttributeType(arg *GetBackupResponseGetTypeAttributeType, val GetBackupResponseGetTypeRetType) {
- *arg = &val
-}
-
-// GetBackupResponse struct for GetBackupResponse
-type GetBackupResponse struct {
- // REQUIRED
- CompletionTime GetBackupResponseGetCompletionTimeAttributeType `json:"completionTime" required:"true"`
- // REQUIRED
- Id GetBackupResponseGetIdAttributeType `json:"id" required:"true"`
- // REQUIRED
- Name GetBackupResponseGetNameAttributeType `json:"name" required:"true"`
- // REQUIRED
- RetainedUntil GetBackupResponseGetRetainedUntilAttributeType `json:"retainedUntil" required:"true"`
- // REQUIRED
- Size GetBackupResponseGetSizeAttributeType `json:"size" required:"true"`
- // REQUIRED
- Type GetBackupResponseGetTypeAttributeType `json:"type" required:"true"`
-}
-
-type _GetBackupResponse GetBackupResponse
-
-// NewGetBackupResponse instantiates a new GetBackupResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetBackupResponse(completionTime GetBackupResponseGetCompletionTimeArgType, id GetBackupResponseGetIdArgType, name GetBackupResponseGetNameArgType, retainedUntil GetBackupResponseGetRetainedUntilArgType, size GetBackupResponseGetSizeArgType, types GetBackupResponseGetTypeArgType) *GetBackupResponse {
- this := GetBackupResponse{}
- setGetBackupResponseGetCompletionTimeAttributeType(&this.CompletionTime, completionTime)
- setGetBackupResponseGetIdAttributeType(&this.Id, id)
- setGetBackupResponseGetNameAttributeType(&this.Name, name)
- setGetBackupResponseGetRetainedUntilAttributeType(&this.RetainedUntil, retainedUntil)
- setGetBackupResponseGetSizeAttributeType(&this.Size, size)
- setGetBackupResponseGetTypeAttributeType(&this.Type, types)
- return &this
-}
-
-// NewGetBackupResponseWithDefaults instantiates a new GetBackupResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetBackupResponseWithDefaults() *GetBackupResponse {
- this := GetBackupResponse{}
- return &this
-}
-
-// GetCompletionTime returns the CompletionTime field value
-func (o *GetBackupResponse) GetCompletionTime() (ret GetBackupResponseGetCompletionTimeRetType) {
- ret, _ = o.GetCompletionTimeOk()
- return ret
-}
-
-// GetCompletionTimeOk returns a tuple with the CompletionTime field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetCompletionTimeOk() (ret GetBackupResponseGetCompletionTimeRetType, ok bool) {
- return getGetBackupResponseGetCompletionTimeAttributeTypeOk(o.CompletionTime)
-}
-
-// SetCompletionTime sets field value
-func (o *GetBackupResponse) SetCompletionTime(v GetBackupResponseGetCompletionTimeRetType) {
- setGetBackupResponseGetCompletionTimeAttributeType(&o.CompletionTime, v)
-}
-
-// GetId returns the Id field value
-func (o *GetBackupResponse) GetId() (ret GetBackupResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetIdOk() (ret GetBackupResponseGetIdRetType, ok bool) {
- return getGetBackupResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *GetBackupResponse) SetId(v GetBackupResponseGetIdRetType) {
- setGetBackupResponseGetIdAttributeType(&o.Id, v)
-}
-
-// GetName returns the Name field value
-func (o *GetBackupResponse) GetName() (ret GetBackupResponseGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetNameOk() (ret GetBackupResponseGetNameRetType, ok bool) {
- return getGetBackupResponseGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *GetBackupResponse) SetName(v GetBackupResponseGetNameRetType) {
- setGetBackupResponseGetNameAttributeType(&o.Name, v)
-}
-
-// GetRetainedUntil returns the RetainedUntil field value
-func (o *GetBackupResponse) GetRetainedUntil() (ret GetBackupResponseGetRetainedUntilRetType) {
- ret, _ = o.GetRetainedUntilOk()
- return ret
-}
-
-// GetRetainedUntilOk returns a tuple with the RetainedUntil field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetRetainedUntilOk() (ret GetBackupResponseGetRetainedUntilRetType, ok bool) {
- return getGetBackupResponseGetRetainedUntilAttributeTypeOk(o.RetainedUntil)
-}
-
-// SetRetainedUntil sets field value
-func (o *GetBackupResponse) SetRetainedUntil(v GetBackupResponseGetRetainedUntilRetType) {
- setGetBackupResponseGetRetainedUntilAttributeType(&o.RetainedUntil, v)
-}
-
-// GetSize returns the Size field value
-func (o *GetBackupResponse) GetSize() (ret GetBackupResponseGetSizeRetType) {
- ret, _ = o.GetSizeOk()
- return ret
-}
-
-// GetSizeOk returns a tuple with the Size field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetSizeOk() (ret GetBackupResponseGetSizeRetType, ok bool) {
- return getGetBackupResponseGetSizeAttributeTypeOk(o.Size)
-}
-
-// SetSize sets field value
-func (o *GetBackupResponse) SetSize(v GetBackupResponseGetSizeRetType) {
- setGetBackupResponseGetSizeAttributeType(&o.Size, v)
-}
-
-// GetType returns the Type field value
-func (o *GetBackupResponse) GetType() (ret GetBackupResponseGetTypeRetType) {
- ret, _ = o.GetTypeOk()
- return ret
-}
-
-// GetTypeOk returns a tuple with the Type field value
-// and a boolean to check if the value has been set.
-func (o *GetBackupResponse) GetTypeOk() (ret GetBackupResponseGetTypeRetType, ok bool) {
- return getGetBackupResponseGetTypeAttributeTypeOk(o.Type)
-}
-
-// SetType sets field value
-func (o *GetBackupResponse) SetType(v GetBackupResponseGetTypeRetType) {
- setGetBackupResponseGetTypeAttributeType(&o.Type, v)
-}
-
-func (o GetBackupResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetBackupResponseGetCompletionTimeAttributeTypeOk(o.CompletionTime); ok {
- toSerialize["CompletionTime"] = val
- }
- if val, ok := getGetBackupResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getGetBackupResponseGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getGetBackupResponseGetRetainedUntilAttributeTypeOk(o.RetainedUntil); ok {
- toSerialize["RetainedUntil"] = val
- }
- if val, ok := getGetBackupResponseGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- if val, ok := getGetBackupResponseGetTypeAttributeTypeOk(o.Type); ok {
- toSerialize["Type"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetBackupResponse struct {
- value *GetBackupResponse
- isSet bool
-}
-
-func (v NullableGetBackupResponse) Get() *GetBackupResponse {
- return v.value
-}
-
-func (v *NullableGetBackupResponse) Set(val *GetBackupResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetBackupResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetBackupResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetBackupResponse(val *GetBackupResponse) *NullableGetBackupResponse {
- return &NullableGetBackupResponse{value: val, isSet: true}
-}
-
-func (v NullableGetBackupResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetBackupResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_get_backup_response_test.go b/pkg/sqlserverflexalpha/model_get_backup_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_get_backup_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_get_collations_response.go b/pkg/sqlserverflexalpha/model_get_collations_response.go
deleted file mode 100644
index 9879d9c9..00000000
--- a/pkg/sqlserverflexalpha/model_get_collations_response.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetCollationsResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetCollationsResponse{}
-
-/*
- types and functions for collations
-*/
-
-// isArray
-type GetCollationsResponseGetCollationsAttributeType = *[]DatabaseGetcollation
-type GetCollationsResponseGetCollationsArgType = []DatabaseGetcollation
-type GetCollationsResponseGetCollationsRetType = []DatabaseGetcollation
-
-func getGetCollationsResponseGetCollationsAttributeTypeOk(arg GetCollationsResponseGetCollationsAttributeType) (ret GetCollationsResponseGetCollationsRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetCollationsResponseGetCollationsAttributeType(arg *GetCollationsResponseGetCollationsAttributeType, val GetCollationsResponseGetCollationsRetType) {
- *arg = &val
-}
-
-// GetCollationsResponse struct for GetCollationsResponse
-type GetCollationsResponse struct {
- // List of collations available for the instance.
- // REQUIRED
- Collations GetCollationsResponseGetCollationsAttributeType `json:"collations" required:"true"`
-}
-
-type _GetCollationsResponse GetCollationsResponse
-
-// NewGetCollationsResponse instantiates a new GetCollationsResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetCollationsResponse(collations GetCollationsResponseGetCollationsArgType) *GetCollationsResponse {
- this := GetCollationsResponse{}
- setGetCollationsResponseGetCollationsAttributeType(&this.Collations, collations)
- return &this
-}
-
-// NewGetCollationsResponseWithDefaults instantiates a new GetCollationsResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetCollationsResponseWithDefaults() *GetCollationsResponse {
- this := GetCollationsResponse{}
- return &this
-}
-
-// GetCollations returns the Collations field value
-func (o *GetCollationsResponse) GetCollations() (ret GetCollationsResponseGetCollationsRetType) {
- ret, _ = o.GetCollationsOk()
- return ret
-}
-
-// GetCollationsOk returns a tuple with the Collations field value
-// and a boolean to check if the value has been set.
-func (o *GetCollationsResponse) GetCollationsOk() (ret GetCollationsResponseGetCollationsRetType, ok bool) {
- return getGetCollationsResponseGetCollationsAttributeTypeOk(o.Collations)
-}
-
-// SetCollations sets field value
-func (o *GetCollationsResponse) SetCollations(v GetCollationsResponseGetCollationsRetType) {
- setGetCollationsResponseGetCollationsAttributeType(&o.Collations, v)
-}
-
-func (o GetCollationsResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetCollationsResponseGetCollationsAttributeTypeOk(o.Collations); ok {
- toSerialize["Collations"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetCollationsResponse struct {
- value *GetCollationsResponse
- isSet bool
-}
-
-func (v NullableGetCollationsResponse) Get() *GetCollationsResponse {
- return v.value
-}
-
-func (v *NullableGetCollationsResponse) Set(val *GetCollationsResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetCollationsResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetCollationsResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetCollationsResponse(val *GetCollationsResponse) *NullableGetCollationsResponse {
- return &NullableGetCollationsResponse{value: val, isSet: true}
-}
-
-func (v NullableGetCollationsResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetCollationsResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_get_collations_response_test.go b/pkg/sqlserverflexalpha/model_get_collations_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_get_collations_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_get_database_response.go b/pkg/sqlserverflexalpha/model_get_database_response.go
deleted file mode 100644
index 3f30c068..00000000
--- a/pkg/sqlserverflexalpha/model_get_database_response.go
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetDatabaseResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetDatabaseResponse{}
-
-/*
- types and functions for collationName
-*/
-
-// isNotNullableString
-type GetDatabaseResponseGetCollationNameAttributeType = *string
-
-func getGetDatabaseResponseGetCollationNameAttributeTypeOk(arg GetDatabaseResponseGetCollationNameAttributeType) (ret GetDatabaseResponseGetCollationNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetDatabaseResponseGetCollationNameAttributeType(arg *GetDatabaseResponseGetCollationNameAttributeType, val GetDatabaseResponseGetCollationNameRetType) {
- *arg = &val
-}
-
-type GetDatabaseResponseGetCollationNameArgType = string
-type GetDatabaseResponseGetCollationNameRetType = string
-
-/*
- types and functions for compatibilityLevel
-*/
-
-// isInteger
-type GetDatabaseResponseGetCompatibilityLevelAttributeType = *int64
-type GetDatabaseResponseGetCompatibilityLevelArgType = int64
-type GetDatabaseResponseGetCompatibilityLevelRetType = int64
-
-func getGetDatabaseResponseGetCompatibilityLevelAttributeTypeOk(arg GetDatabaseResponseGetCompatibilityLevelAttributeType) (ret GetDatabaseResponseGetCompatibilityLevelRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetDatabaseResponseGetCompatibilityLevelAttributeType(arg *GetDatabaseResponseGetCompatibilityLevelAttributeType, val GetDatabaseResponseGetCompatibilityLevelRetType) {
- *arg = &val
-}
-
-/*
- types and functions for id
-*/
-
-// isLong
-type GetDatabaseResponseGetIdAttributeType = *int64
-type GetDatabaseResponseGetIdArgType = int64
-type GetDatabaseResponseGetIdRetType = int64
-
-func getGetDatabaseResponseGetIdAttributeTypeOk(arg GetDatabaseResponseGetIdAttributeType) (ret GetDatabaseResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetDatabaseResponseGetIdAttributeType(arg *GetDatabaseResponseGetIdAttributeType, val GetDatabaseResponseGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type GetDatabaseResponseGetNameAttributeType = *string
-
-func getGetDatabaseResponseGetNameAttributeTypeOk(arg GetDatabaseResponseGetNameAttributeType) (ret GetDatabaseResponseGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetDatabaseResponseGetNameAttributeType(arg *GetDatabaseResponseGetNameAttributeType, val GetDatabaseResponseGetNameRetType) {
- *arg = &val
-}
-
-type GetDatabaseResponseGetNameArgType = string
-type GetDatabaseResponseGetNameRetType = string
-
-/*
- types and functions for owner
-*/
-
-// isNotNullableString
-type GetDatabaseResponseGetOwnerAttributeType = *string
-
-func getGetDatabaseResponseGetOwnerAttributeTypeOk(arg GetDatabaseResponseGetOwnerAttributeType) (ret GetDatabaseResponseGetOwnerRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetDatabaseResponseGetOwnerAttributeType(arg *GetDatabaseResponseGetOwnerAttributeType, val GetDatabaseResponseGetOwnerRetType) {
- *arg = &val
-}
-
-type GetDatabaseResponseGetOwnerArgType = string
-type GetDatabaseResponseGetOwnerRetType = string
-
-// GetDatabaseResponse struct for GetDatabaseResponse
-type GetDatabaseResponse struct {
- // The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.
- // REQUIRED
- CollationName GetDatabaseResponseGetCollationNameAttributeType `json:"collationName" required:"true"`
- // CompatibilityLevel of the Database.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- CompatibilityLevel GetDatabaseResponseGetCompatibilityLevelAttributeType `json:"compatibilityLevel" required:"true"`
- // The id of the database.
- // REQUIRED
- Id GetDatabaseResponseGetIdAttributeType `json:"id" required:"true"`
- // The name of the database.
- // REQUIRED
- Name GetDatabaseResponseGetNameAttributeType `json:"name" required:"true"`
- // The owner of the database.
- // REQUIRED
- Owner GetDatabaseResponseGetOwnerAttributeType `json:"owner" required:"true"`
-}
-
-type _GetDatabaseResponse GetDatabaseResponse
-
-// NewGetDatabaseResponse instantiates a new GetDatabaseResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetDatabaseResponse(collationName GetDatabaseResponseGetCollationNameArgType, compatibilityLevel GetDatabaseResponseGetCompatibilityLevelArgType, id GetDatabaseResponseGetIdArgType, name GetDatabaseResponseGetNameArgType, owner GetDatabaseResponseGetOwnerArgType) *GetDatabaseResponse {
- this := GetDatabaseResponse{}
- setGetDatabaseResponseGetCollationNameAttributeType(&this.CollationName, collationName)
- setGetDatabaseResponseGetCompatibilityLevelAttributeType(&this.CompatibilityLevel, compatibilityLevel)
- setGetDatabaseResponseGetIdAttributeType(&this.Id, id)
- setGetDatabaseResponseGetNameAttributeType(&this.Name, name)
- setGetDatabaseResponseGetOwnerAttributeType(&this.Owner, owner)
- return &this
-}
-
-// NewGetDatabaseResponseWithDefaults instantiates a new GetDatabaseResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetDatabaseResponseWithDefaults() *GetDatabaseResponse {
- this := GetDatabaseResponse{}
- return &this
-}
-
-// GetCollationName returns the CollationName field value
-func (o *GetDatabaseResponse) GetCollationName() (ret GetDatabaseResponseGetCollationNameRetType) {
- ret, _ = o.GetCollationNameOk()
- return ret
-}
-
-// GetCollationNameOk returns a tuple with the CollationName field value
-// and a boolean to check if the value has been set.
-func (o *GetDatabaseResponse) GetCollationNameOk() (ret GetDatabaseResponseGetCollationNameRetType, ok bool) {
- return getGetDatabaseResponseGetCollationNameAttributeTypeOk(o.CollationName)
-}
-
-// SetCollationName sets field value
-func (o *GetDatabaseResponse) SetCollationName(v GetDatabaseResponseGetCollationNameRetType) {
- setGetDatabaseResponseGetCollationNameAttributeType(&o.CollationName, v)
-}
-
-// GetCompatibilityLevel returns the CompatibilityLevel field value
-func (o *GetDatabaseResponse) GetCompatibilityLevel() (ret GetDatabaseResponseGetCompatibilityLevelRetType) {
- ret, _ = o.GetCompatibilityLevelOk()
- return ret
-}
-
-// GetCompatibilityLevelOk returns a tuple with the CompatibilityLevel field value
-// and a boolean to check if the value has been set.
-func (o *GetDatabaseResponse) GetCompatibilityLevelOk() (ret GetDatabaseResponseGetCompatibilityLevelRetType, ok bool) {
- return getGetDatabaseResponseGetCompatibilityLevelAttributeTypeOk(o.CompatibilityLevel)
-}
-
-// SetCompatibilityLevel sets field value
-func (o *GetDatabaseResponse) SetCompatibilityLevel(v GetDatabaseResponseGetCompatibilityLevelRetType) {
- setGetDatabaseResponseGetCompatibilityLevelAttributeType(&o.CompatibilityLevel, v)
-}
-
-// GetId returns the Id field value
-func (o *GetDatabaseResponse) GetId() (ret GetDatabaseResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *GetDatabaseResponse) GetIdOk() (ret GetDatabaseResponseGetIdRetType, ok bool) {
- return getGetDatabaseResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *GetDatabaseResponse) SetId(v GetDatabaseResponseGetIdRetType) {
- setGetDatabaseResponseGetIdAttributeType(&o.Id, v)
-}
-
-// GetName returns the Name field value
-func (o *GetDatabaseResponse) GetName() (ret GetDatabaseResponseGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *GetDatabaseResponse) GetNameOk() (ret GetDatabaseResponseGetNameRetType, ok bool) {
- return getGetDatabaseResponseGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *GetDatabaseResponse) SetName(v GetDatabaseResponseGetNameRetType) {
- setGetDatabaseResponseGetNameAttributeType(&o.Name, v)
-}
-
-// GetOwner returns the Owner field value
-func (o *GetDatabaseResponse) GetOwner() (ret GetDatabaseResponseGetOwnerRetType) {
- ret, _ = o.GetOwnerOk()
- return ret
-}
-
-// GetOwnerOk returns a tuple with the Owner field value
-// and a boolean to check if the value has been set.
-func (o *GetDatabaseResponse) GetOwnerOk() (ret GetDatabaseResponseGetOwnerRetType, ok bool) {
- return getGetDatabaseResponseGetOwnerAttributeTypeOk(o.Owner)
-}
-
-// SetOwner sets field value
-func (o *GetDatabaseResponse) SetOwner(v GetDatabaseResponseGetOwnerRetType) {
- setGetDatabaseResponseGetOwnerAttributeType(&o.Owner, v)
-}
-
-func (o GetDatabaseResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetDatabaseResponseGetCollationNameAttributeTypeOk(o.CollationName); ok {
- toSerialize["CollationName"] = val
- }
- if val, ok := getGetDatabaseResponseGetCompatibilityLevelAttributeTypeOk(o.CompatibilityLevel); ok {
- toSerialize["CompatibilityLevel"] = val
- }
- if val, ok := getGetDatabaseResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getGetDatabaseResponseGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getGetDatabaseResponseGetOwnerAttributeTypeOk(o.Owner); ok {
- toSerialize["Owner"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetDatabaseResponse struct {
- value *GetDatabaseResponse
- isSet bool
-}
-
-func (v NullableGetDatabaseResponse) Get() *GetDatabaseResponse {
- return v.value
-}
-
-func (v *NullableGetDatabaseResponse) Set(val *GetDatabaseResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetDatabaseResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetDatabaseResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetDatabaseResponse(val *GetDatabaseResponse) *NullableGetDatabaseResponse {
- return &NullableGetDatabaseResponse{value: val, isSet: true}
-}
-
-func (v NullableGetDatabaseResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetDatabaseResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_get_database_response_test.go b/pkg/sqlserverflexalpha/model_get_database_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_get_database_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_get_flavors_response.go b/pkg/sqlserverflexalpha/model_get_flavors_response.go
deleted file mode 100644
index ef79544a..00000000
--- a/pkg/sqlserverflexalpha/model_get_flavors_response.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetFlavorsResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetFlavorsResponse{}
-
-/*
- types and functions for flavors
-*/
-
-// isArray
-type GetFlavorsResponseGetFlavorsAttributeType = *[]ListFlavors
-type GetFlavorsResponseGetFlavorsArgType = []ListFlavors
-type GetFlavorsResponseGetFlavorsRetType = []ListFlavors
-
-func getGetFlavorsResponseGetFlavorsAttributeTypeOk(arg GetFlavorsResponseGetFlavorsAttributeType) (ret GetFlavorsResponseGetFlavorsRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetFlavorsResponseGetFlavorsAttributeType(arg *GetFlavorsResponseGetFlavorsAttributeType, val GetFlavorsResponseGetFlavorsRetType) {
- *arg = &val
-}
-
-/*
- types and functions for pagination
-*/
-
-// isModel
-type GetFlavorsResponseGetPaginationAttributeType = *Pagination
-type GetFlavorsResponseGetPaginationArgType = Pagination
-type GetFlavorsResponseGetPaginationRetType = Pagination
-
-func getGetFlavorsResponseGetPaginationAttributeTypeOk(arg GetFlavorsResponseGetPaginationAttributeType) (ret GetFlavorsResponseGetPaginationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetFlavorsResponseGetPaginationAttributeType(arg *GetFlavorsResponseGetPaginationAttributeType, val GetFlavorsResponseGetPaginationRetType) {
- *arg = &val
-}
-
-// GetFlavorsResponse struct for GetFlavorsResponse
-type GetFlavorsResponse struct {
- // List of flavors available for the project.
- // REQUIRED
- Flavors GetFlavorsResponseGetFlavorsAttributeType `json:"flavors" required:"true"`
- // REQUIRED
- Pagination GetFlavorsResponseGetPaginationAttributeType `json:"pagination" required:"true"`
-}
-
-type _GetFlavorsResponse GetFlavorsResponse
-
-// NewGetFlavorsResponse instantiates a new GetFlavorsResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetFlavorsResponse(flavors GetFlavorsResponseGetFlavorsArgType, pagination GetFlavorsResponseGetPaginationArgType) *GetFlavorsResponse {
- this := GetFlavorsResponse{}
- setGetFlavorsResponseGetFlavorsAttributeType(&this.Flavors, flavors)
- setGetFlavorsResponseGetPaginationAttributeType(&this.Pagination, pagination)
- return &this
-}
-
-// NewGetFlavorsResponseWithDefaults instantiates a new GetFlavorsResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetFlavorsResponseWithDefaults() *GetFlavorsResponse {
- this := GetFlavorsResponse{}
- return &this
-}
-
-// GetFlavors returns the Flavors field value
-func (o *GetFlavorsResponse) GetFlavors() (ret GetFlavorsResponseGetFlavorsRetType) {
- ret, _ = o.GetFlavorsOk()
- return ret
-}
-
-// GetFlavorsOk returns a tuple with the Flavors field value
-// and a boolean to check if the value has been set.
-func (o *GetFlavorsResponse) GetFlavorsOk() (ret GetFlavorsResponseGetFlavorsRetType, ok bool) {
- return getGetFlavorsResponseGetFlavorsAttributeTypeOk(o.Flavors)
-}
-
-// SetFlavors sets field value
-func (o *GetFlavorsResponse) SetFlavors(v GetFlavorsResponseGetFlavorsRetType) {
- setGetFlavorsResponseGetFlavorsAttributeType(&o.Flavors, v)
-}
-
-// GetPagination returns the Pagination field value
-func (o *GetFlavorsResponse) GetPagination() (ret GetFlavorsResponseGetPaginationRetType) {
- ret, _ = o.GetPaginationOk()
- return ret
-}
-
-// GetPaginationOk returns a tuple with the Pagination field value
-// and a boolean to check if the value has been set.
-func (o *GetFlavorsResponse) GetPaginationOk() (ret GetFlavorsResponseGetPaginationRetType, ok bool) {
- return getGetFlavorsResponseGetPaginationAttributeTypeOk(o.Pagination)
-}
-
-// SetPagination sets field value
-func (o *GetFlavorsResponse) SetPagination(v GetFlavorsResponseGetPaginationRetType) {
- setGetFlavorsResponseGetPaginationAttributeType(&o.Pagination, v)
-}
-
-func (o GetFlavorsResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetFlavorsResponseGetFlavorsAttributeTypeOk(o.Flavors); ok {
- toSerialize["Flavors"] = val
- }
- if val, ok := getGetFlavorsResponseGetPaginationAttributeTypeOk(o.Pagination); ok {
- toSerialize["Pagination"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetFlavorsResponse struct {
- value *GetFlavorsResponse
- isSet bool
-}
-
-func (v NullableGetFlavorsResponse) Get() *GetFlavorsResponse {
- return v.value
-}
-
-func (v *NullableGetFlavorsResponse) Set(val *GetFlavorsResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetFlavorsResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetFlavorsResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetFlavorsResponse(val *GetFlavorsResponse) *NullableGetFlavorsResponse {
- return &NullableGetFlavorsResponse{value: val, isSet: true}
-}
-
-func (v NullableGetFlavorsResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetFlavorsResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_get_flavors_response_test.go b/pkg/sqlserverflexalpha/model_get_flavors_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_get_flavors_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_get_instance_response.go b/pkg/sqlserverflexalpha/model_get_instance_response.go
deleted file mode 100644
index d86ee586..00000000
--- a/pkg/sqlserverflexalpha/model_get_instance_response.go
+++ /dev/null
@@ -1,700 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetInstanceResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetInstanceResponse{}
-
-/*
- types and functions for acl
-*/
-
-// isArray
-type GetInstanceResponseGetAclAttributeType = *[]string
-type GetInstanceResponseGetAclArgType = []string
-type GetInstanceResponseGetAclRetType = []string
-
-func getGetInstanceResponseGetAclAttributeTypeOk(arg GetInstanceResponseGetAclAttributeType) (ret GetInstanceResponseGetAclRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetAclAttributeType(arg *GetInstanceResponseGetAclAttributeType, val GetInstanceResponseGetAclRetType) {
- *arg = &val
-}
-
-/*
- types and functions for backupSchedule
-*/
-
-// isNotNullableString
-type GetInstanceResponseGetBackupScheduleAttributeType = *string
-
-func getGetInstanceResponseGetBackupScheduleAttributeTypeOk(arg GetInstanceResponseGetBackupScheduleAttributeType) (ret GetInstanceResponseGetBackupScheduleRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetBackupScheduleAttributeType(arg *GetInstanceResponseGetBackupScheduleAttributeType, val GetInstanceResponseGetBackupScheduleRetType) {
- *arg = &val
-}
-
-type GetInstanceResponseGetBackupScheduleArgType = string
-type GetInstanceResponseGetBackupScheduleRetType = string
-
-/*
- types and functions for edition
-*/
-
-// isEnumRef
-type GetInstanceResponseGetEditionAttributeType = *InstanceEdition
-type GetInstanceResponseGetEditionArgType = InstanceEdition
-type GetInstanceResponseGetEditionRetType = InstanceEdition
-
-func getGetInstanceResponseGetEditionAttributeTypeOk(arg GetInstanceResponseGetEditionAttributeType) (ret GetInstanceResponseGetEditionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetEditionAttributeType(arg *GetInstanceResponseGetEditionAttributeType, val GetInstanceResponseGetEditionRetType) {
- *arg = &val
-}
-
-/*
- types and functions for encryption
-*/
-
-// isModel
-type GetInstanceResponseGetEncryptionAttributeType = *InstanceEncryption
-type GetInstanceResponseGetEncryptionArgType = InstanceEncryption
-type GetInstanceResponseGetEncryptionRetType = InstanceEncryption
-
-func getGetInstanceResponseGetEncryptionAttributeTypeOk(arg GetInstanceResponseGetEncryptionAttributeType) (ret GetInstanceResponseGetEncryptionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetEncryptionAttributeType(arg *GetInstanceResponseGetEncryptionAttributeType, val GetInstanceResponseGetEncryptionRetType) {
- *arg = &val
-}
-
-/*
- types and functions for flavorId
-*/
-
-// isNotNullableString
-type GetInstanceResponseGetFlavorIdAttributeType = *string
-
-func getGetInstanceResponseGetFlavorIdAttributeTypeOk(arg GetInstanceResponseGetFlavorIdAttributeType) (ret GetInstanceResponseGetFlavorIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetFlavorIdAttributeType(arg *GetInstanceResponseGetFlavorIdAttributeType, val GetInstanceResponseGetFlavorIdRetType) {
- *arg = &val
-}
-
-type GetInstanceResponseGetFlavorIdArgType = string
-type GetInstanceResponseGetFlavorIdRetType = string
-
-/*
- types and functions for id
-*/
-
-// isNotNullableString
-type GetInstanceResponseGetIdAttributeType = *string
-
-func getGetInstanceResponseGetIdAttributeTypeOk(arg GetInstanceResponseGetIdAttributeType) (ret GetInstanceResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetIdAttributeType(arg *GetInstanceResponseGetIdAttributeType, val GetInstanceResponseGetIdRetType) {
- *arg = &val
-}
-
-type GetInstanceResponseGetIdArgType = string
-type GetInstanceResponseGetIdRetType = string
-
-/*
- types and functions for isDeletable
-*/
-
-// isBoolean
-type GetInstanceResponsegetIsDeletableAttributeType = *bool
-type GetInstanceResponsegetIsDeletableArgType = bool
-type GetInstanceResponsegetIsDeletableRetType = bool
-
-func getGetInstanceResponsegetIsDeletableAttributeTypeOk(arg GetInstanceResponsegetIsDeletableAttributeType) (ret GetInstanceResponsegetIsDeletableRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponsegetIsDeletableAttributeType(arg *GetInstanceResponsegetIsDeletableAttributeType, val GetInstanceResponsegetIsDeletableRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type GetInstanceResponseGetNameAttributeType = *string
-
-func getGetInstanceResponseGetNameAttributeTypeOk(arg GetInstanceResponseGetNameAttributeType) (ret GetInstanceResponseGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetNameAttributeType(arg *GetInstanceResponseGetNameAttributeType, val GetInstanceResponseGetNameRetType) {
- *arg = &val
-}
-
-type GetInstanceResponseGetNameArgType = string
-type GetInstanceResponseGetNameRetType = string
-
-/*
- types and functions for network
-*/
-
-// isModel
-type GetInstanceResponseGetNetworkAttributeType = *InstanceNetwork
-type GetInstanceResponseGetNetworkArgType = InstanceNetwork
-type GetInstanceResponseGetNetworkRetType = InstanceNetwork
-
-func getGetInstanceResponseGetNetworkAttributeTypeOk(arg GetInstanceResponseGetNetworkAttributeType) (ret GetInstanceResponseGetNetworkRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetNetworkAttributeType(arg *GetInstanceResponseGetNetworkAttributeType, val GetInstanceResponseGetNetworkRetType) {
- *arg = &val
-}
-
-/*
- types and functions for replicas
-*/
-
-// isEnumRef
-type GetInstanceResponseGetReplicasAttributeType = *Replicas
-type GetInstanceResponseGetReplicasArgType = Replicas
-type GetInstanceResponseGetReplicasRetType = Replicas
-
-func getGetInstanceResponseGetReplicasAttributeTypeOk(arg GetInstanceResponseGetReplicasAttributeType) (ret GetInstanceResponseGetReplicasRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetReplicasAttributeType(arg *GetInstanceResponseGetReplicasAttributeType, val GetInstanceResponseGetReplicasRetType) {
- *arg = &val
-}
-
-/*
- types and functions for retentionDays
-*/
-
-// isInteger
-type GetInstanceResponseGetRetentionDaysAttributeType = *int64
-type GetInstanceResponseGetRetentionDaysArgType = int64
-type GetInstanceResponseGetRetentionDaysRetType = int64
-
-func getGetInstanceResponseGetRetentionDaysAttributeTypeOk(arg GetInstanceResponseGetRetentionDaysAttributeType) (ret GetInstanceResponseGetRetentionDaysRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetRetentionDaysAttributeType(arg *GetInstanceResponseGetRetentionDaysAttributeType, val GetInstanceResponseGetRetentionDaysRetType) {
- *arg = &val
-}
-
-/*
- types and functions for status
-*/
-
-// isEnumRef
-type GetInstanceResponseGetStatusAttributeType = *Status
-type GetInstanceResponseGetStatusArgType = Status
-type GetInstanceResponseGetStatusRetType = Status
-
-func getGetInstanceResponseGetStatusAttributeTypeOk(arg GetInstanceResponseGetStatusAttributeType) (ret GetInstanceResponseGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetStatusAttributeType(arg *GetInstanceResponseGetStatusAttributeType, val GetInstanceResponseGetStatusRetType) {
- *arg = &val
-}
-
-/*
- types and functions for storage
-*/
-
-// isModel
-type GetInstanceResponseGetStorageAttributeType = *Storage
-type GetInstanceResponseGetStorageArgType = Storage
-type GetInstanceResponseGetStorageRetType = Storage
-
-func getGetInstanceResponseGetStorageAttributeTypeOk(arg GetInstanceResponseGetStorageAttributeType) (ret GetInstanceResponseGetStorageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetStorageAttributeType(arg *GetInstanceResponseGetStorageAttributeType, val GetInstanceResponseGetStorageRetType) {
- *arg = &val
-}
-
-/*
- types and functions for version
-*/
-
-// isEnumRef
-type GetInstanceResponseGetVersionAttributeType = *InstanceVersion
-type GetInstanceResponseGetVersionArgType = InstanceVersion
-type GetInstanceResponseGetVersionRetType = InstanceVersion
-
-func getGetInstanceResponseGetVersionAttributeTypeOk(arg GetInstanceResponseGetVersionAttributeType) (ret GetInstanceResponseGetVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetInstanceResponseGetVersionAttributeType(arg *GetInstanceResponseGetVersionAttributeType, val GetInstanceResponseGetVersionRetType) {
- *arg = &val
-}
-
-// GetInstanceResponse struct for GetInstanceResponse
-type GetInstanceResponse struct {
- // List of IPV4 cidr.
- // REQUIRED
- Acl GetInstanceResponseGetAclAttributeType `json:"acl" required:"true"`
- // The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.
- // REQUIRED
- BackupSchedule GetInstanceResponseGetBackupScheduleAttributeType `json:"backupSchedule" required:"true"`
- // REQUIRED
- Edition GetInstanceResponseGetEditionAttributeType `json:"edition" required:"true"`
- Encryption GetInstanceResponseGetEncryptionAttributeType `json:"encryption,omitempty"`
- // The id of the instance flavor.
- // REQUIRED
- FlavorId GetInstanceResponseGetFlavorIdAttributeType `json:"flavorId" required:"true"`
- // The ID of the instance.
- // REQUIRED
- Id GetInstanceResponseGetIdAttributeType `json:"id" required:"true"`
- // Whether the instance can be deleted or not.
- // REQUIRED
- IsDeletable GetInstanceResponsegetIsDeletableAttributeType `json:"isDeletable" required:"true"`
- // The name of the instance.
- // REQUIRED
- Name GetInstanceResponseGetNameAttributeType `json:"name" required:"true"`
- // REQUIRED
- Network GetInstanceResponseGetNetworkAttributeType `json:"network" required:"true"`
- // REQUIRED
- Replicas GetInstanceResponseGetReplicasAttributeType `json:"replicas" required:"true"`
- // The days for how long the backup files should be stored before cleaned up. 30 to 365
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- RetentionDays GetInstanceResponseGetRetentionDaysAttributeType `json:"retentionDays" required:"true"`
- // REQUIRED
- Status GetInstanceResponseGetStatusAttributeType `json:"status" required:"true"`
- // REQUIRED
- Storage GetInstanceResponseGetStorageAttributeType `json:"storage" required:"true"`
- // REQUIRED
- Version GetInstanceResponseGetVersionAttributeType `json:"version" required:"true"`
-}
-
-type _GetInstanceResponse GetInstanceResponse
-
-// NewGetInstanceResponse instantiates a new GetInstanceResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetInstanceResponse(acl GetInstanceResponseGetAclArgType, backupSchedule GetInstanceResponseGetBackupScheduleArgType, edition GetInstanceResponseGetEditionArgType, flavorId GetInstanceResponseGetFlavorIdArgType, id GetInstanceResponseGetIdArgType, isDeletable GetInstanceResponsegetIsDeletableArgType, name GetInstanceResponseGetNameArgType, network GetInstanceResponseGetNetworkArgType, replicas GetInstanceResponseGetReplicasArgType, retentionDays GetInstanceResponseGetRetentionDaysArgType, status GetInstanceResponseGetStatusArgType, storage GetInstanceResponseGetStorageArgType, version GetInstanceResponseGetVersionArgType) *GetInstanceResponse {
- this := GetInstanceResponse{}
- setGetInstanceResponseGetAclAttributeType(&this.Acl, acl)
- setGetInstanceResponseGetBackupScheduleAttributeType(&this.BackupSchedule, backupSchedule)
- setGetInstanceResponseGetEditionAttributeType(&this.Edition, edition)
- setGetInstanceResponseGetFlavorIdAttributeType(&this.FlavorId, flavorId)
- setGetInstanceResponseGetIdAttributeType(&this.Id, id)
- setGetInstanceResponsegetIsDeletableAttributeType(&this.IsDeletable, isDeletable)
- setGetInstanceResponseGetNameAttributeType(&this.Name, name)
- setGetInstanceResponseGetNetworkAttributeType(&this.Network, network)
- setGetInstanceResponseGetReplicasAttributeType(&this.Replicas, replicas)
- setGetInstanceResponseGetRetentionDaysAttributeType(&this.RetentionDays, retentionDays)
- setGetInstanceResponseGetStatusAttributeType(&this.Status, status)
- setGetInstanceResponseGetStorageAttributeType(&this.Storage, storage)
- setGetInstanceResponseGetVersionAttributeType(&this.Version, version)
- return &this
-}
-
-// NewGetInstanceResponseWithDefaults instantiates a new GetInstanceResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetInstanceResponseWithDefaults() *GetInstanceResponse {
- this := GetInstanceResponse{}
- return &this
-}
-
-// GetAcl returns the Acl field value
-func (o *GetInstanceResponse) GetAcl() (ret GetInstanceResponseGetAclRetType) {
- ret, _ = o.GetAclOk()
- return ret
-}
-
-// GetAclOk returns a tuple with the Acl field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetAclOk() (ret GetInstanceResponseGetAclRetType, ok bool) {
- return getGetInstanceResponseGetAclAttributeTypeOk(o.Acl)
-}
-
-// SetAcl sets field value
-func (o *GetInstanceResponse) SetAcl(v GetInstanceResponseGetAclRetType) {
- setGetInstanceResponseGetAclAttributeType(&o.Acl, v)
-}
-
-// GetBackupSchedule returns the BackupSchedule field value
-func (o *GetInstanceResponse) GetBackupSchedule() (ret GetInstanceResponseGetBackupScheduleRetType) {
- ret, _ = o.GetBackupScheduleOk()
- return ret
-}
-
-// GetBackupScheduleOk returns a tuple with the BackupSchedule field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetBackupScheduleOk() (ret GetInstanceResponseGetBackupScheduleRetType, ok bool) {
- return getGetInstanceResponseGetBackupScheduleAttributeTypeOk(o.BackupSchedule)
-}
-
-// SetBackupSchedule sets field value
-func (o *GetInstanceResponse) SetBackupSchedule(v GetInstanceResponseGetBackupScheduleRetType) {
- setGetInstanceResponseGetBackupScheduleAttributeType(&o.BackupSchedule, v)
-}
-
-// GetEdition returns the Edition field value
-func (o *GetInstanceResponse) GetEdition() (ret GetInstanceResponseGetEditionRetType) {
- ret, _ = o.GetEditionOk()
- return ret
-}
-
-// GetEditionOk returns a tuple with the Edition field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetEditionOk() (ret GetInstanceResponseGetEditionRetType, ok bool) {
- return getGetInstanceResponseGetEditionAttributeTypeOk(o.Edition)
-}
-
-// SetEdition sets field value
-func (o *GetInstanceResponse) SetEdition(v GetInstanceResponseGetEditionRetType) {
- setGetInstanceResponseGetEditionAttributeType(&o.Edition, v)
-}
-
-// GetEncryption returns the Encryption field value if set, zero value otherwise.
-func (o *GetInstanceResponse) GetEncryption() (res GetInstanceResponseGetEncryptionRetType) {
- res, _ = o.GetEncryptionOk()
- return
-}
-
-// GetEncryptionOk returns a tuple with the Encryption field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetEncryptionOk() (ret GetInstanceResponseGetEncryptionRetType, ok bool) {
- return getGetInstanceResponseGetEncryptionAttributeTypeOk(o.Encryption)
-}
-
-// HasEncryption returns a boolean if a field has been set.
-func (o *GetInstanceResponse) HasEncryption() bool {
- _, ok := o.GetEncryptionOk()
- return ok
-}
-
-// SetEncryption gets a reference to the given InstanceEncryption and assigns it to the Encryption field.
-func (o *GetInstanceResponse) SetEncryption(v GetInstanceResponseGetEncryptionRetType) {
- setGetInstanceResponseGetEncryptionAttributeType(&o.Encryption, v)
-}
-
-// GetFlavorId returns the FlavorId field value
-func (o *GetInstanceResponse) GetFlavorId() (ret GetInstanceResponseGetFlavorIdRetType) {
- ret, _ = o.GetFlavorIdOk()
- return ret
-}
-
-// GetFlavorIdOk returns a tuple with the FlavorId field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetFlavorIdOk() (ret GetInstanceResponseGetFlavorIdRetType, ok bool) {
- return getGetInstanceResponseGetFlavorIdAttributeTypeOk(o.FlavorId)
-}
-
-// SetFlavorId sets field value
-func (o *GetInstanceResponse) SetFlavorId(v GetInstanceResponseGetFlavorIdRetType) {
- setGetInstanceResponseGetFlavorIdAttributeType(&o.FlavorId, v)
-}
-
-// GetId returns the Id field value
-func (o *GetInstanceResponse) GetId() (ret GetInstanceResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetIdOk() (ret GetInstanceResponseGetIdRetType, ok bool) {
- return getGetInstanceResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *GetInstanceResponse) SetId(v GetInstanceResponseGetIdRetType) {
- setGetInstanceResponseGetIdAttributeType(&o.Id, v)
-}
-
-// GetIsDeletable returns the IsDeletable field value
-func (o *GetInstanceResponse) GetIsDeletable() (ret GetInstanceResponsegetIsDeletableRetType) {
- ret, _ = o.GetIsDeletableOk()
- return ret
-}
-
-// GetIsDeletableOk returns a tuple with the IsDeletable field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetIsDeletableOk() (ret GetInstanceResponsegetIsDeletableRetType, ok bool) {
- return getGetInstanceResponsegetIsDeletableAttributeTypeOk(o.IsDeletable)
-}
-
-// SetIsDeletable sets field value
-func (o *GetInstanceResponse) SetIsDeletable(v GetInstanceResponsegetIsDeletableRetType) {
- setGetInstanceResponsegetIsDeletableAttributeType(&o.IsDeletable, v)
-}
-
-// GetName returns the Name field value
-func (o *GetInstanceResponse) GetName() (ret GetInstanceResponseGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetNameOk() (ret GetInstanceResponseGetNameRetType, ok bool) {
- return getGetInstanceResponseGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *GetInstanceResponse) SetName(v GetInstanceResponseGetNameRetType) {
- setGetInstanceResponseGetNameAttributeType(&o.Name, v)
-}
-
-// GetNetwork returns the Network field value
-func (o *GetInstanceResponse) GetNetwork() (ret GetInstanceResponseGetNetworkRetType) {
- ret, _ = o.GetNetworkOk()
- return ret
-}
-
-// GetNetworkOk returns a tuple with the Network field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetNetworkOk() (ret GetInstanceResponseGetNetworkRetType, ok bool) {
- return getGetInstanceResponseGetNetworkAttributeTypeOk(o.Network)
-}
-
-// SetNetwork sets field value
-func (o *GetInstanceResponse) SetNetwork(v GetInstanceResponseGetNetworkRetType) {
- setGetInstanceResponseGetNetworkAttributeType(&o.Network, v)
-}
-
-// GetReplicas returns the Replicas field value
-func (o *GetInstanceResponse) GetReplicas() (ret GetInstanceResponseGetReplicasRetType) {
- ret, _ = o.GetReplicasOk()
- return ret
-}
-
-// GetReplicasOk returns a tuple with the Replicas field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetReplicasOk() (ret GetInstanceResponseGetReplicasRetType, ok bool) {
- return getGetInstanceResponseGetReplicasAttributeTypeOk(o.Replicas)
-}
-
-// SetReplicas sets field value
-func (o *GetInstanceResponse) SetReplicas(v GetInstanceResponseGetReplicasRetType) {
- setGetInstanceResponseGetReplicasAttributeType(&o.Replicas, v)
-}
-
-// GetRetentionDays returns the RetentionDays field value
-func (o *GetInstanceResponse) GetRetentionDays() (ret GetInstanceResponseGetRetentionDaysRetType) {
- ret, _ = o.GetRetentionDaysOk()
- return ret
-}
-
-// GetRetentionDaysOk returns a tuple with the RetentionDays field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetRetentionDaysOk() (ret GetInstanceResponseGetRetentionDaysRetType, ok bool) {
- return getGetInstanceResponseGetRetentionDaysAttributeTypeOk(o.RetentionDays)
-}
-
-// SetRetentionDays sets field value
-func (o *GetInstanceResponse) SetRetentionDays(v GetInstanceResponseGetRetentionDaysRetType) {
- setGetInstanceResponseGetRetentionDaysAttributeType(&o.RetentionDays, v)
-}
-
-// GetStatus returns the Status field value
-func (o *GetInstanceResponse) GetStatus() (ret GetInstanceResponseGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetStatusOk() (ret GetInstanceResponseGetStatusRetType, ok bool) {
- return getGetInstanceResponseGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *GetInstanceResponse) SetStatus(v GetInstanceResponseGetStatusRetType) {
- setGetInstanceResponseGetStatusAttributeType(&o.Status, v)
-}
-
-// GetStorage returns the Storage field value
-func (o *GetInstanceResponse) GetStorage() (ret GetInstanceResponseGetStorageRetType) {
- ret, _ = o.GetStorageOk()
- return ret
-}
-
-// GetStorageOk returns a tuple with the Storage field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetStorageOk() (ret GetInstanceResponseGetStorageRetType, ok bool) {
- return getGetInstanceResponseGetStorageAttributeTypeOk(o.Storage)
-}
-
-// SetStorage sets field value
-func (o *GetInstanceResponse) SetStorage(v GetInstanceResponseGetStorageRetType) {
- setGetInstanceResponseGetStorageAttributeType(&o.Storage, v)
-}
-
-// GetVersion returns the Version field value
-func (o *GetInstanceResponse) GetVersion() (ret GetInstanceResponseGetVersionRetType) {
- ret, _ = o.GetVersionOk()
- return ret
-}
-
-// GetVersionOk returns a tuple with the Version field value
-// and a boolean to check if the value has been set.
-func (o *GetInstanceResponse) GetVersionOk() (ret GetInstanceResponseGetVersionRetType, ok bool) {
- return getGetInstanceResponseGetVersionAttributeTypeOk(o.Version)
-}
-
-// SetVersion sets field value
-func (o *GetInstanceResponse) SetVersion(v GetInstanceResponseGetVersionRetType) {
- setGetInstanceResponseGetVersionAttributeType(&o.Version, v)
-}
-
-func (o GetInstanceResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetInstanceResponseGetAclAttributeTypeOk(o.Acl); ok {
- toSerialize["Acl"] = val
- }
- if val, ok := getGetInstanceResponseGetBackupScheduleAttributeTypeOk(o.BackupSchedule); ok {
- toSerialize["BackupSchedule"] = val
- }
- if val, ok := getGetInstanceResponseGetEditionAttributeTypeOk(o.Edition); ok {
- toSerialize["Edition"] = val
- }
- if val, ok := getGetInstanceResponseGetEncryptionAttributeTypeOk(o.Encryption); ok {
- toSerialize["Encryption"] = val
- }
- if val, ok := getGetInstanceResponseGetFlavorIdAttributeTypeOk(o.FlavorId); ok {
- toSerialize["FlavorId"] = val
- }
- if val, ok := getGetInstanceResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getGetInstanceResponsegetIsDeletableAttributeTypeOk(o.IsDeletable); ok {
- toSerialize["IsDeletable"] = val
- }
- if val, ok := getGetInstanceResponseGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getGetInstanceResponseGetNetworkAttributeTypeOk(o.Network); ok {
- toSerialize["Network"] = val
- }
- if val, ok := getGetInstanceResponseGetReplicasAttributeTypeOk(o.Replicas); ok {
- toSerialize["Replicas"] = val
- }
- if val, ok := getGetInstanceResponseGetRetentionDaysAttributeTypeOk(o.RetentionDays); ok {
- toSerialize["RetentionDays"] = val
- }
- if val, ok := getGetInstanceResponseGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- if val, ok := getGetInstanceResponseGetStorageAttributeTypeOk(o.Storage); ok {
- toSerialize["Storage"] = val
- }
- if val, ok := getGetInstanceResponseGetVersionAttributeTypeOk(o.Version); ok {
- toSerialize["Version"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetInstanceResponse struct {
- value *GetInstanceResponse
- isSet bool
-}
-
-func (v NullableGetInstanceResponse) Get() *GetInstanceResponse {
- return v.value
-}
-
-func (v *NullableGetInstanceResponse) Set(val *GetInstanceResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetInstanceResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetInstanceResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetInstanceResponse(val *GetInstanceResponse) *NullableGetInstanceResponse {
- return &NullableGetInstanceResponse{value: val, isSet: true}
-}
-
-func (v NullableGetInstanceResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetInstanceResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_get_instance_response_test.go b/pkg/sqlserverflexalpha/model_get_instance_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_get_instance_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_get_storages_response.go b/pkg/sqlserverflexalpha/model_get_storages_response.go
deleted file mode 100644
index 6a1b6d53..00000000
--- a/pkg/sqlserverflexalpha/model_get_storages_response.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetStoragesResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetStoragesResponse{}
-
-/*
- types and functions for storageClasses
-*/
-
-// isArray
-type GetStoragesResponseGetStorageClassesAttributeType = *[]FlavorStorageClassesStorageClass
-type GetStoragesResponseGetStorageClassesArgType = []FlavorStorageClassesStorageClass
-type GetStoragesResponseGetStorageClassesRetType = []FlavorStorageClassesStorageClass
-
-func getGetStoragesResponseGetStorageClassesAttributeTypeOk(arg GetStoragesResponseGetStorageClassesAttributeType) (ret GetStoragesResponseGetStorageClassesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetStoragesResponseGetStorageClassesAttributeType(arg *GetStoragesResponseGetStorageClassesAttributeType, val GetStoragesResponseGetStorageClassesRetType) {
- *arg = &val
-}
-
-/*
- types and functions for storageRange
-*/
-
-// isModel
-type GetStoragesResponseGetStorageRangeAttributeType = *FlavorStorageRange
-type GetStoragesResponseGetStorageRangeArgType = FlavorStorageRange
-type GetStoragesResponseGetStorageRangeRetType = FlavorStorageRange
-
-func getGetStoragesResponseGetStorageRangeAttributeTypeOk(arg GetStoragesResponseGetStorageRangeAttributeType) (ret GetStoragesResponseGetStorageRangeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetStoragesResponseGetStorageRangeAttributeType(arg *GetStoragesResponseGetStorageRangeAttributeType, val GetStoragesResponseGetStorageRangeRetType) {
- *arg = &val
-}
-
-// GetStoragesResponse struct for GetStoragesResponse
-type GetStoragesResponse struct {
- // maximum storage which can be ordered for the flavor in Gigabyte.
- // REQUIRED
- StorageClasses GetStoragesResponseGetStorageClassesAttributeType `json:"storageClasses" required:"true"`
- // REQUIRED
- StorageRange GetStoragesResponseGetStorageRangeAttributeType `json:"storageRange" required:"true"`
-}
-
-type _GetStoragesResponse GetStoragesResponse
-
-// NewGetStoragesResponse instantiates a new GetStoragesResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetStoragesResponse(storageClasses GetStoragesResponseGetStorageClassesArgType, storageRange GetStoragesResponseGetStorageRangeArgType) *GetStoragesResponse {
- this := GetStoragesResponse{}
- setGetStoragesResponseGetStorageClassesAttributeType(&this.StorageClasses, storageClasses)
- setGetStoragesResponseGetStorageRangeAttributeType(&this.StorageRange, storageRange)
- return &this
-}
-
-// NewGetStoragesResponseWithDefaults instantiates a new GetStoragesResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetStoragesResponseWithDefaults() *GetStoragesResponse {
- this := GetStoragesResponse{}
- return &this
-}
-
-// GetStorageClasses returns the StorageClasses field value
-func (o *GetStoragesResponse) GetStorageClasses() (ret GetStoragesResponseGetStorageClassesRetType) {
- ret, _ = o.GetStorageClassesOk()
- return ret
-}
-
-// GetStorageClassesOk returns a tuple with the StorageClasses field value
-// and a boolean to check if the value has been set.
-func (o *GetStoragesResponse) GetStorageClassesOk() (ret GetStoragesResponseGetStorageClassesRetType, ok bool) {
- return getGetStoragesResponseGetStorageClassesAttributeTypeOk(o.StorageClasses)
-}
-
-// SetStorageClasses sets field value
-func (o *GetStoragesResponse) SetStorageClasses(v GetStoragesResponseGetStorageClassesRetType) {
- setGetStoragesResponseGetStorageClassesAttributeType(&o.StorageClasses, v)
-}
-
-// GetStorageRange returns the StorageRange field value
-func (o *GetStoragesResponse) GetStorageRange() (ret GetStoragesResponseGetStorageRangeRetType) {
- ret, _ = o.GetStorageRangeOk()
- return ret
-}
-
-// GetStorageRangeOk returns a tuple with the StorageRange field value
-// and a boolean to check if the value has been set.
-func (o *GetStoragesResponse) GetStorageRangeOk() (ret GetStoragesResponseGetStorageRangeRetType, ok bool) {
- return getGetStoragesResponseGetStorageRangeAttributeTypeOk(o.StorageRange)
-}
-
-// SetStorageRange sets field value
-func (o *GetStoragesResponse) SetStorageRange(v GetStoragesResponseGetStorageRangeRetType) {
- setGetStoragesResponseGetStorageRangeAttributeType(&o.StorageRange, v)
-}
-
-func (o GetStoragesResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetStoragesResponseGetStorageClassesAttributeTypeOk(o.StorageClasses); ok {
- toSerialize["StorageClasses"] = val
- }
- if val, ok := getGetStoragesResponseGetStorageRangeAttributeTypeOk(o.StorageRange); ok {
- toSerialize["StorageRange"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetStoragesResponse struct {
- value *GetStoragesResponse
- isSet bool
-}
-
-func (v NullableGetStoragesResponse) Get() *GetStoragesResponse {
- return v.value
-}
-
-func (v *NullableGetStoragesResponse) Set(val *GetStoragesResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetStoragesResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetStoragesResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetStoragesResponse(val *GetStoragesResponse) *NullableGetStoragesResponse {
- return &NullableGetStoragesResponse{value: val, isSet: true}
-}
-
-func (v NullableGetStoragesResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetStoragesResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_get_storages_response_test.go b/pkg/sqlserverflexalpha/model_get_storages_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_get_storages_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_get_user_response.go b/pkg/sqlserverflexalpha/model_get_user_response.go
deleted file mode 100644
index 979e505f..00000000
--- a/pkg/sqlserverflexalpha/model_get_user_response.go
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetUserResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetUserResponse{}
-
-/*
- types and functions for default_database
-*/
-
-// isNotNullableString
-type GetUserResponseGetDefaultDatabaseAttributeType = *string
-
-func getGetUserResponseGetDefaultDatabaseAttributeTypeOk(arg GetUserResponseGetDefaultDatabaseAttributeType) (ret GetUserResponseGetDefaultDatabaseRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetDefaultDatabaseAttributeType(arg *GetUserResponseGetDefaultDatabaseAttributeType, val GetUserResponseGetDefaultDatabaseRetType) {
- *arg = &val
-}
-
-type GetUserResponseGetDefaultDatabaseArgType = string
-type GetUserResponseGetDefaultDatabaseRetType = string
-
-/*
- types and functions for host
-*/
-
-// isNotNullableString
-type GetUserResponseGetHostAttributeType = *string
-
-func getGetUserResponseGetHostAttributeTypeOk(arg GetUserResponseGetHostAttributeType) (ret GetUserResponseGetHostRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetHostAttributeType(arg *GetUserResponseGetHostAttributeType, val GetUserResponseGetHostRetType) {
- *arg = &val
-}
-
-type GetUserResponseGetHostArgType = string
-type GetUserResponseGetHostRetType = string
-
-/*
- types and functions for id
-*/
-
-// isLong
-type GetUserResponseGetIdAttributeType = *int64
-type GetUserResponseGetIdArgType = int64
-type GetUserResponseGetIdRetType = int64
-
-func getGetUserResponseGetIdAttributeTypeOk(arg GetUserResponseGetIdAttributeType) (ret GetUserResponseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetIdAttributeType(arg *GetUserResponseGetIdAttributeType, val GetUserResponseGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for port
-*/
-
-// isInteger
-type GetUserResponseGetPortAttributeType = *int64
-type GetUserResponseGetPortArgType = int64
-type GetUserResponseGetPortRetType = int64
-
-func getGetUserResponseGetPortAttributeTypeOk(arg GetUserResponseGetPortAttributeType) (ret GetUserResponseGetPortRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetPortAttributeType(arg *GetUserResponseGetPortAttributeType, val GetUserResponseGetPortRetType) {
- *arg = &val
-}
-
-/*
- types and functions for roles
-*/
-
-// isArray
-type GetUserResponseGetRolesAttributeType = *[]UserRole
-type GetUserResponseGetRolesArgType = []UserRole
-type GetUserResponseGetRolesRetType = []UserRole
-
-func getGetUserResponseGetRolesAttributeTypeOk(arg GetUserResponseGetRolesAttributeType) (ret GetUserResponseGetRolesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetRolesAttributeType(arg *GetUserResponseGetRolesAttributeType, val GetUserResponseGetRolesRetType) {
- *arg = &val
-}
-
-/*
- types and functions for status
-*/
-
-// isNotNullableString
-type GetUserResponseGetStatusAttributeType = *string
-
-func getGetUserResponseGetStatusAttributeTypeOk(arg GetUserResponseGetStatusAttributeType) (ret GetUserResponseGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetStatusAttributeType(arg *GetUserResponseGetStatusAttributeType, val GetUserResponseGetStatusRetType) {
- *arg = &val
-}
-
-type GetUserResponseGetStatusArgType = string
-type GetUserResponseGetStatusRetType = string
-
-/*
- types and functions for username
-*/
-
-// isNotNullableString
-type GetUserResponseGetUsernameAttributeType = *string
-
-func getGetUserResponseGetUsernameAttributeTypeOk(arg GetUserResponseGetUsernameAttributeType) (ret GetUserResponseGetUsernameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetUserResponseGetUsernameAttributeType(arg *GetUserResponseGetUsernameAttributeType, val GetUserResponseGetUsernameRetType) {
- *arg = &val
-}
-
-type GetUserResponseGetUsernameArgType = string
-type GetUserResponseGetUsernameRetType = string
-
-// GetUserResponse struct for GetUserResponse
-type GetUserResponse struct {
- // The default database for a user of the instance.
- // REQUIRED
- DefaultDatabase GetUserResponseGetDefaultDatabaseAttributeType `json:"default_database" required:"true"`
- // The host of the instance in which the user belongs to.
- // REQUIRED
- Host GetUserResponseGetHostAttributeType `json:"host" required:"true"`
- // The ID of the user.
- // REQUIRED
- Id GetUserResponseGetIdAttributeType `json:"id" required:"true"`
- // The port of the instance in which the user belongs to.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- Port GetUserResponseGetPortAttributeType `json:"port" required:"true"`
- // A list of user roles.
- // REQUIRED
- Roles GetUserResponseGetRolesAttributeType `json:"roles" required:"true"`
- // The current status of the user.
- // REQUIRED
- Status GetUserResponseGetStatusAttributeType `json:"status" required:"true"`
- // The name of the user.
- // REQUIRED
- Username GetUserResponseGetUsernameAttributeType `json:"username" required:"true"`
-}
-
-type _GetUserResponse GetUserResponse
-
-// NewGetUserResponse instantiates a new GetUserResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetUserResponse(defaultDatabase GetUserResponseGetDefaultDatabaseArgType, host GetUserResponseGetHostArgType, id GetUserResponseGetIdArgType, port GetUserResponseGetPortArgType, roles GetUserResponseGetRolesArgType, status GetUserResponseGetStatusArgType, username GetUserResponseGetUsernameArgType) *GetUserResponse {
- this := GetUserResponse{}
- setGetUserResponseGetDefaultDatabaseAttributeType(&this.DefaultDatabase, defaultDatabase)
- setGetUserResponseGetHostAttributeType(&this.Host, host)
- setGetUserResponseGetIdAttributeType(&this.Id, id)
- setGetUserResponseGetPortAttributeType(&this.Port, port)
- setGetUserResponseGetRolesAttributeType(&this.Roles, roles)
- setGetUserResponseGetStatusAttributeType(&this.Status, status)
- setGetUserResponseGetUsernameAttributeType(&this.Username, username)
- return &this
-}
-
-// NewGetUserResponseWithDefaults instantiates a new GetUserResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetUserResponseWithDefaults() *GetUserResponse {
- this := GetUserResponse{}
- return &this
-}
-
-// GetDefaultDatabase returns the DefaultDatabase field value
-func (o *GetUserResponse) GetDefaultDatabase() (ret GetUserResponseGetDefaultDatabaseRetType) {
- ret, _ = o.GetDefaultDatabaseOk()
- return ret
-}
-
-// GetDefaultDatabaseOk returns a tuple with the DefaultDatabase field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetDefaultDatabaseOk() (ret GetUserResponseGetDefaultDatabaseRetType, ok bool) {
- return getGetUserResponseGetDefaultDatabaseAttributeTypeOk(o.DefaultDatabase)
-}
-
-// SetDefaultDatabase sets field value
-func (o *GetUserResponse) SetDefaultDatabase(v GetUserResponseGetDefaultDatabaseRetType) {
- setGetUserResponseGetDefaultDatabaseAttributeType(&o.DefaultDatabase, v)
-}
-
-// GetHost returns the Host field value
-func (o *GetUserResponse) GetHost() (ret GetUserResponseGetHostRetType) {
- ret, _ = o.GetHostOk()
- return ret
-}
-
-// GetHostOk returns a tuple with the Host field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetHostOk() (ret GetUserResponseGetHostRetType, ok bool) {
- return getGetUserResponseGetHostAttributeTypeOk(o.Host)
-}
-
-// SetHost sets field value
-func (o *GetUserResponse) SetHost(v GetUserResponseGetHostRetType) {
- setGetUserResponseGetHostAttributeType(&o.Host, v)
-}
-
-// GetId returns the Id field value
-func (o *GetUserResponse) GetId() (ret GetUserResponseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetIdOk() (ret GetUserResponseGetIdRetType, ok bool) {
- return getGetUserResponseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *GetUserResponse) SetId(v GetUserResponseGetIdRetType) {
- setGetUserResponseGetIdAttributeType(&o.Id, v)
-}
-
-// GetPort returns the Port field value
-func (o *GetUserResponse) GetPort() (ret GetUserResponseGetPortRetType) {
- ret, _ = o.GetPortOk()
- return ret
-}
-
-// GetPortOk returns a tuple with the Port field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetPortOk() (ret GetUserResponseGetPortRetType, ok bool) {
- return getGetUserResponseGetPortAttributeTypeOk(o.Port)
-}
-
-// SetPort sets field value
-func (o *GetUserResponse) SetPort(v GetUserResponseGetPortRetType) {
- setGetUserResponseGetPortAttributeType(&o.Port, v)
-}
-
-// GetRoles returns the Roles field value
-func (o *GetUserResponse) GetRoles() (ret GetUserResponseGetRolesRetType) {
- ret, _ = o.GetRolesOk()
- return ret
-}
-
-// GetRolesOk returns a tuple with the Roles field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetRolesOk() (ret GetUserResponseGetRolesRetType, ok bool) {
- return getGetUserResponseGetRolesAttributeTypeOk(o.Roles)
-}
-
-// SetRoles sets field value
-func (o *GetUserResponse) SetRoles(v GetUserResponseGetRolesRetType) {
- setGetUserResponseGetRolesAttributeType(&o.Roles, v)
-}
-
-// GetStatus returns the Status field value
-func (o *GetUserResponse) GetStatus() (ret GetUserResponseGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetStatusOk() (ret GetUserResponseGetStatusRetType, ok bool) {
- return getGetUserResponseGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *GetUserResponse) SetStatus(v GetUserResponseGetStatusRetType) {
- setGetUserResponseGetStatusAttributeType(&o.Status, v)
-}
-
-// GetUsername returns the Username field value
-func (o *GetUserResponse) GetUsername() (ret GetUserResponseGetUsernameRetType) {
- ret, _ = o.GetUsernameOk()
- return ret
-}
-
-// GetUsernameOk returns a tuple with the Username field value
-// and a boolean to check if the value has been set.
-func (o *GetUserResponse) GetUsernameOk() (ret GetUserResponseGetUsernameRetType, ok bool) {
- return getGetUserResponseGetUsernameAttributeTypeOk(o.Username)
-}
-
-// SetUsername sets field value
-func (o *GetUserResponse) SetUsername(v GetUserResponseGetUsernameRetType) {
- setGetUserResponseGetUsernameAttributeType(&o.Username, v)
-}
-
-func (o GetUserResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetUserResponseGetDefaultDatabaseAttributeTypeOk(o.DefaultDatabase); ok {
- toSerialize["DefaultDatabase"] = val
- }
- if val, ok := getGetUserResponseGetHostAttributeTypeOk(o.Host); ok {
- toSerialize["Host"] = val
- }
- if val, ok := getGetUserResponseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getGetUserResponseGetPortAttributeTypeOk(o.Port); ok {
- toSerialize["Port"] = val
- }
- if val, ok := getGetUserResponseGetRolesAttributeTypeOk(o.Roles); ok {
- toSerialize["Roles"] = val
- }
- if val, ok := getGetUserResponseGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- if val, ok := getGetUserResponseGetUsernameAttributeTypeOk(o.Username); ok {
- toSerialize["Username"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetUserResponse struct {
- value *GetUserResponse
- isSet bool
-}
-
-func (v NullableGetUserResponse) Get() *GetUserResponse {
- return v.value
-}
-
-func (v *NullableGetUserResponse) Set(val *GetUserResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetUserResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetUserResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetUserResponse(val *GetUserResponse) *NullableGetUserResponse {
- return &NullableGetUserResponse{value: val, isSet: true}
-}
-
-func (v NullableGetUserResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetUserResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_get_user_response_test.go b/pkg/sqlserverflexalpha/model_get_user_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_get_user_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_get_versions_response.go b/pkg/sqlserverflexalpha/model_get_versions_response.go
deleted file mode 100644
index fda6496d..00000000
--- a/pkg/sqlserverflexalpha/model_get_versions_response.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the GetVersionsResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &GetVersionsResponse{}
-
-/*
- types and functions for versions
-*/
-
-// isArray
-type GetVersionsResponseGetVersionsAttributeType = *[]Version
-type GetVersionsResponseGetVersionsArgType = []Version
-type GetVersionsResponseGetVersionsRetType = []Version
-
-func getGetVersionsResponseGetVersionsAttributeTypeOk(arg GetVersionsResponseGetVersionsAttributeType) (ret GetVersionsResponseGetVersionsRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setGetVersionsResponseGetVersionsAttributeType(arg *GetVersionsResponseGetVersionsAttributeType, val GetVersionsResponseGetVersionsRetType) {
- *arg = &val
-}
-
-// GetVersionsResponse struct for GetVersionsResponse
-type GetVersionsResponse struct {
- // A list containing available sqlserver versions.
- // REQUIRED
- Versions GetVersionsResponseGetVersionsAttributeType `json:"versions" required:"true"`
-}
-
-type _GetVersionsResponse GetVersionsResponse
-
-// NewGetVersionsResponse instantiates a new GetVersionsResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewGetVersionsResponse(versions GetVersionsResponseGetVersionsArgType) *GetVersionsResponse {
- this := GetVersionsResponse{}
- setGetVersionsResponseGetVersionsAttributeType(&this.Versions, versions)
- return &this
-}
-
-// NewGetVersionsResponseWithDefaults instantiates a new GetVersionsResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewGetVersionsResponseWithDefaults() *GetVersionsResponse {
- this := GetVersionsResponse{}
- return &this
-}
-
-// GetVersions returns the Versions field value
-func (o *GetVersionsResponse) GetVersions() (ret GetVersionsResponseGetVersionsRetType) {
- ret, _ = o.GetVersionsOk()
- return ret
-}
-
-// GetVersionsOk returns a tuple with the Versions field value
-// and a boolean to check if the value has been set.
-func (o *GetVersionsResponse) GetVersionsOk() (ret GetVersionsResponseGetVersionsRetType, ok bool) {
- return getGetVersionsResponseGetVersionsAttributeTypeOk(o.Versions)
-}
-
-// SetVersions sets field value
-func (o *GetVersionsResponse) SetVersions(v GetVersionsResponseGetVersionsRetType) {
- setGetVersionsResponseGetVersionsAttributeType(&o.Versions, v)
-}
-
-func (o GetVersionsResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getGetVersionsResponseGetVersionsAttributeTypeOk(o.Versions); ok {
- toSerialize["Versions"] = val
- }
- return toSerialize, nil
-}
-
-type NullableGetVersionsResponse struct {
- value *GetVersionsResponse
- isSet bool
-}
-
-func (v NullableGetVersionsResponse) Get() *GetVersionsResponse {
- return v.value
-}
-
-func (v *NullableGetVersionsResponse) Set(val *GetVersionsResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableGetVersionsResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableGetVersionsResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableGetVersionsResponse(val *GetVersionsResponse) *NullableGetVersionsResponse {
- return &NullableGetVersionsResponse{value: val, isSet: true}
-}
-
-func (v NullableGetVersionsResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableGetVersionsResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_get_versions_response_test.go b/pkg/sqlserverflexalpha/model_get_versions_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_get_versions_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_instance_edition.go b/pkg/sqlserverflexalpha/model_instance_edition.go
deleted file mode 100644
index cab08ff0..00000000
--- a/pkg/sqlserverflexalpha/model_instance_edition.go
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// InstanceEdition Edition of the MSSQL server instance
-type InstanceEdition string
-
-// List of instance.edition
-const (
- INSTANCEEDITION_STANDARD InstanceEdition = "Standard"
- INSTANCEEDITION_ENTERPRISE_CORE InstanceEdition = "EnterpriseCore"
- INSTANCEEDITION_DEVELOPER InstanceEdition = "developer"
-)
-
-// All allowed values of InstanceEdition enum
-var AllowedInstanceEditionEnumValues = []InstanceEdition{
- "Standard",
- "EnterpriseCore",
- "developer",
-}
-
-func (v *InstanceEdition) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := InstanceEdition(value)
- for _, existing := range AllowedInstanceEditionEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid InstanceEdition", value)
-}
-
-// NewInstanceEditionFromValue returns a pointer to a valid InstanceEdition
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewInstanceEditionFromValue(v string) (*InstanceEdition, error) {
- ev := InstanceEdition(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for InstanceEdition: valid values are %v", v, AllowedInstanceEditionEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v InstanceEdition) IsValid() bool {
- for _, existing := range AllowedInstanceEditionEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to instance.edition value
-func (v InstanceEdition) Ptr() *InstanceEdition {
- return &v
-}
-
-type NullableInstanceEdition struct {
- value *InstanceEdition
- isSet bool
-}
-
-func (v NullableInstanceEdition) Get() *InstanceEdition {
- return v.value
-}
-
-func (v *NullableInstanceEdition) Set(val *InstanceEdition) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceEdition) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceEdition) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceEdition(val *InstanceEdition) *NullableInstanceEdition {
- return &NullableInstanceEdition{value: val, isSet: true}
-}
-
-func (v NullableInstanceEdition) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceEdition) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_instance_edition_test.go b/pkg/sqlserverflexalpha/model_instance_edition_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_instance_edition_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_instance_encryption.go b/pkg/sqlserverflexalpha/model_instance_encryption.go
deleted file mode 100644
index 9bac54bf..00000000
--- a/pkg/sqlserverflexalpha/model_instance_encryption.go
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the InstanceEncryption type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &InstanceEncryption{}
-
-/*
- types and functions for kekKeyId
-*/
-
-// isNotNullableString
-type InstanceEncryptionGetKekKeyIdAttributeType = *string
-
-func getInstanceEncryptionGetKekKeyIdAttributeTypeOk(arg InstanceEncryptionGetKekKeyIdAttributeType) (ret InstanceEncryptionGetKekKeyIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceEncryptionGetKekKeyIdAttributeType(arg *InstanceEncryptionGetKekKeyIdAttributeType, val InstanceEncryptionGetKekKeyIdRetType) {
- *arg = &val
-}
-
-type InstanceEncryptionGetKekKeyIdArgType = string
-type InstanceEncryptionGetKekKeyIdRetType = string
-
-/*
- types and functions for kekKeyRingId
-*/
-
-// isNotNullableString
-type InstanceEncryptionGetKekKeyRingIdAttributeType = *string
-
-func getInstanceEncryptionGetKekKeyRingIdAttributeTypeOk(arg InstanceEncryptionGetKekKeyRingIdAttributeType) (ret InstanceEncryptionGetKekKeyRingIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceEncryptionGetKekKeyRingIdAttributeType(arg *InstanceEncryptionGetKekKeyRingIdAttributeType, val InstanceEncryptionGetKekKeyRingIdRetType) {
- *arg = &val
-}
-
-type InstanceEncryptionGetKekKeyRingIdArgType = string
-type InstanceEncryptionGetKekKeyRingIdRetType = string
-
-/*
- types and functions for kekKeyVersion
-*/
-
-// isNotNullableString
-type InstanceEncryptionGetKekKeyVersionAttributeType = *string
-
-func getInstanceEncryptionGetKekKeyVersionAttributeTypeOk(arg InstanceEncryptionGetKekKeyVersionAttributeType) (ret InstanceEncryptionGetKekKeyVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceEncryptionGetKekKeyVersionAttributeType(arg *InstanceEncryptionGetKekKeyVersionAttributeType, val InstanceEncryptionGetKekKeyVersionRetType) {
- *arg = &val
-}
-
-type InstanceEncryptionGetKekKeyVersionArgType = string
-type InstanceEncryptionGetKekKeyVersionRetType = string
-
-/*
- types and functions for serviceAccount
-*/
-
-// isNotNullableString
-type InstanceEncryptionGetServiceAccountAttributeType = *string
-
-func getInstanceEncryptionGetServiceAccountAttributeTypeOk(arg InstanceEncryptionGetServiceAccountAttributeType) (ret InstanceEncryptionGetServiceAccountRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceEncryptionGetServiceAccountAttributeType(arg *InstanceEncryptionGetServiceAccountAttributeType, val InstanceEncryptionGetServiceAccountRetType) {
- *arg = &val
-}
-
-type InstanceEncryptionGetServiceAccountArgType = string
-type InstanceEncryptionGetServiceAccountRetType = string
-
-// InstanceEncryption this defines which key to use for storage encryption
-type InstanceEncryption struct {
- // The key identifier
- // REQUIRED
- KekKeyId InstanceEncryptionGetKekKeyIdAttributeType `json:"kekKeyId" required:"true"`
- // The keyring identifier
- // REQUIRED
- KekKeyRingId InstanceEncryptionGetKekKeyRingIdAttributeType `json:"kekKeyRingId" required:"true"`
- // The key version
- // REQUIRED
- KekKeyVersion InstanceEncryptionGetKekKeyVersionAttributeType `json:"kekKeyVersion" required:"true"`
- // REQUIRED
- ServiceAccount InstanceEncryptionGetServiceAccountAttributeType `json:"serviceAccount" required:"true"`
-}
-
-type _InstanceEncryption InstanceEncryption
-
-// NewInstanceEncryption instantiates a new InstanceEncryption object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewInstanceEncryption(kekKeyId InstanceEncryptionGetKekKeyIdArgType, kekKeyRingId InstanceEncryptionGetKekKeyRingIdArgType, kekKeyVersion InstanceEncryptionGetKekKeyVersionArgType, serviceAccount InstanceEncryptionGetServiceAccountArgType) *InstanceEncryption {
- this := InstanceEncryption{}
- setInstanceEncryptionGetKekKeyIdAttributeType(&this.KekKeyId, kekKeyId)
- setInstanceEncryptionGetKekKeyRingIdAttributeType(&this.KekKeyRingId, kekKeyRingId)
- setInstanceEncryptionGetKekKeyVersionAttributeType(&this.KekKeyVersion, kekKeyVersion)
- setInstanceEncryptionGetServiceAccountAttributeType(&this.ServiceAccount, serviceAccount)
- return &this
-}
-
-// NewInstanceEncryptionWithDefaults instantiates a new InstanceEncryption object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewInstanceEncryptionWithDefaults() *InstanceEncryption {
- this := InstanceEncryption{}
- return &this
-}
-
-// GetKekKeyId returns the KekKeyId field value
-func (o *InstanceEncryption) GetKekKeyId() (ret InstanceEncryptionGetKekKeyIdRetType) {
- ret, _ = o.GetKekKeyIdOk()
- return ret
-}
-
-// GetKekKeyIdOk returns a tuple with the KekKeyId field value
-// and a boolean to check if the value has been set.
-func (o *InstanceEncryption) GetKekKeyIdOk() (ret InstanceEncryptionGetKekKeyIdRetType, ok bool) {
- return getInstanceEncryptionGetKekKeyIdAttributeTypeOk(o.KekKeyId)
-}
-
-// SetKekKeyId sets field value
-func (o *InstanceEncryption) SetKekKeyId(v InstanceEncryptionGetKekKeyIdRetType) {
- setInstanceEncryptionGetKekKeyIdAttributeType(&o.KekKeyId, v)
-}
-
-// GetKekKeyRingId returns the KekKeyRingId field value
-func (o *InstanceEncryption) GetKekKeyRingId() (ret InstanceEncryptionGetKekKeyRingIdRetType) {
- ret, _ = o.GetKekKeyRingIdOk()
- return ret
-}
-
-// GetKekKeyRingIdOk returns a tuple with the KekKeyRingId field value
-// and a boolean to check if the value has been set.
-func (o *InstanceEncryption) GetKekKeyRingIdOk() (ret InstanceEncryptionGetKekKeyRingIdRetType, ok bool) {
- return getInstanceEncryptionGetKekKeyRingIdAttributeTypeOk(o.KekKeyRingId)
-}
-
-// SetKekKeyRingId sets field value
-func (o *InstanceEncryption) SetKekKeyRingId(v InstanceEncryptionGetKekKeyRingIdRetType) {
- setInstanceEncryptionGetKekKeyRingIdAttributeType(&o.KekKeyRingId, v)
-}
-
-// GetKekKeyVersion returns the KekKeyVersion field value
-func (o *InstanceEncryption) GetKekKeyVersion() (ret InstanceEncryptionGetKekKeyVersionRetType) {
- ret, _ = o.GetKekKeyVersionOk()
- return ret
-}
-
-// GetKekKeyVersionOk returns a tuple with the KekKeyVersion field value
-// and a boolean to check if the value has been set.
-func (o *InstanceEncryption) GetKekKeyVersionOk() (ret InstanceEncryptionGetKekKeyVersionRetType, ok bool) {
- return getInstanceEncryptionGetKekKeyVersionAttributeTypeOk(o.KekKeyVersion)
-}
-
-// SetKekKeyVersion sets field value
-func (o *InstanceEncryption) SetKekKeyVersion(v InstanceEncryptionGetKekKeyVersionRetType) {
- setInstanceEncryptionGetKekKeyVersionAttributeType(&o.KekKeyVersion, v)
-}
-
-// GetServiceAccount returns the ServiceAccount field value
-func (o *InstanceEncryption) GetServiceAccount() (ret InstanceEncryptionGetServiceAccountRetType) {
- ret, _ = o.GetServiceAccountOk()
- return ret
-}
-
-// GetServiceAccountOk returns a tuple with the ServiceAccount field value
-// and a boolean to check if the value has been set.
-func (o *InstanceEncryption) GetServiceAccountOk() (ret InstanceEncryptionGetServiceAccountRetType, ok bool) {
- return getInstanceEncryptionGetServiceAccountAttributeTypeOk(o.ServiceAccount)
-}
-
-// SetServiceAccount sets field value
-func (o *InstanceEncryption) SetServiceAccount(v InstanceEncryptionGetServiceAccountRetType) {
- setInstanceEncryptionGetServiceAccountAttributeType(&o.ServiceAccount, v)
-}
-
-func (o InstanceEncryption) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getInstanceEncryptionGetKekKeyIdAttributeTypeOk(o.KekKeyId); ok {
- toSerialize["KekKeyId"] = val
- }
- if val, ok := getInstanceEncryptionGetKekKeyRingIdAttributeTypeOk(o.KekKeyRingId); ok {
- toSerialize["KekKeyRingId"] = val
- }
- if val, ok := getInstanceEncryptionGetKekKeyVersionAttributeTypeOk(o.KekKeyVersion); ok {
- toSerialize["KekKeyVersion"] = val
- }
- if val, ok := getInstanceEncryptionGetServiceAccountAttributeTypeOk(o.ServiceAccount); ok {
- toSerialize["ServiceAccount"] = val
- }
- return toSerialize, nil
-}
-
-type NullableInstanceEncryption struct {
- value *InstanceEncryption
- isSet bool
-}
-
-func (v NullableInstanceEncryption) Get() *InstanceEncryption {
- return v.value
-}
-
-func (v *NullableInstanceEncryption) Set(val *InstanceEncryption) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceEncryption) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceEncryption) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceEncryption(val *InstanceEncryption) *NullableInstanceEncryption {
- return &NullableInstanceEncryption{value: val, isSet: true}
-}
-
-func (v NullableInstanceEncryption) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceEncryption) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_instance_encryption_test.go b/pkg/sqlserverflexalpha/model_instance_encryption_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_instance_encryption_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_instance_network.go b/pkg/sqlserverflexalpha/model_instance_network.go
deleted file mode 100644
index 8abfd38c..00000000
--- a/pkg/sqlserverflexalpha/model_instance_network.go
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the InstanceNetwork type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &InstanceNetwork{}
-
-/*
- types and functions for accessScope
-*/
-
-// isEnumRef
-type InstanceNetworkGetAccessScopeAttributeType = *InstanceNetworkAccessScope
-type InstanceNetworkGetAccessScopeArgType = InstanceNetworkAccessScope
-type InstanceNetworkGetAccessScopeRetType = InstanceNetworkAccessScope
-
-func getInstanceNetworkGetAccessScopeAttributeTypeOk(arg InstanceNetworkGetAccessScopeAttributeType) (ret InstanceNetworkGetAccessScopeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceNetworkGetAccessScopeAttributeType(arg *InstanceNetworkGetAccessScopeAttributeType, val InstanceNetworkGetAccessScopeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for acl
-*/
-
-// isArray
-type InstanceNetworkGetAclAttributeType = *[]string
-type InstanceNetworkGetAclArgType = []string
-type InstanceNetworkGetAclRetType = []string
-
-func getInstanceNetworkGetAclAttributeTypeOk(arg InstanceNetworkGetAclAttributeType) (ret InstanceNetworkGetAclRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceNetworkGetAclAttributeType(arg *InstanceNetworkGetAclAttributeType, val InstanceNetworkGetAclRetType) {
- *arg = &val
-}
-
-/*
- types and functions for instanceAddress
-*/
-
-// isNotNullableString
-type InstanceNetworkGetInstanceAddressAttributeType = *string
-
-func getInstanceNetworkGetInstanceAddressAttributeTypeOk(arg InstanceNetworkGetInstanceAddressAttributeType) (ret InstanceNetworkGetInstanceAddressRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceNetworkGetInstanceAddressAttributeType(arg *InstanceNetworkGetInstanceAddressAttributeType, val InstanceNetworkGetInstanceAddressRetType) {
- *arg = &val
-}
-
-type InstanceNetworkGetInstanceAddressArgType = string
-type InstanceNetworkGetInstanceAddressRetType = string
-
-/*
- types and functions for routerAddress
-*/
-
-// isNotNullableString
-type InstanceNetworkGetRouterAddressAttributeType = *string
-
-func getInstanceNetworkGetRouterAddressAttributeTypeOk(arg InstanceNetworkGetRouterAddressAttributeType) (ret InstanceNetworkGetRouterAddressRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setInstanceNetworkGetRouterAddressAttributeType(arg *InstanceNetworkGetRouterAddressAttributeType, val InstanceNetworkGetRouterAddressRetType) {
- *arg = &val
-}
-
-type InstanceNetworkGetRouterAddressArgType = string
-type InstanceNetworkGetRouterAddressRetType = string
-
-// InstanceNetwork The access configuration of the instance
-type InstanceNetwork struct {
- AccessScope InstanceNetworkGetAccessScopeAttributeType `json:"accessScope,omitempty"`
- // List of IPV4 cidr.
- Acl InstanceNetworkGetAclAttributeType `json:"acl,omitempty"`
- InstanceAddress InstanceNetworkGetInstanceAddressAttributeType `json:"instanceAddress,omitempty"`
- RouterAddress InstanceNetworkGetRouterAddressAttributeType `json:"routerAddress,omitempty"`
-}
-
-// NewInstanceNetwork instantiates a new InstanceNetwork object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewInstanceNetwork() *InstanceNetwork {
- this := InstanceNetwork{}
- return &this
-}
-
-// NewInstanceNetworkWithDefaults instantiates a new InstanceNetwork object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewInstanceNetworkWithDefaults() *InstanceNetwork {
- this := InstanceNetwork{}
- var accessScope InstanceNetworkAccessScope = INSTANCENETWORKACCESSSCOPE_PUBLIC
- this.AccessScope = &accessScope
- return &this
-}
-
-// GetAccessScope returns the AccessScope field value if set, zero value otherwise.
-func (o *InstanceNetwork) GetAccessScope() (res InstanceNetworkGetAccessScopeRetType) {
- res, _ = o.GetAccessScopeOk()
- return
-}
-
-// GetAccessScopeOk returns a tuple with the AccessScope field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *InstanceNetwork) GetAccessScopeOk() (ret InstanceNetworkGetAccessScopeRetType, ok bool) {
- return getInstanceNetworkGetAccessScopeAttributeTypeOk(o.AccessScope)
-}
-
-// HasAccessScope returns a boolean if a field has been set.
-func (o *InstanceNetwork) HasAccessScope() bool {
- _, ok := o.GetAccessScopeOk()
- return ok
-}
-
-// SetAccessScope gets a reference to the given InstanceNetworkAccessScope and assigns it to the AccessScope field.
-func (o *InstanceNetwork) SetAccessScope(v InstanceNetworkGetAccessScopeRetType) {
- setInstanceNetworkGetAccessScopeAttributeType(&o.AccessScope, v)
-}
-
-// GetAcl returns the Acl field value if set, zero value otherwise.
-func (o *InstanceNetwork) GetAcl() (res InstanceNetworkGetAclRetType) {
- res, _ = o.GetAclOk()
- return
-}
-
-// GetAclOk returns a tuple with the Acl field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *InstanceNetwork) GetAclOk() (ret InstanceNetworkGetAclRetType, ok bool) {
- return getInstanceNetworkGetAclAttributeTypeOk(o.Acl)
-}
-
-// HasAcl returns a boolean if a field has been set.
-func (o *InstanceNetwork) HasAcl() bool {
- _, ok := o.GetAclOk()
- return ok
-}
-
-// SetAcl gets a reference to the given []string and assigns it to the Acl field.
-func (o *InstanceNetwork) SetAcl(v InstanceNetworkGetAclRetType) {
- setInstanceNetworkGetAclAttributeType(&o.Acl, v)
-}
-
-// GetInstanceAddress returns the InstanceAddress field value if set, zero value otherwise.
-func (o *InstanceNetwork) GetInstanceAddress() (res InstanceNetworkGetInstanceAddressRetType) {
- res, _ = o.GetInstanceAddressOk()
- return
-}
-
-// GetInstanceAddressOk returns a tuple with the InstanceAddress field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *InstanceNetwork) GetInstanceAddressOk() (ret InstanceNetworkGetInstanceAddressRetType, ok bool) {
- return getInstanceNetworkGetInstanceAddressAttributeTypeOk(o.InstanceAddress)
-}
-
-// HasInstanceAddress returns a boolean if a field has been set.
-func (o *InstanceNetwork) HasInstanceAddress() bool {
- _, ok := o.GetInstanceAddressOk()
- return ok
-}
-
-// SetInstanceAddress gets a reference to the given string and assigns it to the InstanceAddress field.
-func (o *InstanceNetwork) SetInstanceAddress(v InstanceNetworkGetInstanceAddressRetType) {
- setInstanceNetworkGetInstanceAddressAttributeType(&o.InstanceAddress, v)
-}
-
-// GetRouterAddress returns the RouterAddress field value if set, zero value otherwise.
-func (o *InstanceNetwork) GetRouterAddress() (res InstanceNetworkGetRouterAddressRetType) {
- res, _ = o.GetRouterAddressOk()
- return
-}
-
-// GetRouterAddressOk returns a tuple with the RouterAddress field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *InstanceNetwork) GetRouterAddressOk() (ret InstanceNetworkGetRouterAddressRetType, ok bool) {
- return getInstanceNetworkGetRouterAddressAttributeTypeOk(o.RouterAddress)
-}
-
-// HasRouterAddress returns a boolean if a field has been set.
-func (o *InstanceNetwork) HasRouterAddress() bool {
- _, ok := o.GetRouterAddressOk()
- return ok
-}
-
-// SetRouterAddress gets a reference to the given string and assigns it to the RouterAddress field.
-func (o *InstanceNetwork) SetRouterAddress(v InstanceNetworkGetRouterAddressRetType) {
- setInstanceNetworkGetRouterAddressAttributeType(&o.RouterAddress, v)
-}
-
-func (o InstanceNetwork) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getInstanceNetworkGetAccessScopeAttributeTypeOk(o.AccessScope); ok {
- toSerialize["AccessScope"] = val
- }
- if val, ok := getInstanceNetworkGetAclAttributeTypeOk(o.Acl); ok {
- toSerialize["Acl"] = val
- }
- if val, ok := getInstanceNetworkGetInstanceAddressAttributeTypeOk(o.InstanceAddress); ok {
- toSerialize["InstanceAddress"] = val
- }
- if val, ok := getInstanceNetworkGetRouterAddressAttributeTypeOk(o.RouterAddress); ok {
- toSerialize["RouterAddress"] = val
- }
- return toSerialize, nil
-}
-
-type NullableInstanceNetwork struct {
- value *InstanceNetwork
- isSet bool
-}
-
-func (v NullableInstanceNetwork) Get() *InstanceNetwork {
- return v.value
-}
-
-func (v *NullableInstanceNetwork) Set(val *InstanceNetwork) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceNetwork) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceNetwork) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceNetwork(val *InstanceNetwork) *NullableInstanceNetwork {
- return &NullableInstanceNetwork{value: val, isSet: true}
-}
-
-func (v NullableInstanceNetwork) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceNetwork) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_instance_network_access_scope.go b/pkg/sqlserverflexalpha/model_instance_network_access_scope.go
deleted file mode 100644
index c8357883..00000000
--- a/pkg/sqlserverflexalpha/model_instance_network_access_scope.go
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// InstanceNetworkAccessScope The network access scope of the instance ⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.
-type InstanceNetworkAccessScope string
-
-// List of instance.network.accessScope
-const (
- INSTANCENETWORKACCESSSCOPE_PUBLIC InstanceNetworkAccessScope = "PUBLIC"
- INSTANCENETWORKACCESSSCOPE_SNA InstanceNetworkAccessScope = "SNA"
-)
-
-// All allowed values of InstanceNetworkAccessScope enum
-var AllowedInstanceNetworkAccessScopeEnumValues = []InstanceNetworkAccessScope{
- "PUBLIC",
- "SNA",
-}
-
-func (v *InstanceNetworkAccessScope) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := InstanceNetworkAccessScope(value)
- for _, existing := range AllowedInstanceNetworkAccessScopeEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid InstanceNetworkAccessScope", value)
-}
-
-// NewInstanceNetworkAccessScopeFromValue returns a pointer to a valid InstanceNetworkAccessScope
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewInstanceNetworkAccessScopeFromValue(v string) (*InstanceNetworkAccessScope, error) {
- ev := InstanceNetworkAccessScope(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for InstanceNetworkAccessScope: valid values are %v", v, AllowedInstanceNetworkAccessScopeEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v InstanceNetworkAccessScope) IsValid() bool {
- for _, existing := range AllowedInstanceNetworkAccessScopeEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to instance.network.accessScope value
-func (v InstanceNetworkAccessScope) Ptr() *InstanceNetworkAccessScope {
- return &v
-}
-
-type NullableInstanceNetworkAccessScope struct {
- value *InstanceNetworkAccessScope
- isSet bool
-}
-
-func (v NullableInstanceNetworkAccessScope) Get() *InstanceNetworkAccessScope {
- return v.value
-}
-
-func (v *NullableInstanceNetworkAccessScope) Set(val *InstanceNetworkAccessScope) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceNetworkAccessScope) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceNetworkAccessScope) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceNetworkAccessScope(val *InstanceNetworkAccessScope) *NullableInstanceNetworkAccessScope {
- return &NullableInstanceNetworkAccessScope{value: val, isSet: true}
-}
-
-func (v NullableInstanceNetworkAccessScope) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceNetworkAccessScope) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_instance_network_access_scope_test.go b/pkg/sqlserverflexalpha/model_instance_network_access_scope_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_instance_network_access_scope_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_instance_network_test.go b/pkg/sqlserverflexalpha/model_instance_network_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_instance_network_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_instance_sort.go b/pkg/sqlserverflexalpha/model_instance_sort.go
deleted file mode 100644
index 74dde23d..00000000
--- a/pkg/sqlserverflexalpha/model_instance_sort.go
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// InstanceSort the model 'InstanceSort'
-type InstanceSort string
-
-// List of instance.sort
-const (
- INSTANCESORT_INDEX_DESC InstanceSort = "index.desc"
- INSTANCESORT_INDEX_ASC InstanceSort = "index.asc"
- INSTANCESORT_ID_DESC InstanceSort = "id.desc"
- INSTANCESORT_ID_ASC InstanceSort = "id.asc"
- INSTANCESORT_IS_DELETABLE_DESC InstanceSort = "is_deletable.desc"
- INSTANCESORT_IS_DELETABLE_ASC InstanceSort = "is_deletable.asc"
- INSTANCESORT_NAME_ASC InstanceSort = "name.asc"
- INSTANCESORT_NAME_DESC InstanceSort = "name.desc"
- INSTANCESORT_STATUS_ASC InstanceSort = "status.asc"
- INSTANCESORT_STATUS_DESC InstanceSort = "status.desc"
-)
-
-// All allowed values of InstanceSort enum
-var AllowedInstanceSortEnumValues = []InstanceSort{
- "index.desc",
- "index.asc",
- "id.desc",
- "id.asc",
- "is_deletable.desc",
- "is_deletable.asc",
- "name.asc",
- "name.desc",
- "status.asc",
- "status.desc",
-}
-
-func (v *InstanceSort) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := InstanceSort(value)
- for _, existing := range AllowedInstanceSortEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid InstanceSort", value)
-}
-
-// NewInstanceSortFromValue returns a pointer to a valid InstanceSort
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewInstanceSortFromValue(v string) (*InstanceSort, error) {
- ev := InstanceSort(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for InstanceSort: valid values are %v", v, AllowedInstanceSortEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v InstanceSort) IsValid() bool {
- for _, existing := range AllowedInstanceSortEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to instance.sort value
-func (v InstanceSort) Ptr() *InstanceSort {
- return &v
-}
-
-type NullableInstanceSort struct {
- value *InstanceSort
- isSet bool
-}
-
-func (v NullableInstanceSort) Get() *InstanceSort {
- return v.value
-}
-
-func (v *NullableInstanceSort) Set(val *InstanceSort) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceSort) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceSort) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceSort(val *InstanceSort) *NullableInstanceSort {
- return &NullableInstanceSort{value: val, isSet: true}
-}
-
-func (v NullableInstanceSort) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceSort) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_instance_sort_test.go b/pkg/sqlserverflexalpha/model_instance_sort_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_instance_sort_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_instance_version.go b/pkg/sqlserverflexalpha/model_instance_version.go
deleted file mode 100644
index 82276c45..00000000
--- a/pkg/sqlserverflexalpha/model_instance_version.go
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// InstanceVersion The sqlserver version used for the instance.
-type InstanceVersion string
-
-// List of instance.version
-const (
- INSTANCEVERSION__2022 InstanceVersion = "2022"
-)
-
-// All allowed values of InstanceVersion enum
-var AllowedInstanceVersionEnumValues = []InstanceVersion{
- "2022",
-}
-
-func (v *InstanceVersion) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := InstanceVersion(value)
- for _, existing := range AllowedInstanceVersionEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid InstanceVersion", value)
-}
-
-// NewInstanceVersionFromValue returns a pointer to a valid InstanceVersion
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewInstanceVersionFromValue(v string) (*InstanceVersion, error) {
- ev := InstanceVersion(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for InstanceVersion: valid values are %v", v, AllowedInstanceVersionEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v InstanceVersion) IsValid() bool {
- for _, existing := range AllowedInstanceVersionEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to instance.version value
-func (v InstanceVersion) Ptr() *InstanceVersion {
- return &v
-}
-
-type NullableInstanceVersion struct {
- value *InstanceVersion
- isSet bool
-}
-
-func (v NullableInstanceVersion) Get() *InstanceVersion {
- return v.value
-}
-
-func (v *NullableInstanceVersion) Set(val *InstanceVersion) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceVersion) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceVersion) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceVersion(val *InstanceVersion) *NullableInstanceVersion {
- return &NullableInstanceVersion{value: val, isSet: true}
-}
-
-func (v NullableInstanceVersion) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceVersion) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_instance_version_opt.go b/pkg/sqlserverflexalpha/model_instance_version_opt.go
deleted file mode 100644
index 13c1efc9..00000000
--- a/pkg/sqlserverflexalpha/model_instance_version_opt.go
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// InstanceVersionOpt the model 'InstanceVersionOpt'
-type InstanceVersionOpt string
-
-// List of instance.version.opt
-const (
- INSTANCEVERSIONOPT__2022 InstanceVersionOpt = "2022"
-)
-
-// All allowed values of InstanceVersionOpt enum
-var AllowedInstanceVersionOptEnumValues = []InstanceVersionOpt{
- "2022",
-}
-
-func (v *InstanceVersionOpt) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := InstanceVersionOpt(value)
- for _, existing := range AllowedInstanceVersionOptEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid InstanceVersionOpt", value)
-}
-
-// NewInstanceVersionOptFromValue returns a pointer to a valid InstanceVersionOpt
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewInstanceVersionOptFromValue(v string) (*InstanceVersionOpt, error) {
- ev := InstanceVersionOpt(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for InstanceVersionOpt: valid values are %v", v, AllowedInstanceVersionOptEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v InstanceVersionOpt) IsValid() bool {
- for _, existing := range AllowedInstanceVersionOptEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to instance.version.opt value
-func (v InstanceVersionOpt) Ptr() *InstanceVersionOpt {
- return &v
-}
-
-type NullableInstanceVersionOpt struct {
- value *InstanceVersionOpt
- isSet bool
-}
-
-func (v NullableInstanceVersionOpt) Get() *InstanceVersionOpt {
- return v.value
-}
-
-func (v *NullableInstanceVersionOpt) Set(val *InstanceVersionOpt) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInstanceVersionOpt) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInstanceVersionOpt) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInstanceVersionOpt(val *InstanceVersionOpt) *NullableInstanceVersionOpt {
- return &NullableInstanceVersionOpt{value: val, isSet: true}
-}
-
-func (v NullableInstanceVersionOpt) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInstanceVersionOpt) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_instance_version_opt_test.go b/pkg/sqlserverflexalpha/model_instance_version_opt_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_instance_version_opt_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_instance_version_test.go b/pkg/sqlserverflexalpha/model_instance_version_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_instance_version_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_backup.go b/pkg/sqlserverflexalpha/model_list_backup.go
deleted file mode 100644
index 70140b92..00000000
--- a/pkg/sqlserverflexalpha/model_list_backup.go
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListBackup type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListBackup{}
-
-/*
- types and functions for completionTime
-*/
-
-//// isAny
-//type ListBackupGetCompletionTimeAttributeType = any
-//type ListBackupGetCompletionTimeArgType = any
-//type ListBackupGetCompletionTimeRetType = any
-//
-//func getListBackupGetCompletionTimeAttributeTypeOk(arg ListBackupGetCompletionTimeAttributeType) (ret ListBackupGetCompletionTimeRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setListBackupGetCompletionTimeAttributeType(arg *ListBackupGetCompletionTimeAttributeType, val ListBackupGetCompletionTimeRetType) {
-// *arg = &val
-//}
-
-// isModel
-type ListBackupGetCompletionTimeAttributeType = *string
-type ListBackupGetCompletionTimeArgType = string
-type ListBackupGetCompletionTimeRetType = string
-
-func getListBackupGetCompletionTimeAttributeTypeOk(arg ListBackupGetCompletionTimeAttributeType) (ret ListBackupGetCompletionTimeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetCompletionTimeAttributeType(arg *ListBackupGetCompletionTimeAttributeType, val ListBackupGetCompletionTimeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for id
-*/
-
-// isAny
-//type ListBackupGetIdAttributeType = any
-//type ListBackupGetIdArgType = any
-//type ListBackupGetIdRetType = any
-//
-//func getListBackupGetIdAttributeTypeOk(arg ListBackupGetIdAttributeType) (ret ListBackupGetIdRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setListBackupGetIdAttributeType(arg *ListBackupGetIdAttributeType, val ListBackupGetIdRetType) {
-// *arg = &val
-//}
-
-// isModel
-type ListBackupGetIdAttributeType = *int64
-type ListBackupGetIdArgType = int64
-type ListBackupGetIdRetType = int64
-
-func getListBackupGetIdAttributeTypeOk(arg ListBackupGetIdAttributeType) (ret ListBackupGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetIdAttributeType(arg *ListBackupGetIdAttributeType, val ListBackupGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-//// isAny
-//type ListBackupGetNameAttributeType = any
-//type ListBackupGetNameArgType = any
-//type ListBackupGetNameRetType = any
-//
-//func getListBackupGetNameAttributeTypeOk(arg ListBackupGetNameAttributeType) (ret ListBackupGetNameRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setListBackupGetNameAttributeType(arg *ListBackupGetNameAttributeType, val ListBackupGetNameRetType) {
-// *arg = &val
-//}
-
-// isModel
-type ListBackupGetNameAttributeType = *string
-type ListBackupGetNameArgType = string
-type ListBackupGetNameRetType = string
-
-func getListBackupGetNameAttributeTypeOk(arg ListBackupGetNameAttributeType) (ret ListBackupGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetNameAttributeType(arg *ListBackupGetNameAttributeType, val ListBackupGetNameRetType) {
- *arg = &val
-}
-
-/*
- types and functions for retainedUntil
-*/
-
-//// isAny
-//type ListBackupGetRetainedUntilAttributeType = any
-//type ListBackupGetRetainedUntilArgType = any
-//type ListBackupGetRetainedUntilRetType = any
-//
-//func getListBackupGetRetainedUntilAttributeTypeOk(arg ListBackupGetRetainedUntilAttributeType) (ret ListBackupGetRetainedUntilRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setListBackupGetRetainedUntilAttributeType(arg *ListBackupGetRetainedUntilAttributeType, val ListBackupGetRetainedUntilRetType) {
-// *arg = &val
-//}
-
-// isModel
-type ListBackupGetRetainedUntilAttributeType = *string
-type ListBackupGetRetainedUntilArgType = string
-type ListBackupGetRetainedUntilRetType = string
-
-func getListBackupGetRetainedUntilAttributeTypeOk(arg ListBackupGetRetainedUntilAttributeType) (ret ListBackupGetRetainedUntilRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetRetainedUntilAttributeType(arg *ListBackupGetRetainedUntilAttributeType, val ListBackupGetRetainedUntilRetType) {
- *arg = &val
-}
-
-/*
- types and functions for size
-*/
-
-//// isAny
-//type ListBackupGetSizeAttributeType = any
-//type ListBackupGetSizeArgType = any
-//type ListBackupGetSizeRetType = any
-//
-//func getListBackupGetSizeAttributeTypeOk(arg ListBackupGetSizeAttributeType) (ret ListBackupGetSizeRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setListBackupGetSizeAttributeType(arg *ListBackupGetSizeAttributeType, val ListBackupGetSizeRetType) {
-// *arg = &val
-//}
-
-// isModel
-type ListBackupGetSizeAttributeType = *int64
-type ListBackupGetSizeArgType = int64
-type ListBackupGetSizeRetType = int64
-
-func getListBackupGetSizeAttributeTypeOk(arg ListBackupGetSizeAttributeType) (ret ListBackupGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetSizeAttributeType(arg *ListBackupGetSizeAttributeType, val ListBackupGetSizeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for type
-*/
-
-//// isAny
-//type ListBackupGetTypeAttributeType = any
-//type ListBackupGetTypeArgType = any
-//type ListBackupGetTypeRetType = any
-//
-//func getListBackupGetTypeAttributeTypeOk(arg ListBackupGetTypeAttributeType) (ret ListBackupGetTypeRetType, ok bool) {
-// if arg == nil {
-// return ret, false
-// }
-// return *arg, true
-//}
-//
-//func setListBackupGetTypeAttributeType(arg *ListBackupGetTypeAttributeType, val ListBackupGetTypeRetType) {
-// *arg = &val
-//}
-
-// isModel
-type ListBackupGetTypeAttributeType = *string
-type ListBackupGetTypeArgType = string
-type ListBackupGetTypeRetType = string
-
-func getListBackupGetTypeAttributeTypeOk(arg ListBackupGetTypeAttributeType) (ret ListBackupGetTypeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupGetTypeAttributeType(arg *ListBackupGetTypeAttributeType, val ListBackupGetTypeRetType) {
- *arg = &val
-}
-
-// ListBackup struct for ListBackup
-type ListBackup struct {
- // REQUIRED
- CompletionTime ListBackupGetCompletionTimeAttributeType `json:"completionTime" required:"true"`
- // REQUIRED
- Id ListBackupGetIdAttributeType `json:"id" required:"true"`
- // REQUIRED
- Name ListBackupGetNameAttributeType `json:"name" required:"true"`
- // REQUIRED
- RetainedUntil ListBackupGetRetainedUntilAttributeType `json:"retainedUntil" required:"true"`
- // REQUIRED
- Size ListBackupGetSizeAttributeType `json:"size" required:"true"`
- // REQUIRED
- Type ListBackupGetTypeAttributeType `json:"type" required:"true"`
-}
-
-type _ListBackup ListBackup
-
-// NewListBackup instantiates a new ListBackup object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListBackup(completionTime ListBackupGetCompletionTimeArgType, id ListBackupGetIdArgType, name ListBackupGetNameArgType, retainedUntil ListBackupGetRetainedUntilArgType, size ListBackupGetSizeArgType, types ListBackupGetTypeArgType) *ListBackup {
- this := ListBackup{}
- setListBackupGetCompletionTimeAttributeType(&this.CompletionTime, completionTime)
- setListBackupGetIdAttributeType(&this.Id, id)
- setListBackupGetNameAttributeType(&this.Name, name)
- setListBackupGetRetainedUntilAttributeType(&this.RetainedUntil, retainedUntil)
- setListBackupGetSizeAttributeType(&this.Size, size)
- setListBackupGetTypeAttributeType(&this.Type, types)
- return &this
-}
-
-// NewListBackupWithDefaults instantiates a new ListBackup object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListBackupWithDefaults() *ListBackup {
- this := ListBackup{}
- return &this
-}
-
-// GetCompletionTime returns the CompletionTime field value
-func (o *ListBackup) GetCompletionTime() (ret ListBackupGetCompletionTimeRetType) {
- ret, _ = o.GetCompletionTimeOk()
- return ret
-}
-
-// GetCompletionTimeOk returns a tuple with the CompletionTime field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetCompletionTimeOk() (ret ListBackupGetCompletionTimeRetType, ok bool) {
- return getListBackupGetCompletionTimeAttributeTypeOk(o.CompletionTime)
-}
-
-// SetCompletionTime sets field value
-func (o *ListBackup) SetCompletionTime(v ListBackupGetCompletionTimeRetType) {
- setListBackupGetCompletionTimeAttributeType(&o.CompletionTime, v)
-}
-
-// GetId returns the Id field value
-func (o *ListBackup) GetId() (ret ListBackupGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetIdOk() (ret ListBackupGetIdRetType, ok bool) {
- return getListBackupGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *ListBackup) SetId(v ListBackupGetIdRetType) {
- setListBackupGetIdAttributeType(&o.Id, v)
-}
-
-// GetName returns the Name field value
-func (o *ListBackup) GetName() (ret ListBackupGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetNameOk() (ret ListBackupGetNameRetType, ok bool) {
- return getListBackupGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *ListBackup) SetName(v ListBackupGetNameRetType) {
- setListBackupGetNameAttributeType(&o.Name, v)
-}
-
-// GetRetainedUntil returns the RetainedUntil field value
-func (o *ListBackup) GetRetainedUntil() (ret ListBackupGetRetainedUntilRetType) {
- ret, _ = o.GetRetainedUntilOk()
- return ret
-}
-
-// GetRetainedUntilOk returns a tuple with the RetainedUntil field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetRetainedUntilOk() (ret ListBackupGetRetainedUntilRetType, ok bool) {
- return getListBackupGetRetainedUntilAttributeTypeOk(o.RetainedUntil)
-}
-
-// SetRetainedUntil sets field value
-func (o *ListBackup) SetRetainedUntil(v ListBackupGetRetainedUntilRetType) {
- setListBackupGetRetainedUntilAttributeType(&o.RetainedUntil, v)
-}
-
-// GetSize returns the Size field value
-func (o *ListBackup) GetSize() (ret ListBackupGetSizeRetType) {
- ret, _ = o.GetSizeOk()
- return ret
-}
-
-// GetSizeOk returns a tuple with the Size field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetSizeOk() (ret ListBackupGetSizeRetType, ok bool) {
- return getListBackupGetSizeAttributeTypeOk(o.Size)
-}
-
-// SetSize sets field value
-func (o *ListBackup) SetSize(v ListBackupGetSizeRetType) {
- setListBackupGetSizeAttributeType(&o.Size, v)
-}
-
-// GetType returns the Type field value
-func (o *ListBackup) GetType() (ret ListBackupGetTypeRetType) {
- ret, _ = o.GetTypeOk()
- return ret
-}
-
-// GetTypeOk returns a tuple with the Type field value
-// and a boolean to check if the value has been set.
-func (o *ListBackup) GetTypeOk() (ret ListBackupGetTypeRetType, ok bool) {
- return getListBackupGetTypeAttributeTypeOk(o.Type)
-}
-
-// SetType sets field value
-func (o *ListBackup) SetType(v ListBackupGetTypeRetType) {
- setListBackupGetTypeAttributeType(&o.Type, v)
-}
-
-func (o ListBackup) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListBackupGetCompletionTimeAttributeTypeOk(o.CompletionTime); ok {
- toSerialize["CompletionTime"] = val
- }
- if val, ok := getListBackupGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getListBackupGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getListBackupGetRetainedUntilAttributeTypeOk(o.RetainedUntil); ok {
- toSerialize["RetainedUntil"] = val
- }
- if val, ok := getListBackupGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- if val, ok := getListBackupGetTypeAttributeTypeOk(o.Type); ok {
- toSerialize["Type"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListBackup struct {
- value *ListBackup
- isSet bool
-}
-
-func (v NullableListBackup) Get() *ListBackup {
- return v.value
-}
-
-func (v *NullableListBackup) Set(val *ListBackup) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListBackup) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListBackup) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListBackup(val *ListBackup) *NullableListBackup {
- return &NullableListBackup{value: val, isSet: true}
-}
-
-func (v NullableListBackup) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListBackup) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_backup_response.go b/pkg/sqlserverflexalpha/model_list_backup_response.go
deleted file mode 100644
index 71be5729..00000000
--- a/pkg/sqlserverflexalpha/model_list_backup_response.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListBackupResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListBackupResponse{}
-
-/*
- types and functions for backups
-*/
-
-// isArray
-type ListBackupResponseGetBackupsAttributeType = *[]ListBackupsResponse
-type ListBackupResponseGetBackupsArgType = []ListBackupsResponse
-type ListBackupResponseGetBackupsRetType = []ListBackupsResponse
-
-func getListBackupResponseGetBackupsAttributeTypeOk(arg ListBackupResponseGetBackupsAttributeType) (ret ListBackupResponseGetBackupsRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupResponseGetBackupsAttributeType(arg *ListBackupResponseGetBackupsAttributeType, val ListBackupResponseGetBackupsRetType) {
- *arg = &val
-}
-
-/*
- types and functions for pagination
-*/
-
-// isModel
-type ListBackupResponseGetPaginationAttributeType = *Pagination
-type ListBackupResponseGetPaginationArgType = Pagination
-type ListBackupResponseGetPaginationRetType = Pagination
-
-func getListBackupResponseGetPaginationAttributeTypeOk(arg ListBackupResponseGetPaginationAttributeType) (ret ListBackupResponseGetPaginationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupResponseGetPaginationAttributeType(arg *ListBackupResponseGetPaginationAttributeType, val ListBackupResponseGetPaginationRetType) {
- *arg = &val
-}
-
-// ListBackupResponse struct for ListBackupResponse
-type ListBackupResponse struct {
- // The list containing the information about the backups.
- // REQUIRED
- Backups ListBackupResponseGetBackupsAttributeType `json:"backups" required:"true"`
- // REQUIRED
- Pagination ListBackupResponseGetPaginationAttributeType `json:"pagination" required:"true"`
-}
-
-type _ListBackupResponse ListBackupResponse
-
-// NewListBackupResponse instantiates a new ListBackupResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListBackupResponse(backups ListBackupResponseGetBackupsArgType, pagination ListBackupResponseGetPaginationArgType) *ListBackupResponse {
- this := ListBackupResponse{}
- setListBackupResponseGetBackupsAttributeType(&this.Backups, backups)
- setListBackupResponseGetPaginationAttributeType(&this.Pagination, pagination)
- return &this
-}
-
-// NewListBackupResponseWithDefaults instantiates a new ListBackupResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListBackupResponseWithDefaults() *ListBackupResponse {
- this := ListBackupResponse{}
- return &this
-}
-
-// GetBackups returns the Backups field value
-func (o *ListBackupResponse) GetBackups() (ret ListBackupResponseGetBackupsRetType) {
- ret, _ = o.GetBackupsOk()
- return ret
-}
-
-// GetBackupsOk returns a tuple with the Backups field value
-// and a boolean to check if the value has been set.
-func (o *ListBackupResponse) GetBackupsOk() (ret ListBackupResponseGetBackupsRetType, ok bool) {
- return getListBackupResponseGetBackupsAttributeTypeOk(o.Backups)
-}
-
-// SetBackups sets field value
-func (o *ListBackupResponse) SetBackups(v ListBackupResponseGetBackupsRetType) {
- setListBackupResponseGetBackupsAttributeType(&o.Backups, v)
-}
-
-// GetPagination returns the Pagination field value
-func (o *ListBackupResponse) GetPagination() (ret ListBackupResponseGetPaginationRetType) {
- ret, _ = o.GetPaginationOk()
- return ret
-}
-
-// GetPaginationOk returns a tuple with the Pagination field value
-// and a boolean to check if the value has been set.
-func (o *ListBackupResponse) GetPaginationOk() (ret ListBackupResponseGetPaginationRetType, ok bool) {
- return getListBackupResponseGetPaginationAttributeTypeOk(o.Pagination)
-}
-
-// SetPagination sets field value
-func (o *ListBackupResponse) SetPagination(v ListBackupResponseGetPaginationRetType) {
- setListBackupResponseGetPaginationAttributeType(&o.Pagination, v)
-}
-
-func (o ListBackupResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListBackupResponseGetBackupsAttributeTypeOk(o.Backups); ok {
- toSerialize["Backups"] = val
- }
- if val, ok := getListBackupResponseGetPaginationAttributeTypeOk(o.Pagination); ok {
- toSerialize["Pagination"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListBackupResponse struct {
- value *ListBackupResponse
- isSet bool
-}
-
-func (v NullableListBackupResponse) Get() *ListBackupResponse {
- return v.value
-}
-
-func (v *NullableListBackupResponse) Set(val *ListBackupResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListBackupResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListBackupResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListBackupResponse(val *ListBackupResponse) *NullableListBackupResponse {
- return &NullableListBackupResponse{value: val, isSet: true}
-}
-
-func (v NullableListBackupResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListBackupResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_backup_response_test.go b/pkg/sqlserverflexalpha/model_list_backup_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_backup_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_backup_test.go b/pkg/sqlserverflexalpha/model_list_backup_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_backup_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_backups_response.go b/pkg/sqlserverflexalpha/model_list_backups_response.go
deleted file mode 100644
index 9ca04238..00000000
--- a/pkg/sqlserverflexalpha/model_list_backups_response.go
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListBackupsResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListBackupsResponse{}
-
-/*
- types and functions for backups
-*/
-
-// isArray
-type ListBackupsResponseGetBackupsAttributeType = *[]ListBackup
-type ListBackupsResponseGetBackupsArgType = []ListBackup
-type ListBackupsResponseGetBackupsRetType = []ListBackup
-
-func getListBackupsResponseGetBackupsAttributeTypeOk(arg ListBackupsResponseGetBackupsAttributeType) (ret ListBackupsResponseGetBackupsRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupsResponseGetBackupsAttributeType(arg *ListBackupsResponseGetBackupsAttributeType, val ListBackupsResponseGetBackupsRetType) {
- *arg = &val
-}
-
-/*
- types and functions for databaseName
-*/
-
-// isNotNullableString
-type ListBackupsResponseGetDatabaseNameAttributeType = *string
-
-func getListBackupsResponseGetDatabaseNameAttributeTypeOk(arg ListBackupsResponseGetDatabaseNameAttributeType) (ret ListBackupsResponseGetDatabaseNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListBackupsResponseGetDatabaseNameAttributeType(arg *ListBackupsResponseGetDatabaseNameAttributeType, val ListBackupsResponseGetDatabaseNameRetType) {
- *arg = &val
-}
-
-type ListBackupsResponseGetDatabaseNameArgType = string
-type ListBackupsResponseGetDatabaseNameRetType = string
-
-// ListBackupsResponse struct for ListBackupsResponse
-type ListBackupsResponse struct {
- // List of the backups beloning to that database
- // REQUIRED
- Backups ListBackupsResponseGetBackupsAttributeType `json:"backups" required:"true" validate:"required,dive"`
- // Name of the database the backups belong to
- // REQUIRED
- DatabaseName ListBackupsResponseGetDatabaseNameAttributeType `json:"databaseName" required:"true" validate:"required,databaseName"`
-}
-
-type _ListBackupsResponse ListBackupsResponse
-
-// NewListBackupsResponse instantiates a new ListBackupsResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListBackupsResponse(backups ListBackupsResponseGetBackupsArgType, databaseName ListBackupsResponseGetDatabaseNameArgType) *ListBackupsResponse {
- this := ListBackupsResponse{}
- setListBackupsResponseGetBackupsAttributeType(&this.Backups, backups)
- setListBackupsResponseGetDatabaseNameAttributeType(&this.DatabaseName, databaseName)
- return &this
-}
-
-// NewListBackupsResponseWithDefaults instantiates a new ListBackupsResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListBackupsResponseWithDefaults() *ListBackupsResponse {
- this := ListBackupsResponse{}
- return &this
-}
-
-// GetBackups returns the Backups field value
-func (o *ListBackupsResponse) GetBackups() (ret ListBackupsResponseGetBackupsRetType) {
- ret, _ = o.GetBackupsOk()
- return ret
-}
-
-// GetBackupsOk returns a tuple with the Backups field value
-// and a boolean to check if the value has been set.
-func (o *ListBackupsResponse) GetBackupsOk() (ret ListBackupsResponseGetBackupsRetType, ok bool) {
- return getListBackupsResponseGetBackupsAttributeTypeOk(o.Backups)
-}
-
-// SetBackups sets field value
-func (o *ListBackupsResponse) SetBackups(v ListBackupsResponseGetBackupsRetType) {
- setListBackupsResponseGetBackupsAttributeType(&o.Backups, v)
-}
-
-// GetDatabaseName returns the DatabaseName field value
-func (o *ListBackupsResponse) GetDatabaseName() (ret ListBackupsResponseGetDatabaseNameRetType) {
- ret, _ = o.GetDatabaseNameOk()
- return ret
-}
-
-// GetDatabaseNameOk returns a tuple with the DatabaseName field value
-// and a boolean to check if the value has been set.
-func (o *ListBackupsResponse) GetDatabaseNameOk() (ret ListBackupsResponseGetDatabaseNameRetType, ok bool) {
- return getListBackupsResponseGetDatabaseNameAttributeTypeOk(o.DatabaseName)
-}
-
-// SetDatabaseName sets field value
-func (o *ListBackupsResponse) SetDatabaseName(v ListBackupsResponseGetDatabaseNameRetType) {
- setListBackupsResponseGetDatabaseNameAttributeType(&o.DatabaseName, v)
-}
-
-func (o ListBackupsResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListBackupsResponseGetBackupsAttributeTypeOk(o.Backups); ok {
- toSerialize["Backups"] = val
- }
- if val, ok := getListBackupsResponseGetDatabaseNameAttributeTypeOk(o.DatabaseName); ok {
- toSerialize["DatabaseName"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListBackupsResponse struct {
- value *ListBackupsResponse
- isSet bool
-}
-
-func (v NullableListBackupsResponse) Get() *ListBackupsResponse {
- return v.value
-}
-
-func (v *NullableListBackupsResponse) Set(val *ListBackupsResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListBackupsResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListBackupsResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListBackupsResponse(val *ListBackupsResponse) *NullableListBackupsResponse {
- return &NullableListBackupsResponse{value: val, isSet: true}
-}
-
-func (v NullableListBackupsResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListBackupsResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_backups_response_test.go b/pkg/sqlserverflexalpha/model_list_backups_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_backups_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_compatibility_response.go b/pkg/sqlserverflexalpha/model_list_compatibility_response.go
deleted file mode 100644
index 84c969f1..00000000
--- a/pkg/sqlserverflexalpha/model_list_compatibility_response.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListCompatibilityResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListCompatibilityResponse{}
-
-/*
- types and functions for compatibilities
-*/
-
-// isArray
-type ListCompatibilityResponseGetCompatibilitiesAttributeType = *[]DatabaseGetcompatibility
-type ListCompatibilityResponseGetCompatibilitiesArgType = []DatabaseGetcompatibility
-type ListCompatibilityResponseGetCompatibilitiesRetType = []DatabaseGetcompatibility
-
-func getListCompatibilityResponseGetCompatibilitiesAttributeTypeOk(arg ListCompatibilityResponseGetCompatibilitiesAttributeType) (ret ListCompatibilityResponseGetCompatibilitiesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListCompatibilityResponseGetCompatibilitiesAttributeType(arg *ListCompatibilityResponseGetCompatibilitiesAttributeType, val ListCompatibilityResponseGetCompatibilitiesRetType) {
- *arg = &val
-}
-
-// ListCompatibilityResponse struct for ListCompatibilityResponse
-type ListCompatibilityResponse struct {
- // List of compatibilities available for a d
- // REQUIRED
- Compatibilities ListCompatibilityResponseGetCompatibilitiesAttributeType `json:"compatibilities" required:"true"`
-}
-
-type _ListCompatibilityResponse ListCompatibilityResponse
-
-// NewListCompatibilityResponse instantiates a new ListCompatibilityResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListCompatibilityResponse(compatibilities ListCompatibilityResponseGetCompatibilitiesArgType) *ListCompatibilityResponse {
- this := ListCompatibilityResponse{}
- setListCompatibilityResponseGetCompatibilitiesAttributeType(&this.Compatibilities, compatibilities)
- return &this
-}
-
-// NewListCompatibilityResponseWithDefaults instantiates a new ListCompatibilityResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListCompatibilityResponseWithDefaults() *ListCompatibilityResponse {
- this := ListCompatibilityResponse{}
- return &this
-}
-
-// GetCompatibilities returns the Compatibilities field value
-func (o *ListCompatibilityResponse) GetCompatibilities() (ret ListCompatibilityResponseGetCompatibilitiesRetType) {
- ret, _ = o.GetCompatibilitiesOk()
- return ret
-}
-
-// GetCompatibilitiesOk returns a tuple with the Compatibilities field value
-// and a boolean to check if the value has been set.
-func (o *ListCompatibilityResponse) GetCompatibilitiesOk() (ret ListCompatibilityResponseGetCompatibilitiesRetType, ok bool) {
- return getListCompatibilityResponseGetCompatibilitiesAttributeTypeOk(o.Compatibilities)
-}
-
-// SetCompatibilities sets field value
-func (o *ListCompatibilityResponse) SetCompatibilities(v ListCompatibilityResponseGetCompatibilitiesRetType) {
- setListCompatibilityResponseGetCompatibilitiesAttributeType(&o.Compatibilities, v)
-}
-
-func (o ListCompatibilityResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListCompatibilityResponseGetCompatibilitiesAttributeTypeOk(o.Compatibilities); ok {
- toSerialize["Compatibilities"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListCompatibilityResponse struct {
- value *ListCompatibilityResponse
- isSet bool
-}
-
-func (v NullableListCompatibilityResponse) Get() *ListCompatibilityResponse {
- return v.value
-}
-
-func (v *NullableListCompatibilityResponse) Set(val *ListCompatibilityResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListCompatibilityResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListCompatibilityResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListCompatibilityResponse(val *ListCompatibilityResponse) *NullableListCompatibilityResponse {
- return &NullableListCompatibilityResponse{value: val, isSet: true}
-}
-
-func (v NullableListCompatibilityResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListCompatibilityResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_compatibility_response_test.go b/pkg/sqlserverflexalpha/model_list_compatibility_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_compatibility_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_current_running_restore_jobs.go b/pkg/sqlserverflexalpha/model_list_current_running_restore_jobs.go
deleted file mode 100644
index 38bc475a..00000000
--- a/pkg/sqlserverflexalpha/model_list_current_running_restore_jobs.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListCurrentRunningRestoreJobs type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListCurrentRunningRestoreJobs{}
-
-/*
- types and functions for runningRestores
-*/
-
-// isArray
-type ListCurrentRunningRestoreJobsGetRunningRestoresAttributeType = *[]BackupRunningRestore
-type ListCurrentRunningRestoreJobsGetRunningRestoresArgType = []BackupRunningRestore
-type ListCurrentRunningRestoreJobsGetRunningRestoresRetType = []BackupRunningRestore
-
-func getListCurrentRunningRestoreJobsGetRunningRestoresAttributeTypeOk(arg ListCurrentRunningRestoreJobsGetRunningRestoresAttributeType) (ret ListCurrentRunningRestoreJobsGetRunningRestoresRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListCurrentRunningRestoreJobsGetRunningRestoresAttributeType(arg *ListCurrentRunningRestoreJobsGetRunningRestoresAttributeType, val ListCurrentRunningRestoreJobsGetRunningRestoresRetType) {
- *arg = &val
-}
-
-// ListCurrentRunningRestoreJobs struct for ListCurrentRunningRestoreJobs
-type ListCurrentRunningRestoreJobs struct {
- // List of the currently running Restore jobs
- // REQUIRED
- RunningRestores ListCurrentRunningRestoreJobsGetRunningRestoresAttributeType `json:"runningRestores" required:"true"`
-}
-
-type _ListCurrentRunningRestoreJobs ListCurrentRunningRestoreJobs
-
-// NewListCurrentRunningRestoreJobs instantiates a new ListCurrentRunningRestoreJobs object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListCurrentRunningRestoreJobs(runningRestores ListCurrentRunningRestoreJobsGetRunningRestoresArgType) *ListCurrentRunningRestoreJobs {
- this := ListCurrentRunningRestoreJobs{}
- setListCurrentRunningRestoreJobsGetRunningRestoresAttributeType(&this.RunningRestores, runningRestores)
- return &this
-}
-
-// NewListCurrentRunningRestoreJobsWithDefaults instantiates a new ListCurrentRunningRestoreJobs object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListCurrentRunningRestoreJobsWithDefaults() *ListCurrentRunningRestoreJobs {
- this := ListCurrentRunningRestoreJobs{}
- return &this
-}
-
-// GetRunningRestores returns the RunningRestores field value
-func (o *ListCurrentRunningRestoreJobs) GetRunningRestores() (ret ListCurrentRunningRestoreJobsGetRunningRestoresRetType) {
- ret, _ = o.GetRunningRestoresOk()
- return ret
-}
-
-// GetRunningRestoresOk returns a tuple with the RunningRestores field value
-// and a boolean to check if the value has been set.
-func (o *ListCurrentRunningRestoreJobs) GetRunningRestoresOk() (ret ListCurrentRunningRestoreJobsGetRunningRestoresRetType, ok bool) {
- return getListCurrentRunningRestoreJobsGetRunningRestoresAttributeTypeOk(o.RunningRestores)
-}
-
-// SetRunningRestores sets field value
-func (o *ListCurrentRunningRestoreJobs) SetRunningRestores(v ListCurrentRunningRestoreJobsGetRunningRestoresRetType) {
- setListCurrentRunningRestoreJobsGetRunningRestoresAttributeType(&o.RunningRestores, v)
-}
-
-func (o ListCurrentRunningRestoreJobs) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListCurrentRunningRestoreJobsGetRunningRestoresAttributeTypeOk(o.RunningRestores); ok {
- toSerialize["RunningRestores"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListCurrentRunningRestoreJobs struct {
- value *ListCurrentRunningRestoreJobs
- isSet bool
-}
-
-func (v NullableListCurrentRunningRestoreJobs) Get() *ListCurrentRunningRestoreJobs {
- return v.value
-}
-
-func (v *NullableListCurrentRunningRestoreJobs) Set(val *ListCurrentRunningRestoreJobs) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListCurrentRunningRestoreJobs) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListCurrentRunningRestoreJobs) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListCurrentRunningRestoreJobs(val *ListCurrentRunningRestoreJobs) *NullableListCurrentRunningRestoreJobs {
- return &NullableListCurrentRunningRestoreJobs{value: val, isSet: true}
-}
-
-func (v NullableListCurrentRunningRestoreJobs) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListCurrentRunningRestoreJobs) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_current_running_restore_jobs_test.go b/pkg/sqlserverflexalpha/model_list_current_running_restore_jobs_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_current_running_restore_jobs_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_database.go b/pkg/sqlserverflexalpha/model_list_database.go
deleted file mode 100644
index 0960fb2f..00000000
--- a/pkg/sqlserverflexalpha/model_list_database.go
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListDatabase type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListDatabase{}
-
-/*
- types and functions for created
-*/
-
-// isNotNullableString
-type ListDatabaseGetCreatedAttributeType = *string
-
-func getListDatabaseGetCreatedAttributeTypeOk(arg ListDatabaseGetCreatedAttributeType) (ret ListDatabaseGetCreatedRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabaseGetCreatedAttributeType(arg *ListDatabaseGetCreatedAttributeType, val ListDatabaseGetCreatedRetType) {
- *arg = &val
-}
-
-type ListDatabaseGetCreatedArgType = string
-type ListDatabaseGetCreatedRetType = string
-
-/*
- types and functions for id
-*/
-
-// isLong
-type ListDatabaseGetIdAttributeType = *int64
-type ListDatabaseGetIdArgType = int64
-type ListDatabaseGetIdRetType = int64
-
-func getListDatabaseGetIdAttributeTypeOk(arg ListDatabaseGetIdAttributeType) (ret ListDatabaseGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabaseGetIdAttributeType(arg *ListDatabaseGetIdAttributeType, val ListDatabaseGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type ListDatabaseGetNameAttributeType = *string
-
-func getListDatabaseGetNameAttributeTypeOk(arg ListDatabaseGetNameAttributeType) (ret ListDatabaseGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabaseGetNameAttributeType(arg *ListDatabaseGetNameAttributeType, val ListDatabaseGetNameRetType) {
- *arg = &val
-}
-
-type ListDatabaseGetNameArgType = string
-type ListDatabaseGetNameRetType = string
-
-/*
- types and functions for owner
-*/
-
-// isNotNullableString
-type ListDatabaseGetOwnerAttributeType = *string
-
-func getListDatabaseGetOwnerAttributeTypeOk(arg ListDatabaseGetOwnerAttributeType) (ret ListDatabaseGetOwnerRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabaseGetOwnerAttributeType(arg *ListDatabaseGetOwnerAttributeType, val ListDatabaseGetOwnerRetType) {
- *arg = &val
-}
-
-type ListDatabaseGetOwnerArgType = string
-type ListDatabaseGetOwnerRetType = string
-
-// ListDatabase struct for ListDatabase
-type ListDatabase struct {
- // The date when the database was created in RFC3339 format.
- // REQUIRED
- Created ListDatabaseGetCreatedAttributeType `json:"created" required:"true"`
- // The id of the database.
- // REQUIRED
- Id ListDatabaseGetIdAttributeType `json:"id" required:"true"`
- // The name of the database.
- // REQUIRED
- Name ListDatabaseGetNameAttributeType `json:"name" required:"true"`
- // The owner of the database.
- // REQUIRED
- Owner ListDatabaseGetOwnerAttributeType `json:"owner" required:"true"`
-}
-
-type _ListDatabase ListDatabase
-
-// NewListDatabase instantiates a new ListDatabase object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListDatabase(created ListDatabaseGetCreatedArgType, id ListDatabaseGetIdArgType, name ListDatabaseGetNameArgType, owner ListDatabaseGetOwnerArgType) *ListDatabase {
- this := ListDatabase{}
- setListDatabaseGetCreatedAttributeType(&this.Created, created)
- setListDatabaseGetIdAttributeType(&this.Id, id)
- setListDatabaseGetNameAttributeType(&this.Name, name)
- setListDatabaseGetOwnerAttributeType(&this.Owner, owner)
- return &this
-}
-
-// NewListDatabaseWithDefaults instantiates a new ListDatabase object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListDatabaseWithDefaults() *ListDatabase {
- this := ListDatabase{}
- return &this
-}
-
-// GetCreated returns the Created field value
-func (o *ListDatabase) GetCreated() (ret ListDatabaseGetCreatedRetType) {
- ret, _ = o.GetCreatedOk()
- return ret
-}
-
-// GetCreatedOk returns a tuple with the Created field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabase) GetCreatedOk() (ret ListDatabaseGetCreatedRetType, ok bool) {
- return getListDatabaseGetCreatedAttributeTypeOk(o.Created)
-}
-
-// SetCreated sets field value
-func (o *ListDatabase) SetCreated(v ListDatabaseGetCreatedRetType) {
- setListDatabaseGetCreatedAttributeType(&o.Created, v)
-}
-
-// GetId returns the Id field value
-func (o *ListDatabase) GetId() (ret ListDatabaseGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabase) GetIdOk() (ret ListDatabaseGetIdRetType, ok bool) {
- return getListDatabaseGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *ListDatabase) SetId(v ListDatabaseGetIdRetType) {
- setListDatabaseGetIdAttributeType(&o.Id, v)
-}
-
-// GetName returns the Name field value
-func (o *ListDatabase) GetName() (ret ListDatabaseGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabase) GetNameOk() (ret ListDatabaseGetNameRetType, ok bool) {
- return getListDatabaseGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *ListDatabase) SetName(v ListDatabaseGetNameRetType) {
- setListDatabaseGetNameAttributeType(&o.Name, v)
-}
-
-// GetOwner returns the Owner field value
-func (o *ListDatabase) GetOwner() (ret ListDatabaseGetOwnerRetType) {
- ret, _ = o.GetOwnerOk()
- return ret
-}
-
-// GetOwnerOk returns a tuple with the Owner field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabase) GetOwnerOk() (ret ListDatabaseGetOwnerRetType, ok bool) {
- return getListDatabaseGetOwnerAttributeTypeOk(o.Owner)
-}
-
-// SetOwner sets field value
-func (o *ListDatabase) SetOwner(v ListDatabaseGetOwnerRetType) {
- setListDatabaseGetOwnerAttributeType(&o.Owner, v)
-}
-
-func (o ListDatabase) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListDatabaseGetCreatedAttributeTypeOk(o.Created); ok {
- toSerialize["Created"] = val
- }
- if val, ok := getListDatabaseGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getListDatabaseGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getListDatabaseGetOwnerAttributeTypeOk(o.Owner); ok {
- toSerialize["Owner"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListDatabase struct {
- value *ListDatabase
- isSet bool
-}
-
-func (v NullableListDatabase) Get() *ListDatabase {
- return v.value
-}
-
-func (v *NullableListDatabase) Set(val *ListDatabase) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListDatabase) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListDatabase) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListDatabase(val *ListDatabase) *NullableListDatabase {
- return &NullableListDatabase{value: val, isSet: true}
-}
-
-func (v NullableListDatabase) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListDatabase) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_database_test.go b/pkg/sqlserverflexalpha/model_list_database_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_database_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_databases_response.go b/pkg/sqlserverflexalpha/model_list_databases_response.go
deleted file mode 100644
index d09ba44c..00000000
--- a/pkg/sqlserverflexalpha/model_list_databases_response.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListDatabasesResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListDatabasesResponse{}
-
-/*
- types and functions for databases
-*/
-
-// isArray
-type ListDatabasesResponseGetDatabasesAttributeType = *[]ListDatabase
-type ListDatabasesResponseGetDatabasesArgType = []ListDatabase
-type ListDatabasesResponseGetDatabasesRetType = []ListDatabase
-
-func getListDatabasesResponseGetDatabasesAttributeTypeOk(arg ListDatabasesResponseGetDatabasesAttributeType) (ret ListDatabasesResponseGetDatabasesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabasesResponseGetDatabasesAttributeType(arg *ListDatabasesResponseGetDatabasesAttributeType, val ListDatabasesResponseGetDatabasesRetType) {
- *arg = &val
-}
-
-/*
- types and functions for pagination
-*/
-
-// isModel
-type ListDatabasesResponseGetPaginationAttributeType = *Pagination
-type ListDatabasesResponseGetPaginationArgType = Pagination
-type ListDatabasesResponseGetPaginationRetType = Pagination
-
-func getListDatabasesResponseGetPaginationAttributeTypeOk(arg ListDatabasesResponseGetPaginationAttributeType) (ret ListDatabasesResponseGetPaginationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListDatabasesResponseGetPaginationAttributeType(arg *ListDatabasesResponseGetPaginationAttributeType, val ListDatabasesResponseGetPaginationRetType) {
- *arg = &val
-}
-
-// ListDatabasesResponse struct for ListDatabasesResponse
-type ListDatabasesResponse struct {
- // A list containing all databases for the instance.
- // REQUIRED
- Databases ListDatabasesResponseGetDatabasesAttributeType `json:"databases" required:"true"`
- // REQUIRED
- Pagination ListDatabasesResponseGetPaginationAttributeType `json:"pagination" required:"true"`
-}
-
-type _ListDatabasesResponse ListDatabasesResponse
-
-// NewListDatabasesResponse instantiates a new ListDatabasesResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListDatabasesResponse(databases ListDatabasesResponseGetDatabasesArgType, pagination ListDatabasesResponseGetPaginationArgType) *ListDatabasesResponse {
- this := ListDatabasesResponse{}
- setListDatabasesResponseGetDatabasesAttributeType(&this.Databases, databases)
- setListDatabasesResponseGetPaginationAttributeType(&this.Pagination, pagination)
- return &this
-}
-
-// NewListDatabasesResponseWithDefaults instantiates a new ListDatabasesResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListDatabasesResponseWithDefaults() *ListDatabasesResponse {
- this := ListDatabasesResponse{}
- return &this
-}
-
-// GetDatabases returns the Databases field value
-func (o *ListDatabasesResponse) GetDatabases() (ret ListDatabasesResponseGetDatabasesRetType) {
- ret, _ = o.GetDatabasesOk()
- return ret
-}
-
-// GetDatabasesOk returns a tuple with the Databases field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabasesResponse) GetDatabasesOk() (ret ListDatabasesResponseGetDatabasesRetType, ok bool) {
- return getListDatabasesResponseGetDatabasesAttributeTypeOk(o.Databases)
-}
-
-// SetDatabases sets field value
-func (o *ListDatabasesResponse) SetDatabases(v ListDatabasesResponseGetDatabasesRetType) {
- setListDatabasesResponseGetDatabasesAttributeType(&o.Databases, v)
-}
-
-// GetPagination returns the Pagination field value
-func (o *ListDatabasesResponse) GetPagination() (ret ListDatabasesResponseGetPaginationRetType) {
- ret, _ = o.GetPaginationOk()
- return ret
-}
-
-// GetPaginationOk returns a tuple with the Pagination field value
-// and a boolean to check if the value has been set.
-func (o *ListDatabasesResponse) GetPaginationOk() (ret ListDatabasesResponseGetPaginationRetType, ok bool) {
- return getListDatabasesResponseGetPaginationAttributeTypeOk(o.Pagination)
-}
-
-// SetPagination sets field value
-func (o *ListDatabasesResponse) SetPagination(v ListDatabasesResponseGetPaginationRetType) {
- setListDatabasesResponseGetPaginationAttributeType(&o.Pagination, v)
-}
-
-func (o ListDatabasesResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListDatabasesResponseGetDatabasesAttributeTypeOk(o.Databases); ok {
- toSerialize["Databases"] = val
- }
- if val, ok := getListDatabasesResponseGetPaginationAttributeTypeOk(o.Pagination); ok {
- toSerialize["Pagination"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListDatabasesResponse struct {
- value *ListDatabasesResponse
- isSet bool
-}
-
-func (v NullableListDatabasesResponse) Get() *ListDatabasesResponse {
- return v.value
-}
-
-func (v *NullableListDatabasesResponse) Set(val *ListDatabasesResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListDatabasesResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListDatabasesResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListDatabasesResponse(val *ListDatabasesResponse) *NullableListDatabasesResponse {
- return &NullableListDatabasesResponse{value: val, isSet: true}
-}
-
-func (v NullableListDatabasesResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListDatabasesResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_databases_response_test.go b/pkg/sqlserverflexalpha/model_list_databases_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_databases_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_flavors.go b/pkg/sqlserverflexalpha/model_list_flavors.go
deleted file mode 100644
index 799577b2..00000000
--- a/pkg/sqlserverflexalpha/model_list_flavors.go
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListFlavors type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListFlavors{}
-
-/*
- types and functions for cpu
-*/
-
-// isLong
-type ListFlavorsGetCpuAttributeType = *int64
-type ListFlavorsGetCpuArgType = int64
-type ListFlavorsGetCpuRetType = int64
-
-func getListFlavorsGetCpuAttributeTypeOk(arg ListFlavorsGetCpuAttributeType) (ret ListFlavorsGetCpuRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetCpuAttributeType(arg *ListFlavorsGetCpuAttributeType, val ListFlavorsGetCpuRetType) {
- *arg = &val
-}
-
-/*
- types and functions for description
-*/
-
-// isNotNullableString
-type ListFlavorsGetDescriptionAttributeType = *string
-
-func getListFlavorsGetDescriptionAttributeTypeOk(arg ListFlavorsGetDescriptionAttributeType) (ret ListFlavorsGetDescriptionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetDescriptionAttributeType(arg *ListFlavorsGetDescriptionAttributeType, val ListFlavorsGetDescriptionRetType) {
- *arg = &val
-}
-
-type ListFlavorsGetDescriptionArgType = string
-type ListFlavorsGetDescriptionRetType = string
-
-/*
- types and functions for id
-*/
-
-// isNotNullableString
-type ListFlavorsGetIdAttributeType = *string
-
-func getListFlavorsGetIdAttributeTypeOk(arg ListFlavorsGetIdAttributeType) (ret ListFlavorsGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetIdAttributeType(arg *ListFlavorsGetIdAttributeType, val ListFlavorsGetIdRetType) {
- *arg = &val
-}
-
-type ListFlavorsGetIdArgType = string
-type ListFlavorsGetIdRetType = string
-
-/*
- types and functions for maxGB
-*/
-
-// isInteger
-type ListFlavorsGetMaxGBAttributeType = *int64
-type ListFlavorsGetMaxGBArgType = int64
-type ListFlavorsGetMaxGBRetType = int64
-
-func getListFlavorsGetMaxGBAttributeTypeOk(arg ListFlavorsGetMaxGBAttributeType) (ret ListFlavorsGetMaxGBRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetMaxGBAttributeType(arg *ListFlavorsGetMaxGBAttributeType, val ListFlavorsGetMaxGBRetType) {
- *arg = &val
-}
-
-/*
- types and functions for memory
-*/
-
-// isLong
-type ListFlavorsGetMemoryAttributeType = *int64
-type ListFlavorsGetMemoryArgType = int64
-type ListFlavorsGetMemoryRetType = int64
-
-func getListFlavorsGetMemoryAttributeTypeOk(arg ListFlavorsGetMemoryAttributeType) (ret ListFlavorsGetMemoryRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetMemoryAttributeType(arg *ListFlavorsGetMemoryAttributeType, val ListFlavorsGetMemoryRetType) {
- *arg = &val
-}
-
-/*
- types and functions for minGB
-*/
-
-// isInteger
-type ListFlavorsGetMinGBAttributeType = *int64
-type ListFlavorsGetMinGBArgType = int64
-type ListFlavorsGetMinGBRetType = int64
-
-func getListFlavorsGetMinGBAttributeTypeOk(arg ListFlavorsGetMinGBAttributeType) (ret ListFlavorsGetMinGBRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetMinGBAttributeType(arg *ListFlavorsGetMinGBAttributeType, val ListFlavorsGetMinGBRetType) {
- *arg = &val
-}
-
-/*
- types and functions for nodeType
-*/
-
-// isNotNullableString
-type ListFlavorsGetNodeTypeAttributeType = *string
-
-func getListFlavorsGetNodeTypeAttributeTypeOk(arg ListFlavorsGetNodeTypeAttributeType) (ret ListFlavorsGetNodeTypeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetNodeTypeAttributeType(arg *ListFlavorsGetNodeTypeAttributeType, val ListFlavorsGetNodeTypeRetType) {
- *arg = &val
-}
-
-type ListFlavorsGetNodeTypeArgType = string
-type ListFlavorsGetNodeTypeRetType = string
-
-/*
- types and functions for storageClasses
-*/
-
-// isArray
-type ListFlavorsGetStorageClassesAttributeType = *[]FlavorStorageClassesStorageClass
-type ListFlavorsGetStorageClassesArgType = []FlavorStorageClassesStorageClass
-type ListFlavorsGetStorageClassesRetType = []FlavorStorageClassesStorageClass
-
-func getListFlavorsGetStorageClassesAttributeTypeOk(arg ListFlavorsGetStorageClassesAttributeType) (ret ListFlavorsGetStorageClassesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListFlavorsGetStorageClassesAttributeType(arg *ListFlavorsGetStorageClassesAttributeType, val ListFlavorsGetStorageClassesRetType) {
- *arg = &val
-}
-
-// ListFlavors The flavor of the instance containing the technical features.
-type ListFlavors struct {
- // The cpu count of the instance.
- // REQUIRED
- Cpu ListFlavorsGetCpuAttributeType `json:"cpu" required:"true"`
- // The flavor description.
- // REQUIRED
- Description ListFlavorsGetDescriptionAttributeType `json:"description" required:"true"`
- // The id of the instance flavor.
- // REQUIRED
- Id ListFlavorsGetIdAttributeType `json:"id" required:"true"`
- // maximum storage which can be ordered for the flavor in Gigabyte.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- MaxGB ListFlavorsGetMaxGBAttributeType `json:"maxGB" required:"true"`
- // The memory of the instance in Gibibyte.
- // REQUIRED
- Memory ListFlavorsGetMemoryAttributeType `json:"memory" required:"true"`
- // minimum storage which is required to order in Gigabyte.
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- MinGB ListFlavorsGetMinGBAttributeType `json:"minGB" required:"true"`
- // defines the nodeType it can be either single or HA
- // REQUIRED
- NodeType ListFlavorsGetNodeTypeAttributeType `json:"nodeType" required:"true"`
- // maximum storage which can be ordered for the flavor in Gigabyte.
- // REQUIRED
- StorageClasses ListFlavorsGetStorageClassesAttributeType `json:"storageClasses" required:"true"`
-}
-
-type _ListFlavors ListFlavors
-
-// NewListFlavors instantiates a new ListFlavors object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListFlavors(cpu ListFlavorsGetCpuArgType, description ListFlavorsGetDescriptionArgType, id ListFlavorsGetIdArgType, maxGB ListFlavorsGetMaxGBArgType, memory ListFlavorsGetMemoryArgType, minGB ListFlavorsGetMinGBArgType, nodeType ListFlavorsGetNodeTypeArgType, storageClasses ListFlavorsGetStorageClassesArgType) *ListFlavors {
- this := ListFlavors{}
- setListFlavorsGetCpuAttributeType(&this.Cpu, cpu)
- setListFlavorsGetDescriptionAttributeType(&this.Description, description)
- setListFlavorsGetIdAttributeType(&this.Id, id)
- setListFlavorsGetMaxGBAttributeType(&this.MaxGB, maxGB)
- setListFlavorsGetMemoryAttributeType(&this.Memory, memory)
- setListFlavorsGetMinGBAttributeType(&this.MinGB, minGB)
- setListFlavorsGetNodeTypeAttributeType(&this.NodeType, nodeType)
- setListFlavorsGetStorageClassesAttributeType(&this.StorageClasses, storageClasses)
- return &this
-}
-
-// NewListFlavorsWithDefaults instantiates a new ListFlavors object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListFlavorsWithDefaults() *ListFlavors {
- this := ListFlavors{}
- return &this
-}
-
-// GetCpu returns the Cpu field value
-func (o *ListFlavors) GetCpu() (ret ListFlavorsGetCpuRetType) {
- ret, _ = o.GetCpuOk()
- return ret
-}
-
-// GetCpuOk returns a tuple with the Cpu field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetCpuOk() (ret ListFlavorsGetCpuRetType, ok bool) {
- return getListFlavorsGetCpuAttributeTypeOk(o.Cpu)
-}
-
-// SetCpu sets field value
-func (o *ListFlavors) SetCpu(v ListFlavorsGetCpuRetType) {
- setListFlavorsGetCpuAttributeType(&o.Cpu, v)
-}
-
-// GetDescription returns the Description field value
-func (o *ListFlavors) GetDescription() (ret ListFlavorsGetDescriptionRetType) {
- ret, _ = o.GetDescriptionOk()
- return ret
-}
-
-// GetDescriptionOk returns a tuple with the Description field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetDescriptionOk() (ret ListFlavorsGetDescriptionRetType, ok bool) {
- return getListFlavorsGetDescriptionAttributeTypeOk(o.Description)
-}
-
-// SetDescription sets field value
-func (o *ListFlavors) SetDescription(v ListFlavorsGetDescriptionRetType) {
- setListFlavorsGetDescriptionAttributeType(&o.Description, v)
-}
-
-// GetId returns the Id field value
-func (o *ListFlavors) GetId() (ret ListFlavorsGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetIdOk() (ret ListFlavorsGetIdRetType, ok bool) {
- return getListFlavorsGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *ListFlavors) SetId(v ListFlavorsGetIdRetType) {
- setListFlavorsGetIdAttributeType(&o.Id, v)
-}
-
-// GetMaxGB returns the MaxGB field value
-func (o *ListFlavors) GetMaxGB() (ret ListFlavorsGetMaxGBRetType) {
- ret, _ = o.GetMaxGBOk()
- return ret
-}
-
-// GetMaxGBOk returns a tuple with the MaxGB field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetMaxGBOk() (ret ListFlavorsGetMaxGBRetType, ok bool) {
- return getListFlavorsGetMaxGBAttributeTypeOk(o.MaxGB)
-}
-
-// SetMaxGB sets field value
-func (o *ListFlavors) SetMaxGB(v ListFlavorsGetMaxGBRetType) {
- setListFlavorsGetMaxGBAttributeType(&o.MaxGB, v)
-}
-
-// GetMemory returns the Memory field value
-func (o *ListFlavors) GetMemory() (ret ListFlavorsGetMemoryRetType) {
- ret, _ = o.GetMemoryOk()
- return ret
-}
-
-// GetMemoryOk returns a tuple with the Memory field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetMemoryOk() (ret ListFlavorsGetMemoryRetType, ok bool) {
- return getListFlavorsGetMemoryAttributeTypeOk(o.Memory)
-}
-
-// SetMemory sets field value
-func (o *ListFlavors) SetMemory(v ListFlavorsGetMemoryRetType) {
- setListFlavorsGetMemoryAttributeType(&o.Memory, v)
-}
-
-// GetMinGB returns the MinGB field value
-func (o *ListFlavors) GetMinGB() (ret ListFlavorsGetMinGBRetType) {
- ret, _ = o.GetMinGBOk()
- return ret
-}
-
-// GetMinGBOk returns a tuple with the MinGB field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetMinGBOk() (ret ListFlavorsGetMinGBRetType, ok bool) {
- return getListFlavorsGetMinGBAttributeTypeOk(o.MinGB)
-}
-
-// SetMinGB sets field value
-func (o *ListFlavors) SetMinGB(v ListFlavorsGetMinGBRetType) {
- setListFlavorsGetMinGBAttributeType(&o.MinGB, v)
-}
-
-// GetNodeType returns the NodeType field value
-func (o *ListFlavors) GetNodeType() (ret ListFlavorsGetNodeTypeRetType) {
- ret, _ = o.GetNodeTypeOk()
- return ret
-}
-
-// GetNodeTypeOk returns a tuple with the NodeType field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetNodeTypeOk() (ret ListFlavorsGetNodeTypeRetType, ok bool) {
- return getListFlavorsGetNodeTypeAttributeTypeOk(o.NodeType)
-}
-
-// SetNodeType sets field value
-func (o *ListFlavors) SetNodeType(v ListFlavorsGetNodeTypeRetType) {
- setListFlavorsGetNodeTypeAttributeType(&o.NodeType, v)
-}
-
-// GetStorageClasses returns the StorageClasses field value
-func (o *ListFlavors) GetStorageClasses() (ret ListFlavorsGetStorageClassesRetType) {
- ret, _ = o.GetStorageClassesOk()
- return ret
-}
-
-// GetStorageClassesOk returns a tuple with the StorageClasses field value
-// and a boolean to check if the value has been set.
-func (o *ListFlavors) GetStorageClassesOk() (ret ListFlavorsGetStorageClassesRetType, ok bool) {
- return getListFlavorsGetStorageClassesAttributeTypeOk(o.StorageClasses)
-}
-
-// SetStorageClasses sets field value
-func (o *ListFlavors) SetStorageClasses(v ListFlavorsGetStorageClassesRetType) {
- setListFlavorsGetStorageClassesAttributeType(&o.StorageClasses, v)
-}
-
-func (o ListFlavors) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListFlavorsGetCpuAttributeTypeOk(o.Cpu); ok {
- toSerialize["Cpu"] = val
- }
- if val, ok := getListFlavorsGetDescriptionAttributeTypeOk(o.Description); ok {
- toSerialize["Description"] = val
- }
- if val, ok := getListFlavorsGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getListFlavorsGetMaxGBAttributeTypeOk(o.MaxGB); ok {
- toSerialize["MaxGB"] = val
- }
- if val, ok := getListFlavorsGetMemoryAttributeTypeOk(o.Memory); ok {
- toSerialize["Memory"] = val
- }
- if val, ok := getListFlavorsGetMinGBAttributeTypeOk(o.MinGB); ok {
- toSerialize["MinGB"] = val
- }
- if val, ok := getListFlavorsGetNodeTypeAttributeTypeOk(o.NodeType); ok {
- toSerialize["NodeType"] = val
- }
- if val, ok := getListFlavorsGetStorageClassesAttributeTypeOk(o.StorageClasses); ok {
- toSerialize["StorageClasses"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListFlavors struct {
- value *ListFlavors
- isSet bool
-}
-
-func (v NullableListFlavors) Get() *ListFlavors {
- return v.value
-}
-
-func (v *NullableListFlavors) Set(val *ListFlavors) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListFlavors) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListFlavors) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListFlavors(val *ListFlavors) *NullableListFlavors {
- return &NullableListFlavors{value: val, isSet: true}
-}
-
-func (v NullableListFlavors) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListFlavors) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_flavors_test.go b/pkg/sqlserverflexalpha/model_list_flavors_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_flavors_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_instance.go b/pkg/sqlserverflexalpha/model_list_instance.go
deleted file mode 100644
index 07871aaa..00000000
--- a/pkg/sqlserverflexalpha/model_list_instance.go
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListInstance type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListInstance{}
-
-/*
- types and functions for id
-*/
-
-// isNotNullableString
-type ListInstanceGetIdAttributeType = *string
-
-func getListInstanceGetIdAttributeTypeOk(arg ListInstanceGetIdAttributeType) (ret ListInstanceGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstanceGetIdAttributeType(arg *ListInstanceGetIdAttributeType, val ListInstanceGetIdRetType) {
- *arg = &val
-}
-
-type ListInstanceGetIdArgType = string
-type ListInstanceGetIdRetType = string
-
-/*
- types and functions for isDeletable
-*/
-
-// isBoolean
-type ListInstancegetIsDeletableAttributeType = *bool
-type ListInstancegetIsDeletableArgType = bool
-type ListInstancegetIsDeletableRetType = bool
-
-func getListInstancegetIsDeletableAttributeTypeOk(arg ListInstancegetIsDeletableAttributeType) (ret ListInstancegetIsDeletableRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstancegetIsDeletableAttributeType(arg *ListInstancegetIsDeletableAttributeType, val ListInstancegetIsDeletableRetType) {
- *arg = &val
-}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type ListInstanceGetNameAttributeType = *string
-
-func getListInstanceGetNameAttributeTypeOk(arg ListInstanceGetNameAttributeType) (ret ListInstanceGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstanceGetNameAttributeType(arg *ListInstanceGetNameAttributeType, val ListInstanceGetNameRetType) {
- *arg = &val
-}
-
-type ListInstanceGetNameArgType = string
-type ListInstanceGetNameRetType = string
-
-/*
- types and functions for status
-*/
-
-// isEnumRef
-type ListInstanceGetStatusAttributeType = *Status
-type ListInstanceGetStatusArgType = Status
-type ListInstanceGetStatusRetType = Status
-
-func getListInstanceGetStatusAttributeTypeOk(arg ListInstanceGetStatusAttributeType) (ret ListInstanceGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstanceGetStatusAttributeType(arg *ListInstanceGetStatusAttributeType, val ListInstanceGetStatusRetType) {
- *arg = &val
-}
-
-// ListInstance struct for ListInstance
-type ListInstance struct {
- // The ID of the instance.
- // REQUIRED
- Id ListInstanceGetIdAttributeType `json:"id" required:"true"`
- // Whether the instance can be deleted or not.
- // REQUIRED
- IsDeletable ListInstancegetIsDeletableAttributeType `json:"isDeletable" required:"true"`
- // The name of the instance.
- // REQUIRED
- Name ListInstanceGetNameAttributeType `json:"name" required:"true"`
- // REQUIRED
- Status ListInstanceGetStatusAttributeType `json:"status" required:"true"`
-}
-
-type _ListInstance ListInstance
-
-// NewListInstance instantiates a new ListInstance object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListInstance(id ListInstanceGetIdArgType, isDeletable ListInstancegetIsDeletableArgType, name ListInstanceGetNameArgType, status ListInstanceGetStatusArgType) *ListInstance {
- this := ListInstance{}
- setListInstanceGetIdAttributeType(&this.Id, id)
- setListInstancegetIsDeletableAttributeType(&this.IsDeletable, isDeletable)
- setListInstanceGetNameAttributeType(&this.Name, name)
- setListInstanceGetStatusAttributeType(&this.Status, status)
- return &this
-}
-
-// NewListInstanceWithDefaults instantiates a new ListInstance object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListInstanceWithDefaults() *ListInstance {
- this := ListInstance{}
- return &this
-}
-
-// GetId returns the Id field value
-func (o *ListInstance) GetId() (ret ListInstanceGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *ListInstance) GetIdOk() (ret ListInstanceGetIdRetType, ok bool) {
- return getListInstanceGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *ListInstance) SetId(v ListInstanceGetIdRetType) {
- setListInstanceGetIdAttributeType(&o.Id, v)
-}
-
-// GetIsDeletable returns the IsDeletable field value
-func (o *ListInstance) GetIsDeletable() (ret ListInstancegetIsDeletableRetType) {
- ret, _ = o.GetIsDeletableOk()
- return ret
-}
-
-// GetIsDeletableOk returns a tuple with the IsDeletable field value
-// and a boolean to check if the value has been set.
-func (o *ListInstance) GetIsDeletableOk() (ret ListInstancegetIsDeletableRetType, ok bool) {
- return getListInstancegetIsDeletableAttributeTypeOk(o.IsDeletable)
-}
-
-// SetIsDeletable sets field value
-func (o *ListInstance) SetIsDeletable(v ListInstancegetIsDeletableRetType) {
- setListInstancegetIsDeletableAttributeType(&o.IsDeletable, v)
-}
-
-// GetName returns the Name field value
-func (o *ListInstance) GetName() (ret ListInstanceGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *ListInstance) GetNameOk() (ret ListInstanceGetNameRetType, ok bool) {
- return getListInstanceGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *ListInstance) SetName(v ListInstanceGetNameRetType) {
- setListInstanceGetNameAttributeType(&o.Name, v)
-}
-
-// GetStatus returns the Status field value
-func (o *ListInstance) GetStatus() (ret ListInstanceGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *ListInstance) GetStatusOk() (ret ListInstanceGetStatusRetType, ok bool) {
- return getListInstanceGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *ListInstance) SetStatus(v ListInstanceGetStatusRetType) {
- setListInstanceGetStatusAttributeType(&o.Status, v)
-}
-
-func (o ListInstance) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListInstanceGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getListInstancegetIsDeletableAttributeTypeOk(o.IsDeletable); ok {
- toSerialize["IsDeletable"] = val
- }
- if val, ok := getListInstanceGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getListInstanceGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListInstance struct {
- value *ListInstance
- isSet bool
-}
-
-func (v NullableListInstance) Get() *ListInstance {
- return v.value
-}
-
-func (v *NullableListInstance) Set(val *ListInstance) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListInstance) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListInstance) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListInstance(val *ListInstance) *NullableListInstance {
- return &NullableListInstance{value: val, isSet: true}
-}
-
-func (v NullableListInstance) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListInstance) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_instance_test.go b/pkg/sqlserverflexalpha/model_list_instance_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_instance_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_instances_response.go b/pkg/sqlserverflexalpha/model_list_instances_response.go
deleted file mode 100644
index 79ee23b0..00000000
--- a/pkg/sqlserverflexalpha/model_list_instances_response.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListInstancesResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListInstancesResponse{}
-
-/*
- types and functions for instances
-*/
-
-// isArray
-type ListInstancesResponseGetInstancesAttributeType = *[]ListInstance
-type ListInstancesResponseGetInstancesArgType = []ListInstance
-type ListInstancesResponseGetInstancesRetType = []ListInstance
-
-func getListInstancesResponseGetInstancesAttributeTypeOk(arg ListInstancesResponseGetInstancesAttributeType) (ret ListInstancesResponseGetInstancesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstancesResponseGetInstancesAttributeType(arg *ListInstancesResponseGetInstancesAttributeType, val ListInstancesResponseGetInstancesRetType) {
- *arg = &val
-}
-
-/*
- types and functions for pagination
-*/
-
-// isModel
-type ListInstancesResponseGetPaginationAttributeType = *Pagination
-type ListInstancesResponseGetPaginationArgType = Pagination
-type ListInstancesResponseGetPaginationRetType = Pagination
-
-func getListInstancesResponseGetPaginationAttributeTypeOk(arg ListInstancesResponseGetPaginationAttributeType) (ret ListInstancesResponseGetPaginationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListInstancesResponseGetPaginationAttributeType(arg *ListInstancesResponseGetPaginationAttributeType, val ListInstancesResponseGetPaginationRetType) {
- *arg = &val
-}
-
-// ListInstancesResponse struct for ListInstancesResponse
-type ListInstancesResponse struct {
- // List of owned instances and their current status.
- // REQUIRED
- Instances ListInstancesResponseGetInstancesAttributeType `json:"instances" required:"true"`
- // REQUIRED
- Pagination ListInstancesResponseGetPaginationAttributeType `json:"pagination" required:"true"`
-}
-
-type _ListInstancesResponse ListInstancesResponse
-
-// NewListInstancesResponse instantiates a new ListInstancesResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListInstancesResponse(instances ListInstancesResponseGetInstancesArgType, pagination ListInstancesResponseGetPaginationArgType) *ListInstancesResponse {
- this := ListInstancesResponse{}
- setListInstancesResponseGetInstancesAttributeType(&this.Instances, instances)
- setListInstancesResponseGetPaginationAttributeType(&this.Pagination, pagination)
- return &this
-}
-
-// NewListInstancesResponseWithDefaults instantiates a new ListInstancesResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListInstancesResponseWithDefaults() *ListInstancesResponse {
- this := ListInstancesResponse{}
- return &this
-}
-
-// GetInstances returns the Instances field value
-func (o *ListInstancesResponse) GetInstances() (ret ListInstancesResponseGetInstancesRetType) {
- ret, _ = o.GetInstancesOk()
- return ret
-}
-
-// GetInstancesOk returns a tuple with the Instances field value
-// and a boolean to check if the value has been set.
-func (o *ListInstancesResponse) GetInstancesOk() (ret ListInstancesResponseGetInstancesRetType, ok bool) {
- return getListInstancesResponseGetInstancesAttributeTypeOk(o.Instances)
-}
-
-// SetInstances sets field value
-func (o *ListInstancesResponse) SetInstances(v ListInstancesResponseGetInstancesRetType) {
- setListInstancesResponseGetInstancesAttributeType(&o.Instances, v)
-}
-
-// GetPagination returns the Pagination field value
-func (o *ListInstancesResponse) GetPagination() (ret ListInstancesResponseGetPaginationRetType) {
- ret, _ = o.GetPaginationOk()
- return ret
-}
-
-// GetPaginationOk returns a tuple with the Pagination field value
-// and a boolean to check if the value has been set.
-func (o *ListInstancesResponse) GetPaginationOk() (ret ListInstancesResponseGetPaginationRetType, ok bool) {
- return getListInstancesResponseGetPaginationAttributeTypeOk(o.Pagination)
-}
-
-// SetPagination sets field value
-func (o *ListInstancesResponse) SetPagination(v ListInstancesResponseGetPaginationRetType) {
- setListInstancesResponseGetPaginationAttributeType(&o.Pagination, v)
-}
-
-func (o ListInstancesResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListInstancesResponseGetInstancesAttributeTypeOk(o.Instances); ok {
- toSerialize["Instances"] = val
- }
- if val, ok := getListInstancesResponseGetPaginationAttributeTypeOk(o.Pagination); ok {
- toSerialize["Pagination"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListInstancesResponse struct {
- value *ListInstancesResponse
- isSet bool
-}
-
-func (v NullableListInstancesResponse) Get() *ListInstancesResponse {
- return v.value
-}
-
-func (v *NullableListInstancesResponse) Set(val *ListInstancesResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListInstancesResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListInstancesResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListInstancesResponse(val *ListInstancesResponse) *NullableListInstancesResponse {
- return &NullableListInstancesResponse{value: val, isSet: true}
-}
-
-func (v NullableListInstancesResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListInstancesResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_instances_response_test.go b/pkg/sqlserverflexalpha/model_list_instances_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_instances_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_roles_response.go b/pkg/sqlserverflexalpha/model_list_roles_response.go
deleted file mode 100644
index 102c3ced..00000000
--- a/pkg/sqlserverflexalpha/model_list_roles_response.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListRolesResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListRolesResponse{}
-
-/*
- types and functions for roles
-*/
-
-// isArray
-type ListRolesResponseGetRolesAttributeType = *[]UserRole
-type ListRolesResponseGetRolesArgType = []UserRole
-type ListRolesResponseGetRolesRetType = []UserRole
-
-func getListRolesResponseGetRolesAttributeTypeOk(arg ListRolesResponseGetRolesAttributeType) (ret ListRolesResponseGetRolesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListRolesResponseGetRolesAttributeType(arg *ListRolesResponseGetRolesAttributeType, val ListRolesResponseGetRolesRetType) {
- *arg = &val
-}
-
-// ListRolesResponse struct for ListRolesResponse
-type ListRolesResponse struct {
- // List of roles available for an instance.
- // REQUIRED
- Roles ListRolesResponseGetRolesAttributeType `json:"roles" required:"true"`
-}
-
-type _ListRolesResponse ListRolesResponse
-
-// NewListRolesResponse instantiates a new ListRolesResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListRolesResponse(roles ListRolesResponseGetRolesArgType) *ListRolesResponse {
- this := ListRolesResponse{}
- setListRolesResponseGetRolesAttributeType(&this.Roles, roles)
- return &this
-}
-
-// NewListRolesResponseWithDefaults instantiates a new ListRolesResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListRolesResponseWithDefaults() *ListRolesResponse {
- this := ListRolesResponse{}
- return &this
-}
-
-// GetRoles returns the Roles field value
-func (o *ListRolesResponse) GetRoles() (ret ListRolesResponseGetRolesRetType) {
- ret, _ = o.GetRolesOk()
- return ret
-}
-
-// GetRolesOk returns a tuple with the Roles field value
-// and a boolean to check if the value has been set.
-func (o *ListRolesResponse) GetRolesOk() (ret ListRolesResponseGetRolesRetType, ok bool) {
- return getListRolesResponseGetRolesAttributeTypeOk(o.Roles)
-}
-
-// SetRoles sets field value
-func (o *ListRolesResponse) SetRoles(v ListRolesResponseGetRolesRetType) {
- setListRolesResponseGetRolesAttributeType(&o.Roles, v)
-}
-
-func (o ListRolesResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListRolesResponseGetRolesAttributeTypeOk(o.Roles); ok {
- toSerialize["Roles"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListRolesResponse struct {
- value *ListRolesResponse
- isSet bool
-}
-
-func (v NullableListRolesResponse) Get() *ListRolesResponse {
- return v.value
-}
-
-func (v *NullableListRolesResponse) Set(val *ListRolesResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListRolesResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListRolesResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListRolesResponse(val *ListRolesResponse) *NullableListRolesResponse {
- return &NullableListRolesResponse{value: val, isSet: true}
-}
-
-func (v NullableListRolesResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListRolesResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_roles_response_test.go b/pkg/sqlserverflexalpha/model_list_roles_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_roles_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_user.go b/pkg/sqlserverflexalpha/model_list_user.go
deleted file mode 100644
index 0d7d6e2e..00000000
--- a/pkg/sqlserverflexalpha/model_list_user.go
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListUser type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListUser{}
-
-/*
- types and functions for id
-*/
-
-// isLong
-type ListUserGetIdAttributeType = *int64
-type ListUserGetIdArgType = int64
-type ListUserGetIdRetType = int64
-
-func getListUserGetIdAttributeTypeOk(arg ListUserGetIdAttributeType) (ret ListUserGetIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListUserGetIdAttributeType(arg *ListUserGetIdAttributeType, val ListUserGetIdRetType) {
- *arg = &val
-}
-
-/*
- types and functions for status
-*/
-
-// isNotNullableString
-type ListUserGetStatusAttributeType = *string
-
-func getListUserGetStatusAttributeTypeOk(arg ListUserGetStatusAttributeType) (ret ListUserGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListUserGetStatusAttributeType(arg *ListUserGetStatusAttributeType, val ListUserGetStatusRetType) {
- *arg = &val
-}
-
-type ListUserGetStatusArgType = string
-type ListUserGetStatusRetType = string
-
-/*
- types and functions for username
-*/
-
-// isNotNullableString
-type ListUserGetUsernameAttributeType = *string
-
-func getListUserGetUsernameAttributeTypeOk(arg ListUserGetUsernameAttributeType) (ret ListUserGetUsernameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListUserGetUsernameAttributeType(arg *ListUserGetUsernameAttributeType, val ListUserGetUsernameRetType) {
- *arg = &val
-}
-
-type ListUserGetUsernameArgType = string
-type ListUserGetUsernameRetType = string
-
-// ListUser struct for ListUser
-type ListUser struct {
- // The ID of the user.
- // REQUIRED
- Id ListUserGetIdAttributeType `json:"id" required:"true"`
- // The current status of the user.
- // REQUIRED
- Status ListUserGetStatusAttributeType `json:"status" required:"true"`
- // The name of the user.
- // REQUIRED
- Username ListUserGetUsernameAttributeType `json:"username" required:"true"`
-}
-
-type _ListUser ListUser
-
-// NewListUser instantiates a new ListUser object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListUser(id ListUserGetIdArgType, status ListUserGetStatusArgType, username ListUserGetUsernameArgType) *ListUser {
- this := ListUser{}
- setListUserGetIdAttributeType(&this.Id, id)
- setListUserGetStatusAttributeType(&this.Status, status)
- setListUserGetUsernameAttributeType(&this.Username, username)
- return &this
-}
-
-// NewListUserWithDefaults instantiates a new ListUser object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListUserWithDefaults() *ListUser {
- this := ListUser{}
- return &this
-}
-
-// GetId returns the Id field value
-func (o *ListUser) GetId() (ret ListUserGetIdRetType) {
- ret, _ = o.GetIdOk()
- return ret
-}
-
-// GetIdOk returns a tuple with the Id field value
-// and a boolean to check if the value has been set.
-func (o *ListUser) GetIdOk() (ret ListUserGetIdRetType, ok bool) {
- return getListUserGetIdAttributeTypeOk(o.Id)
-}
-
-// SetId sets field value
-func (o *ListUser) SetId(v ListUserGetIdRetType) {
- setListUserGetIdAttributeType(&o.Id, v)
-}
-
-// GetStatus returns the Status field value
-func (o *ListUser) GetStatus() (ret ListUserGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *ListUser) GetStatusOk() (ret ListUserGetStatusRetType, ok bool) {
- return getListUserGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *ListUser) SetStatus(v ListUserGetStatusRetType) {
- setListUserGetStatusAttributeType(&o.Status, v)
-}
-
-// GetUsername returns the Username field value
-func (o *ListUser) GetUsername() (ret ListUserGetUsernameRetType) {
- ret, _ = o.GetUsernameOk()
- return ret
-}
-
-// GetUsernameOk returns a tuple with the Username field value
-// and a boolean to check if the value has been set.
-func (o *ListUser) GetUsernameOk() (ret ListUserGetUsernameRetType, ok bool) {
- return getListUserGetUsernameAttributeTypeOk(o.Username)
-}
-
-// SetUsername sets field value
-func (o *ListUser) SetUsername(v ListUserGetUsernameRetType) {
- setListUserGetUsernameAttributeType(&o.Username, v)
-}
-
-func (o ListUser) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListUserGetIdAttributeTypeOk(o.Id); ok {
- toSerialize["Id"] = val
- }
- if val, ok := getListUserGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- if val, ok := getListUserGetUsernameAttributeTypeOk(o.Username); ok {
- toSerialize["Username"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListUser struct {
- value *ListUser
- isSet bool
-}
-
-func (v NullableListUser) Get() *ListUser {
- return v.value
-}
-
-func (v *NullableListUser) Set(val *ListUser) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListUser) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListUser) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListUser(val *ListUser) *NullableListUser {
- return &NullableListUser{value: val, isSet: true}
-}
-
-func (v NullableListUser) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListUser) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_user_response.go b/pkg/sqlserverflexalpha/model_list_user_response.go
deleted file mode 100644
index ad5f0c87..00000000
--- a/pkg/sqlserverflexalpha/model_list_user_response.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ListUserResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ListUserResponse{}
-
-/*
- types and functions for pagination
-*/
-
-// isModel
-type ListUserResponseGetPaginationAttributeType = *Pagination
-type ListUserResponseGetPaginationArgType = Pagination
-type ListUserResponseGetPaginationRetType = Pagination
-
-func getListUserResponseGetPaginationAttributeTypeOk(arg ListUserResponseGetPaginationAttributeType) (ret ListUserResponseGetPaginationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListUserResponseGetPaginationAttributeType(arg *ListUserResponseGetPaginationAttributeType, val ListUserResponseGetPaginationRetType) {
- *arg = &val
-}
-
-/*
- types and functions for users
-*/
-
-// isArray
-type ListUserResponseGetUsersAttributeType = *[]ListUser
-type ListUserResponseGetUsersArgType = []ListUser
-type ListUserResponseGetUsersRetType = []ListUser
-
-func getListUserResponseGetUsersAttributeTypeOk(arg ListUserResponseGetUsersAttributeType) (ret ListUserResponseGetUsersRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setListUserResponseGetUsersAttributeType(arg *ListUserResponseGetUsersAttributeType, val ListUserResponseGetUsersRetType) {
- *arg = &val
-}
-
-// ListUserResponse struct for ListUserResponse
-type ListUserResponse struct {
- // REQUIRED
- Pagination ListUserResponseGetPaginationAttributeType `json:"pagination" required:"true"`
- // List of all users inside an instance
- // REQUIRED
- Users ListUserResponseGetUsersAttributeType `json:"users" required:"true"`
-}
-
-type _ListUserResponse ListUserResponse
-
-// NewListUserResponse instantiates a new ListUserResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewListUserResponse(pagination ListUserResponseGetPaginationArgType, users ListUserResponseGetUsersArgType) *ListUserResponse {
- this := ListUserResponse{}
- setListUserResponseGetPaginationAttributeType(&this.Pagination, pagination)
- setListUserResponseGetUsersAttributeType(&this.Users, users)
- return &this
-}
-
-// NewListUserResponseWithDefaults instantiates a new ListUserResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewListUserResponseWithDefaults() *ListUserResponse {
- this := ListUserResponse{}
- return &this
-}
-
-// GetPagination returns the Pagination field value
-func (o *ListUserResponse) GetPagination() (ret ListUserResponseGetPaginationRetType) {
- ret, _ = o.GetPaginationOk()
- return ret
-}
-
-// GetPaginationOk returns a tuple with the Pagination field value
-// and a boolean to check if the value has been set.
-func (o *ListUserResponse) GetPaginationOk() (ret ListUserResponseGetPaginationRetType, ok bool) {
- return getListUserResponseGetPaginationAttributeTypeOk(o.Pagination)
-}
-
-// SetPagination sets field value
-func (o *ListUserResponse) SetPagination(v ListUserResponseGetPaginationRetType) {
- setListUserResponseGetPaginationAttributeType(&o.Pagination, v)
-}
-
-// GetUsers returns the Users field value
-func (o *ListUserResponse) GetUsers() (ret ListUserResponseGetUsersRetType) {
- ret, _ = o.GetUsersOk()
- return ret
-}
-
-// GetUsersOk returns a tuple with the Users field value
-// and a boolean to check if the value has been set.
-func (o *ListUserResponse) GetUsersOk() (ret ListUserResponseGetUsersRetType, ok bool) {
- return getListUserResponseGetUsersAttributeTypeOk(o.Users)
-}
-
-// SetUsers sets field value
-func (o *ListUserResponse) SetUsers(v ListUserResponseGetUsersRetType) {
- setListUserResponseGetUsersAttributeType(&o.Users, v)
-}
-
-func (o ListUserResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getListUserResponseGetPaginationAttributeTypeOk(o.Pagination); ok {
- toSerialize["Pagination"] = val
- }
- if val, ok := getListUserResponseGetUsersAttributeTypeOk(o.Users); ok {
- toSerialize["Users"] = val
- }
- return toSerialize, nil
-}
-
-type NullableListUserResponse struct {
- value *ListUserResponse
- isSet bool
-}
-
-func (v NullableListUserResponse) Get() *ListUserResponse {
- return v.value
-}
-
-func (v *NullableListUserResponse) Set(val *ListUserResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableListUserResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableListUserResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableListUserResponse(val *ListUserResponse) *NullableListUserResponse {
- return &NullableListUserResponse{value: val, isSet: true}
-}
-
-func (v NullableListUserResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableListUserResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_list_user_response_test.go b/pkg/sqlserverflexalpha/model_list_user_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_user_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_list_user_test.go b/pkg/sqlserverflexalpha/model_list_user_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_list_user_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_pagination.go b/pkg/sqlserverflexalpha/model_pagination.go
deleted file mode 100644
index 1992145d..00000000
--- a/pkg/sqlserverflexalpha/model_pagination.go
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the Pagination type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &Pagination{}
-
-/*
- types and functions for page
-*/
-
-// isLong
-type PaginationGetPageAttributeType = *int64
-type PaginationGetPageArgType = int64
-type PaginationGetPageRetType = int64
-
-func getPaginationGetPageAttributeTypeOk(arg PaginationGetPageAttributeType) (ret PaginationGetPageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPaginationGetPageAttributeType(arg *PaginationGetPageAttributeType, val PaginationGetPageRetType) {
- *arg = &val
-}
-
-/*
- types and functions for size
-*/
-
-// isLong
-type PaginationGetSizeAttributeType = *int64
-type PaginationGetSizeArgType = int64
-type PaginationGetSizeRetType = int64
-
-func getPaginationGetSizeAttributeTypeOk(arg PaginationGetSizeAttributeType) (ret PaginationGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPaginationGetSizeAttributeType(arg *PaginationGetSizeAttributeType, val PaginationGetSizeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for sort
-*/
-
-// isNotNullableString
-type PaginationGetSortAttributeType = *string
-
-func getPaginationGetSortAttributeTypeOk(arg PaginationGetSortAttributeType) (ret PaginationGetSortRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPaginationGetSortAttributeType(arg *PaginationGetSortAttributeType, val PaginationGetSortRetType) {
- *arg = &val
-}
-
-type PaginationGetSortArgType = string
-type PaginationGetSortRetType = string
-
-/*
- types and functions for totalPages
-*/
-
-// isLong
-type PaginationGetTotalPagesAttributeType = *int64
-type PaginationGetTotalPagesArgType = int64
-type PaginationGetTotalPagesRetType = int64
-
-func getPaginationGetTotalPagesAttributeTypeOk(arg PaginationGetTotalPagesAttributeType) (ret PaginationGetTotalPagesRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPaginationGetTotalPagesAttributeType(arg *PaginationGetTotalPagesAttributeType, val PaginationGetTotalPagesRetType) {
- *arg = &val
-}
-
-/*
- types and functions for totalRows
-*/
-
-// isLong
-type PaginationGetTotalRowsAttributeType = *int64
-type PaginationGetTotalRowsArgType = int64
-type PaginationGetTotalRowsRetType = int64
-
-func getPaginationGetTotalRowsAttributeTypeOk(arg PaginationGetTotalRowsAttributeType) (ret PaginationGetTotalRowsRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setPaginationGetTotalRowsAttributeType(arg *PaginationGetTotalRowsAttributeType, val PaginationGetTotalRowsRetType) {
- *arg = &val
-}
-
-// Pagination struct for Pagination
-type Pagination struct {
- // REQUIRED
- Page PaginationGetPageAttributeType `json:"page" required:"true" validate:"required"`
- // REQUIRED
- Size PaginationGetSizeAttributeType `json:"size" required:"true" validate:"required"`
- // REQUIRED
- Sort PaginationGetSortAttributeType `json:"sort" required:"true" validate:"required"`
- // REQUIRED
- TotalPages PaginationGetTotalPagesAttributeType `json:"totalPages" required:"true" validate:"required"`
- // REQUIRED
- TotalRows PaginationGetTotalRowsAttributeType `json:"totalRows" required:"true" validate:"required"`
-}
-
-type _Pagination Pagination
-
-// NewPagination instantiates a new Pagination object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewPagination(page PaginationGetPageArgType, size PaginationGetSizeArgType, sort PaginationGetSortArgType, totalPages PaginationGetTotalPagesArgType, totalRows PaginationGetTotalRowsArgType) *Pagination {
- this := Pagination{}
- setPaginationGetPageAttributeType(&this.Page, page)
- setPaginationGetSizeAttributeType(&this.Size, size)
- setPaginationGetSortAttributeType(&this.Sort, sort)
- setPaginationGetTotalPagesAttributeType(&this.TotalPages, totalPages)
- setPaginationGetTotalRowsAttributeType(&this.TotalRows, totalRows)
- return &this
-}
-
-// NewPaginationWithDefaults instantiates a new Pagination object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewPaginationWithDefaults() *Pagination {
- this := Pagination{}
- return &this
-}
-
-// GetPage returns the Page field value
-func (o *Pagination) GetPage() (ret PaginationGetPageRetType) {
- ret, _ = o.GetPageOk()
- return ret
-}
-
-// GetPageOk returns a tuple with the Page field value
-// and a boolean to check if the value has been set.
-func (o *Pagination) GetPageOk() (ret PaginationGetPageRetType, ok bool) {
- return getPaginationGetPageAttributeTypeOk(o.Page)
-}
-
-// SetPage sets field value
-func (o *Pagination) SetPage(v PaginationGetPageRetType) {
- setPaginationGetPageAttributeType(&o.Page, v)
-}
-
-// GetSize returns the Size field value
-func (o *Pagination) GetSize() (ret PaginationGetSizeRetType) {
- ret, _ = o.GetSizeOk()
- return ret
-}
-
-// GetSizeOk returns a tuple with the Size field value
-// and a boolean to check if the value has been set.
-func (o *Pagination) GetSizeOk() (ret PaginationGetSizeRetType, ok bool) {
- return getPaginationGetSizeAttributeTypeOk(o.Size)
-}
-
-// SetSize sets field value
-func (o *Pagination) SetSize(v PaginationGetSizeRetType) {
- setPaginationGetSizeAttributeType(&o.Size, v)
-}
-
-// GetSort returns the Sort field value
-func (o *Pagination) GetSort() (ret PaginationGetSortRetType) {
- ret, _ = o.GetSortOk()
- return ret
-}
-
-// GetSortOk returns a tuple with the Sort field value
-// and a boolean to check if the value has been set.
-func (o *Pagination) GetSortOk() (ret PaginationGetSortRetType, ok bool) {
- return getPaginationGetSortAttributeTypeOk(o.Sort)
-}
-
-// SetSort sets field value
-func (o *Pagination) SetSort(v PaginationGetSortRetType) {
- setPaginationGetSortAttributeType(&o.Sort, v)
-}
-
-// GetTotalPages returns the TotalPages field value
-func (o *Pagination) GetTotalPages() (ret PaginationGetTotalPagesRetType) {
- ret, _ = o.GetTotalPagesOk()
- return ret
-}
-
-// GetTotalPagesOk returns a tuple with the TotalPages field value
-// and a boolean to check if the value has been set.
-func (o *Pagination) GetTotalPagesOk() (ret PaginationGetTotalPagesRetType, ok bool) {
- return getPaginationGetTotalPagesAttributeTypeOk(o.TotalPages)
-}
-
-// SetTotalPages sets field value
-func (o *Pagination) SetTotalPages(v PaginationGetTotalPagesRetType) {
- setPaginationGetTotalPagesAttributeType(&o.TotalPages, v)
-}
-
-// GetTotalRows returns the TotalRows field value
-func (o *Pagination) GetTotalRows() (ret PaginationGetTotalRowsRetType) {
- ret, _ = o.GetTotalRowsOk()
- return ret
-}
-
-// GetTotalRowsOk returns a tuple with the TotalRows field value
-// and a boolean to check if the value has been set.
-func (o *Pagination) GetTotalRowsOk() (ret PaginationGetTotalRowsRetType, ok bool) {
- return getPaginationGetTotalRowsAttributeTypeOk(o.TotalRows)
-}
-
-// SetTotalRows sets field value
-func (o *Pagination) SetTotalRows(v PaginationGetTotalRowsRetType) {
- setPaginationGetTotalRowsAttributeType(&o.TotalRows, v)
-}
-
-func (o Pagination) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getPaginationGetPageAttributeTypeOk(o.Page); ok {
- toSerialize["Page"] = val
- }
- if val, ok := getPaginationGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- if val, ok := getPaginationGetSortAttributeTypeOk(o.Sort); ok {
- toSerialize["Sort"] = val
- }
- if val, ok := getPaginationGetTotalPagesAttributeTypeOk(o.TotalPages); ok {
- toSerialize["TotalPages"] = val
- }
- if val, ok := getPaginationGetTotalRowsAttributeTypeOk(o.TotalRows); ok {
- toSerialize["TotalRows"] = val
- }
- return toSerialize, nil
-}
-
-type NullablePagination struct {
- value *Pagination
- isSet bool
-}
-
-func (v NullablePagination) Get() *Pagination {
- return v.value
-}
-
-func (v *NullablePagination) Set(val *Pagination) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullablePagination) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullablePagination) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullablePagination(val *Pagination) *NullablePagination {
- return &NullablePagination{value: val, isSet: true}
-}
-
-func (v NullablePagination) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullablePagination) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_pagination_test.go b/pkg/sqlserverflexalpha/model_pagination_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_pagination_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_protect_instance_request_payload.go b/pkg/sqlserverflexalpha/model_protect_instance_request_payload.go
deleted file mode 100644
index 63d2de8f..00000000
--- a/pkg/sqlserverflexalpha/model_protect_instance_request_payload.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ProtectInstanceRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ProtectInstanceRequestPayload{}
-
-/*
- types and functions for isDeletable
-*/
-
-// isBoolean
-type ProtectInstanceRequestPayloadgetIsDeletableAttributeType = *bool
-type ProtectInstanceRequestPayloadgetIsDeletableArgType = bool
-type ProtectInstanceRequestPayloadgetIsDeletableRetType = bool
-
-func getProtectInstanceRequestPayloadgetIsDeletableAttributeTypeOk(arg ProtectInstanceRequestPayloadgetIsDeletableAttributeType) (ret ProtectInstanceRequestPayloadgetIsDeletableRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setProtectInstanceRequestPayloadgetIsDeletableAttributeType(arg *ProtectInstanceRequestPayloadgetIsDeletableAttributeType, val ProtectInstanceRequestPayloadgetIsDeletableRetType) {
- *arg = &val
-}
-
-// ProtectInstanceRequestPayload struct for ProtectInstanceRequestPayload
-type ProtectInstanceRequestPayload struct {
- // Protect instance from deletion.
- // REQUIRED
- IsDeletable ProtectInstanceRequestPayloadgetIsDeletableAttributeType `json:"isDeletable" required:"true"`
-}
-
-type _ProtectInstanceRequestPayload ProtectInstanceRequestPayload
-
-// NewProtectInstanceRequestPayload instantiates a new ProtectInstanceRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewProtectInstanceRequestPayload(isDeletable ProtectInstanceRequestPayloadgetIsDeletableArgType) *ProtectInstanceRequestPayload {
- this := ProtectInstanceRequestPayload{}
- setProtectInstanceRequestPayloadgetIsDeletableAttributeType(&this.IsDeletable, isDeletable)
- return &this
-}
-
-// NewProtectInstanceRequestPayloadWithDefaults instantiates a new ProtectInstanceRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewProtectInstanceRequestPayloadWithDefaults() *ProtectInstanceRequestPayload {
- this := ProtectInstanceRequestPayload{}
- return &this
-}
-
-// GetIsDeletable returns the IsDeletable field value
-func (o *ProtectInstanceRequestPayload) GetIsDeletable() (ret ProtectInstanceRequestPayloadgetIsDeletableRetType) {
- ret, _ = o.GetIsDeletableOk()
- return ret
-}
-
-// GetIsDeletableOk returns a tuple with the IsDeletable field value
-// and a boolean to check if the value has been set.
-func (o *ProtectInstanceRequestPayload) GetIsDeletableOk() (ret ProtectInstanceRequestPayloadgetIsDeletableRetType, ok bool) {
- return getProtectInstanceRequestPayloadgetIsDeletableAttributeTypeOk(o.IsDeletable)
-}
-
-// SetIsDeletable sets field value
-func (o *ProtectInstanceRequestPayload) SetIsDeletable(v ProtectInstanceRequestPayloadgetIsDeletableRetType) {
- setProtectInstanceRequestPayloadgetIsDeletableAttributeType(&o.IsDeletable, v)
-}
-
-func (o ProtectInstanceRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getProtectInstanceRequestPayloadgetIsDeletableAttributeTypeOk(o.IsDeletable); ok {
- toSerialize["IsDeletable"] = val
- }
- return toSerialize, nil
-}
-
-type NullableProtectInstanceRequestPayload struct {
- value *ProtectInstanceRequestPayload
- isSet bool
-}
-
-func (v NullableProtectInstanceRequestPayload) Get() *ProtectInstanceRequestPayload {
- return v.value
-}
-
-func (v *NullableProtectInstanceRequestPayload) Set(val *ProtectInstanceRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableProtectInstanceRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableProtectInstanceRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableProtectInstanceRequestPayload(val *ProtectInstanceRequestPayload) *NullableProtectInstanceRequestPayload {
- return &NullableProtectInstanceRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableProtectInstanceRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableProtectInstanceRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_protect_instance_request_payload_test.go b/pkg/sqlserverflexalpha/model_protect_instance_request_payload_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_protect_instance_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_protect_instance_response.go b/pkg/sqlserverflexalpha/model_protect_instance_response.go
deleted file mode 100644
index ddbe6ea8..00000000
--- a/pkg/sqlserverflexalpha/model_protect_instance_response.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ProtectInstanceResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ProtectInstanceResponse{}
-
-/*
- types and functions for isDeletable
-*/
-
-// isBoolean
-type ProtectInstanceResponsegetIsDeletableAttributeType = *bool
-type ProtectInstanceResponsegetIsDeletableArgType = bool
-type ProtectInstanceResponsegetIsDeletableRetType = bool
-
-func getProtectInstanceResponsegetIsDeletableAttributeTypeOk(arg ProtectInstanceResponsegetIsDeletableAttributeType) (ret ProtectInstanceResponsegetIsDeletableRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setProtectInstanceResponsegetIsDeletableAttributeType(arg *ProtectInstanceResponsegetIsDeletableAttributeType, val ProtectInstanceResponsegetIsDeletableRetType) {
- *arg = &val
-}
-
-// ProtectInstanceResponse struct for ProtectInstanceResponse
-type ProtectInstanceResponse struct {
- // Protect instance from deletion.
- // REQUIRED
- IsDeletable ProtectInstanceResponsegetIsDeletableAttributeType `json:"isDeletable" required:"true"`
-}
-
-type _ProtectInstanceResponse ProtectInstanceResponse
-
-// NewProtectInstanceResponse instantiates a new ProtectInstanceResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewProtectInstanceResponse(isDeletable ProtectInstanceResponsegetIsDeletableArgType) *ProtectInstanceResponse {
- this := ProtectInstanceResponse{}
- setProtectInstanceResponsegetIsDeletableAttributeType(&this.IsDeletable, isDeletable)
- return &this
-}
-
-// NewProtectInstanceResponseWithDefaults instantiates a new ProtectInstanceResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewProtectInstanceResponseWithDefaults() *ProtectInstanceResponse {
- this := ProtectInstanceResponse{}
- return &this
-}
-
-// GetIsDeletable returns the IsDeletable field value
-func (o *ProtectInstanceResponse) GetIsDeletable() (ret ProtectInstanceResponsegetIsDeletableRetType) {
- ret, _ = o.GetIsDeletableOk()
- return ret
-}
-
-// GetIsDeletableOk returns a tuple with the IsDeletable field value
-// and a boolean to check if the value has been set.
-func (o *ProtectInstanceResponse) GetIsDeletableOk() (ret ProtectInstanceResponsegetIsDeletableRetType, ok bool) {
- return getProtectInstanceResponsegetIsDeletableAttributeTypeOk(o.IsDeletable)
-}
-
-// SetIsDeletable sets field value
-func (o *ProtectInstanceResponse) SetIsDeletable(v ProtectInstanceResponsegetIsDeletableRetType) {
- setProtectInstanceResponsegetIsDeletableAttributeType(&o.IsDeletable, v)
-}
-
-func (o ProtectInstanceResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getProtectInstanceResponsegetIsDeletableAttributeTypeOk(o.IsDeletable); ok {
- toSerialize["IsDeletable"] = val
- }
- return toSerialize, nil
-}
-
-type NullableProtectInstanceResponse struct {
- value *ProtectInstanceResponse
- isSet bool
-}
-
-func (v NullableProtectInstanceResponse) Get() *ProtectInstanceResponse {
- return v.value
-}
-
-func (v *NullableProtectInstanceResponse) Set(val *ProtectInstanceResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableProtectInstanceResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableProtectInstanceResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableProtectInstanceResponse(val *ProtectInstanceResponse) *NullableProtectInstanceResponse {
- return &NullableProtectInstanceResponse{value: val, isSet: true}
-}
-
-func (v NullableProtectInstanceResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableProtectInstanceResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_protect_instance_response_test.go b/pkg/sqlserverflexalpha/model_protect_instance_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_protect_instance_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_replicas.go b/pkg/sqlserverflexalpha/model_replicas.go
deleted file mode 100644
index 7871b48c..00000000
--- a/pkg/sqlserverflexalpha/model_replicas.go
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// Replicas How many replicas the instance should have.
-type Replicas int32
-
-// List of replicas
-const (
- REPLICAS__1 Replicas = 1
- REPLICAS__3 Replicas = 3
-)
-
-// All allowed values of Replicas enum
-var AllowedReplicasEnumValues = []Replicas{
- 1,
- 3,
-}
-
-func (v *Replicas) UnmarshalJSON(src []byte) error {
- var value int32
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue int32
- if value == zeroValue {
- return nil
- }
- enumTypeValue := Replicas(value)
- for _, existing := range AllowedReplicasEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid Replicas", value)
-}
-
-// NewReplicasFromValue returns a pointer to a valid Replicas
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewReplicasFromValue(v int32) (*Replicas, error) {
- ev := Replicas(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for Replicas: valid values are %v", v, AllowedReplicasEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v Replicas) IsValid() bool {
- for _, existing := range AllowedReplicasEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to replicas value
-func (v Replicas) Ptr() *Replicas {
- return &v
-}
-
-type NullableReplicas struct {
- value *Replicas
- isSet bool
-}
-
-func (v NullableReplicas) Get() *Replicas {
- return v.value
-}
-
-func (v *NullableReplicas) Set(val *Replicas) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableReplicas) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableReplicas) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableReplicas(val *Replicas) *NullableReplicas {
- return &NullableReplicas{value: val, isSet: true}
-}
-
-func (v NullableReplicas) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableReplicas) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_replicas_opt.go b/pkg/sqlserverflexalpha/model_replicas_opt.go
deleted file mode 100644
index 7a8b311b..00000000
--- a/pkg/sqlserverflexalpha/model_replicas_opt.go
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// ReplicasOpt How many replicas the instance should have.
-type ReplicasOpt int32
-
-// List of replicas.opt
-const (
- REPLICASOPT__1 ReplicasOpt = 1
- REPLICASOPT__3 ReplicasOpt = 3
-)
-
-// All allowed values of ReplicasOpt enum
-var AllowedReplicasOptEnumValues = []ReplicasOpt{
- 1,
- 3,
-}
-
-func (v *ReplicasOpt) UnmarshalJSON(src []byte) error {
- var value int32
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue int32
- if value == zeroValue {
- return nil
- }
- enumTypeValue := ReplicasOpt(value)
- for _, existing := range AllowedReplicasOptEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid ReplicasOpt", value)
-}
-
-// NewReplicasOptFromValue returns a pointer to a valid ReplicasOpt
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewReplicasOptFromValue(v int32) (*ReplicasOpt, error) {
- ev := ReplicasOpt(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for ReplicasOpt: valid values are %v", v, AllowedReplicasOptEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v ReplicasOpt) IsValid() bool {
- for _, existing := range AllowedReplicasOptEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to replicas.opt value
-func (v ReplicasOpt) Ptr() *ReplicasOpt {
- return &v
-}
-
-type NullableReplicasOpt struct {
- value *ReplicasOpt
- isSet bool
-}
-
-func (v NullableReplicasOpt) Get() *ReplicasOpt {
- return v.value
-}
-
-func (v *NullableReplicasOpt) Set(val *ReplicasOpt) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableReplicasOpt) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableReplicasOpt) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableReplicasOpt(val *ReplicasOpt) *NullableReplicasOpt {
- return &NullableReplicasOpt{value: val, isSet: true}
-}
-
-func (v NullableReplicasOpt) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableReplicasOpt) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_replicas_opt_test.go b/pkg/sqlserverflexalpha/model_replicas_opt_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_replicas_opt_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_replicas_test.go b/pkg/sqlserverflexalpha/model_replicas_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_replicas_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_reset_user_response.go b/pkg/sqlserverflexalpha/model_reset_user_response.go
deleted file mode 100644
index be56cc26..00000000
--- a/pkg/sqlserverflexalpha/model_reset_user_response.go
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ResetUserResponse type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ResetUserResponse{}
-
-/*
- types and functions for password
-*/
-
-// isNotNullableString
-type ResetUserResponseGetPasswordAttributeType = *string
-
-func getResetUserResponseGetPasswordAttributeTypeOk(arg ResetUserResponseGetPasswordAttributeType) (ret ResetUserResponseGetPasswordRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setResetUserResponseGetPasswordAttributeType(arg *ResetUserResponseGetPasswordAttributeType, val ResetUserResponseGetPasswordRetType) {
- *arg = &val
-}
-
-type ResetUserResponseGetPasswordArgType = string
-type ResetUserResponseGetPasswordRetType = string
-
-/*
- types and functions for status
-*/
-
-// isNotNullableString
-type ResetUserResponseGetStatusAttributeType = *string
-
-func getResetUserResponseGetStatusAttributeTypeOk(arg ResetUserResponseGetStatusAttributeType) (ret ResetUserResponseGetStatusRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setResetUserResponseGetStatusAttributeType(arg *ResetUserResponseGetStatusAttributeType, val ResetUserResponseGetStatusRetType) {
- *arg = &val
-}
-
-type ResetUserResponseGetStatusArgType = string
-type ResetUserResponseGetStatusRetType = string
-
-/*
- types and functions for uri
-*/
-
-// isNotNullableString
-type ResetUserResponseGetUriAttributeType = *string
-
-func getResetUserResponseGetUriAttributeTypeOk(arg ResetUserResponseGetUriAttributeType) (ret ResetUserResponseGetUriRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setResetUserResponseGetUriAttributeType(arg *ResetUserResponseGetUriAttributeType, val ResetUserResponseGetUriRetType) {
- *arg = &val
-}
-
-type ResetUserResponseGetUriArgType = string
-type ResetUserResponseGetUriRetType = string
-
-/*
- types and functions for username
-*/
-
-// isNotNullableString
-type ResetUserResponseGetUsernameAttributeType = *string
-
-func getResetUserResponseGetUsernameAttributeTypeOk(arg ResetUserResponseGetUsernameAttributeType) (ret ResetUserResponseGetUsernameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setResetUserResponseGetUsernameAttributeType(arg *ResetUserResponseGetUsernameAttributeType, val ResetUserResponseGetUsernameRetType) {
- *arg = &val
-}
-
-type ResetUserResponseGetUsernameArgType = string
-type ResetUserResponseGetUsernameRetType = string
-
-// ResetUserResponse struct for ResetUserResponse
-type ResetUserResponse struct {
- // The password for the user.
- // REQUIRED
- Password ResetUserResponseGetPasswordAttributeType `json:"password" required:"true"`
- // The current status of the user.
- // REQUIRED
- Status ResetUserResponseGetStatusAttributeType `json:"status" required:"true"`
- // The connection string for the user to the instance.
- // REQUIRED
- Uri ResetUserResponseGetUriAttributeType `json:"uri" required:"true"`
- // The name of the user.
- // REQUIRED
- Username ResetUserResponseGetUsernameAttributeType `json:"username" required:"true"`
-}
-
-type _ResetUserResponse ResetUserResponse
-
-// NewResetUserResponse instantiates a new ResetUserResponse object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewResetUserResponse(password ResetUserResponseGetPasswordArgType, status ResetUserResponseGetStatusArgType, uri ResetUserResponseGetUriArgType, username ResetUserResponseGetUsernameArgType) *ResetUserResponse {
- this := ResetUserResponse{}
- setResetUserResponseGetPasswordAttributeType(&this.Password, password)
- setResetUserResponseGetStatusAttributeType(&this.Status, status)
- setResetUserResponseGetUriAttributeType(&this.Uri, uri)
- setResetUserResponseGetUsernameAttributeType(&this.Username, username)
- return &this
-}
-
-// NewResetUserResponseWithDefaults instantiates a new ResetUserResponse object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewResetUserResponseWithDefaults() *ResetUserResponse {
- this := ResetUserResponse{}
- return &this
-}
-
-// GetPassword returns the Password field value
-func (o *ResetUserResponse) GetPassword() (ret ResetUserResponseGetPasswordRetType) {
- ret, _ = o.GetPasswordOk()
- return ret
-}
-
-// GetPasswordOk returns a tuple with the Password field value
-// and a boolean to check if the value has been set.
-func (o *ResetUserResponse) GetPasswordOk() (ret ResetUserResponseGetPasswordRetType, ok bool) {
- return getResetUserResponseGetPasswordAttributeTypeOk(o.Password)
-}
-
-// SetPassword sets field value
-func (o *ResetUserResponse) SetPassword(v ResetUserResponseGetPasswordRetType) {
- setResetUserResponseGetPasswordAttributeType(&o.Password, v)
-}
-
-// GetStatus returns the Status field value
-func (o *ResetUserResponse) GetStatus() (ret ResetUserResponseGetStatusRetType) {
- ret, _ = o.GetStatusOk()
- return ret
-}
-
-// GetStatusOk returns a tuple with the Status field value
-// and a boolean to check if the value has been set.
-func (o *ResetUserResponse) GetStatusOk() (ret ResetUserResponseGetStatusRetType, ok bool) {
- return getResetUserResponseGetStatusAttributeTypeOk(o.Status)
-}
-
-// SetStatus sets field value
-func (o *ResetUserResponse) SetStatus(v ResetUserResponseGetStatusRetType) {
- setResetUserResponseGetStatusAttributeType(&o.Status, v)
-}
-
-// GetUri returns the Uri field value
-func (o *ResetUserResponse) GetUri() (ret ResetUserResponseGetUriRetType) {
- ret, _ = o.GetUriOk()
- return ret
-}
-
-// GetUriOk returns a tuple with the Uri field value
-// and a boolean to check if the value has been set.
-func (o *ResetUserResponse) GetUriOk() (ret ResetUserResponseGetUriRetType, ok bool) {
- return getResetUserResponseGetUriAttributeTypeOk(o.Uri)
-}
-
-// SetUri sets field value
-func (o *ResetUserResponse) SetUri(v ResetUserResponseGetUriRetType) {
- setResetUserResponseGetUriAttributeType(&o.Uri, v)
-}
-
-// GetUsername returns the Username field value
-func (o *ResetUserResponse) GetUsername() (ret ResetUserResponseGetUsernameRetType) {
- ret, _ = o.GetUsernameOk()
- return ret
-}
-
-// GetUsernameOk returns a tuple with the Username field value
-// and a boolean to check if the value has been set.
-func (o *ResetUserResponse) GetUsernameOk() (ret ResetUserResponseGetUsernameRetType, ok bool) {
- return getResetUserResponseGetUsernameAttributeTypeOk(o.Username)
-}
-
-// SetUsername sets field value
-func (o *ResetUserResponse) SetUsername(v ResetUserResponseGetUsernameRetType) {
- setResetUserResponseGetUsernameAttributeType(&o.Username, v)
-}
-
-func (o ResetUserResponse) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getResetUserResponseGetPasswordAttributeTypeOk(o.Password); ok {
- toSerialize["Password"] = val
- }
- if val, ok := getResetUserResponseGetStatusAttributeTypeOk(o.Status); ok {
- toSerialize["Status"] = val
- }
- if val, ok := getResetUserResponseGetUriAttributeTypeOk(o.Uri); ok {
- toSerialize["Uri"] = val
- }
- if val, ok := getResetUserResponseGetUsernameAttributeTypeOk(o.Username); ok {
- toSerialize["Username"] = val
- }
- return toSerialize, nil
-}
-
-type NullableResetUserResponse struct {
- value *ResetUserResponse
- isSet bool
-}
-
-func (v NullableResetUserResponse) Get() *ResetUserResponse {
- return v.value
-}
-
-func (v *NullableResetUserResponse) Set(val *ResetUserResponse) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableResetUserResponse) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableResetUserResponse) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableResetUserResponse(val *ResetUserResponse) *NullableResetUserResponse {
- return &NullableResetUserResponse{value: val, isSet: true}
-}
-
-func (v NullableResetUserResponse) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableResetUserResponse) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_reset_user_response_test.go b/pkg/sqlserverflexalpha/model_reset_user_response_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_reset_user_response_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_status.go b/pkg/sqlserverflexalpha/model_status.go
deleted file mode 100644
index fb85da4a..00000000
--- a/pkg/sqlserverflexalpha/model_status.go
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// Status the model 'Status'
-type Status string
-
-// List of status
-const (
- STATUS_READY Status = "READY"
- STATUS_PENDING Status = "PENDING"
- STATUS_PROGRESSING Status = "PROGRESSING"
- STATUS_FAILURE Status = "FAILURE"
- STATUS_UNKNOWN Status = "UNKNOWN"
- STATUS_TERMINATING Status = "TERMINATING"
-)
-
-// All allowed values of Status enum
-var AllowedStatusEnumValues = []Status{
- "READY",
- "PENDING",
- "PROGRESSING",
- "FAILURE",
- "UNKNOWN",
- "TERMINATING",
-}
-
-func (v *Status) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := Status(value)
- for _, existing := range AllowedStatusEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid Status", value)
-}
-
-// NewStatusFromValue returns a pointer to a valid Status
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewStatusFromValue(v string) (*Status, error) {
- ev := Status(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for Status: valid values are %v", v, AllowedStatusEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v Status) IsValid() bool {
- for _, existing := range AllowedStatusEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to status value
-func (v Status) Ptr() *Status {
- return &v
-}
-
-type NullableStatus struct {
- value *Status
- isSet bool
-}
-
-func (v NullableStatus) Get() *Status {
- return v.value
-}
-
-func (v *NullableStatus) Set(val *Status) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableStatus) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableStatus) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableStatus(val *Status) *NullableStatus {
- return &NullableStatus{value: val, isSet: true}
-}
-
-func (v NullableStatus) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableStatus) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_status_test.go b/pkg/sqlserverflexalpha/model_status_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_status_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_storage.go b/pkg/sqlserverflexalpha/model_storage.go
deleted file mode 100644
index a5dd0f51..00000000
--- a/pkg/sqlserverflexalpha/model_storage.go
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the Storage type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &Storage{}
-
-/*
- types and functions for class
-*/
-
-// isNotNullableString
-type StorageGetClassAttributeType = *string
-
-func getStorageGetClassAttributeTypeOk(arg StorageGetClassAttributeType) (ret StorageGetClassRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setStorageGetClassAttributeType(arg *StorageGetClassAttributeType, val StorageGetClassRetType) {
- *arg = &val
-}
-
-type StorageGetClassArgType = string
-type StorageGetClassRetType = string
-
-/*
- types and functions for size
-*/
-
-// isLong
-type StorageGetSizeAttributeType = *int64
-type StorageGetSizeArgType = int64
-type StorageGetSizeRetType = int64
-
-func getStorageGetSizeAttributeTypeOk(arg StorageGetSizeAttributeType) (ret StorageGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setStorageGetSizeAttributeType(arg *StorageGetSizeAttributeType, val StorageGetSizeRetType) {
- *arg = &val
-}
-
-// Storage The object containing information about the storage size and class.
-type Storage struct {
- // The storage class for the storage.
- Class StorageGetClassAttributeType `json:"class,omitempty"`
- // The storage size in Gigabytes.
- Size StorageGetSizeAttributeType `json:"size,omitempty"`
-}
-
-// NewStorage instantiates a new Storage object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewStorage() *Storage {
- this := Storage{}
- return &this
-}
-
-// NewStorageWithDefaults instantiates a new Storage object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewStorageWithDefaults() *Storage {
- this := Storage{}
- return &this
-}
-
-// GetClass returns the Class field value if set, zero value otherwise.
-func (o *Storage) GetClass() (res StorageGetClassRetType) {
- res, _ = o.GetClassOk()
- return
-}
-
-// GetClassOk returns a tuple with the Class field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *Storage) GetClassOk() (ret StorageGetClassRetType, ok bool) {
- return getStorageGetClassAttributeTypeOk(o.Class)
-}
-
-// HasClass returns a boolean if a field has been set.
-func (o *Storage) HasClass() bool {
- _, ok := o.GetClassOk()
- return ok
-}
-
-// SetClass gets a reference to the given string and assigns it to the Class field.
-func (o *Storage) SetClass(v StorageGetClassRetType) {
- setStorageGetClassAttributeType(&o.Class, v)
-}
-
-// GetSize returns the Size field value if set, zero value otherwise.
-func (o *Storage) GetSize() (res StorageGetSizeRetType) {
- res, _ = o.GetSizeOk()
- return
-}
-
-// GetSizeOk returns a tuple with the Size field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *Storage) GetSizeOk() (ret StorageGetSizeRetType, ok bool) {
- return getStorageGetSizeAttributeTypeOk(o.Size)
-}
-
-// HasSize returns a boolean if a field has been set.
-func (o *Storage) HasSize() bool {
- _, ok := o.GetSizeOk()
- return ok
-}
-
-// SetSize gets a reference to the given int64 and assigns it to the Size field.
-func (o *Storage) SetSize(v StorageGetSizeRetType) {
- setStorageGetSizeAttributeType(&o.Size, v)
-}
-
-func (o Storage) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getStorageGetClassAttributeTypeOk(o.Class); ok {
- toSerialize["Class"] = val
- }
- if val, ok := getStorageGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- return toSerialize, nil
-}
-
-type NullableStorage struct {
- value *Storage
- isSet bool
-}
-
-func (v NullableStorage) Get() *Storage {
- return v.value
-}
-
-func (v *NullableStorage) Set(val *Storage) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableStorage) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableStorage) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableStorage(val *Storage) *NullableStorage {
- return &NullableStorage{value: val, isSet: true}
-}
-
-func (v NullableStorage) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableStorage) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_storage_create.go b/pkg/sqlserverflexalpha/model_storage_create.go
deleted file mode 100644
index 5b9031ea..00000000
--- a/pkg/sqlserverflexalpha/model_storage_create.go
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the StorageCreate type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &StorageCreate{}
-
-/*
- types and functions for class
-*/
-
-// isNotNullableString
-type StorageCreateGetClassAttributeType = *string
-
-func getStorageCreateGetClassAttributeTypeOk(arg StorageCreateGetClassAttributeType) (ret StorageCreateGetClassRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setStorageCreateGetClassAttributeType(arg *StorageCreateGetClassAttributeType, val StorageCreateGetClassRetType) {
- *arg = &val
-}
-
-type StorageCreateGetClassArgType = string
-type StorageCreateGetClassRetType = string
-
-/*
- types and functions for size
-*/
-
-// isLong
-type StorageCreateGetSizeAttributeType = *int64
-type StorageCreateGetSizeArgType = int64
-type StorageCreateGetSizeRetType = int64
-
-func getStorageCreateGetSizeAttributeTypeOk(arg StorageCreateGetSizeAttributeType) (ret StorageCreateGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setStorageCreateGetSizeAttributeType(arg *StorageCreateGetSizeAttributeType, val StorageCreateGetSizeRetType) {
- *arg = &val
-}
-
-// StorageCreate The object containing information about the storage size and class.
-type StorageCreate struct {
- // The storage class for the storage.
- // REQUIRED
- Class StorageCreateGetClassAttributeType `json:"class" required:"true"`
- // The storage size in Gigabytes.
- // REQUIRED
- Size StorageCreateGetSizeAttributeType `json:"size" required:"true"`
-}
-
-type _StorageCreate StorageCreate
-
-// NewStorageCreate instantiates a new StorageCreate object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewStorageCreate(class StorageCreateGetClassArgType, size StorageCreateGetSizeArgType) *StorageCreate {
- this := StorageCreate{}
- setStorageCreateGetClassAttributeType(&this.Class, class)
- setStorageCreateGetSizeAttributeType(&this.Size, size)
- return &this
-}
-
-// NewStorageCreateWithDefaults instantiates a new StorageCreate object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewStorageCreateWithDefaults() *StorageCreate {
- this := StorageCreate{}
- return &this
-}
-
-// GetClass returns the Class field value
-func (o *StorageCreate) GetClass() (ret StorageCreateGetClassRetType) {
- ret, _ = o.GetClassOk()
- return ret
-}
-
-// GetClassOk returns a tuple with the Class field value
-// and a boolean to check if the value has been set.
-func (o *StorageCreate) GetClassOk() (ret StorageCreateGetClassRetType, ok bool) {
- return getStorageCreateGetClassAttributeTypeOk(o.Class)
-}
-
-// SetClass sets field value
-func (o *StorageCreate) SetClass(v StorageCreateGetClassRetType) {
- setStorageCreateGetClassAttributeType(&o.Class, v)
-}
-
-// GetSize returns the Size field value
-func (o *StorageCreate) GetSize() (ret StorageCreateGetSizeRetType) {
- ret, _ = o.GetSizeOk()
- return ret
-}
-
-// GetSizeOk returns a tuple with the Size field value
-// and a boolean to check if the value has been set.
-func (o *StorageCreate) GetSizeOk() (ret StorageCreateGetSizeRetType, ok bool) {
- return getStorageCreateGetSizeAttributeTypeOk(o.Size)
-}
-
-// SetSize sets field value
-func (o *StorageCreate) SetSize(v StorageCreateGetSizeRetType) {
- setStorageCreateGetSizeAttributeType(&o.Size, v)
-}
-
-func (o StorageCreate) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getStorageCreateGetClassAttributeTypeOk(o.Class); ok {
- toSerialize["Class"] = val
- }
- if val, ok := getStorageCreateGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- return toSerialize, nil
-}
-
-type NullableStorageCreate struct {
- value *StorageCreate
- isSet bool
-}
-
-func (v NullableStorageCreate) Get() *StorageCreate {
- return v.value
-}
-
-func (v *NullableStorageCreate) Set(val *StorageCreate) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableStorageCreate) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableStorageCreate) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableStorageCreate(val *StorageCreate) *NullableStorageCreate {
- return &NullableStorageCreate{value: val, isSet: true}
-}
-
-func (v NullableStorageCreate) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableStorageCreate) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_storage_create_test.go b/pkg/sqlserverflexalpha/model_storage_create_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_storage_create_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_storage_test.go b/pkg/sqlserverflexalpha/model_storage_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_storage_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_storage_update.go b/pkg/sqlserverflexalpha/model_storage_update.go
deleted file mode 100644
index 05509b6c..00000000
--- a/pkg/sqlserverflexalpha/model_storage_update.go
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the StorageUpdate type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &StorageUpdate{}
-
-/*
- types and functions for size
-*/
-
-// isLong
-type StorageUpdateGetSizeAttributeType = *int64
-type StorageUpdateGetSizeArgType = int64
-type StorageUpdateGetSizeRetType = int64
-
-func getStorageUpdateGetSizeAttributeTypeOk(arg StorageUpdateGetSizeAttributeType) (ret StorageUpdateGetSizeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setStorageUpdateGetSizeAttributeType(arg *StorageUpdateGetSizeAttributeType, val StorageUpdateGetSizeRetType) {
- *arg = &val
-}
-
-// StorageUpdate The object containing information about the storage size and class.
-type StorageUpdate struct {
- // The storage size in Gigabytes.
- Size StorageUpdateGetSizeAttributeType `json:"size,omitempty"`
-}
-
-// NewStorageUpdate instantiates a new StorageUpdate object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewStorageUpdate() *StorageUpdate {
- this := StorageUpdate{}
- return &this
-}
-
-// NewStorageUpdateWithDefaults instantiates a new StorageUpdate object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewStorageUpdateWithDefaults() *StorageUpdate {
- this := StorageUpdate{}
- return &this
-}
-
-// GetSize returns the Size field value if set, zero value otherwise.
-func (o *StorageUpdate) GetSize() (res StorageUpdateGetSizeRetType) {
- res, _ = o.GetSizeOk()
- return
-}
-
-// GetSizeOk returns a tuple with the Size field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *StorageUpdate) GetSizeOk() (ret StorageUpdateGetSizeRetType, ok bool) {
- return getStorageUpdateGetSizeAttributeTypeOk(o.Size)
-}
-
-// HasSize returns a boolean if a field has been set.
-func (o *StorageUpdate) HasSize() bool {
- _, ok := o.GetSizeOk()
- return ok
-}
-
-// SetSize gets a reference to the given int64 and assigns it to the Size field.
-func (o *StorageUpdate) SetSize(v StorageUpdateGetSizeRetType) {
- setStorageUpdateGetSizeAttributeType(&o.Size, v)
-}
-
-func (o StorageUpdate) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getStorageUpdateGetSizeAttributeTypeOk(o.Size); ok {
- toSerialize["Size"] = val
- }
- return toSerialize, nil
-}
-
-type NullableStorageUpdate struct {
- value *StorageUpdate
- isSet bool
-}
-
-func (v NullableStorageUpdate) Get() *StorageUpdate {
- return v.value
-}
-
-func (v *NullableStorageUpdate) Set(val *StorageUpdate) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableStorageUpdate) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableStorageUpdate) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableStorageUpdate(val *StorageUpdate) *NullableStorageUpdate {
- return &NullableStorageUpdate{value: val, isSet: true}
-}
-
-func (v NullableStorageUpdate) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableStorageUpdate) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_storage_update_test.go b/pkg/sqlserverflexalpha/model_storage_update_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_storage_update_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_trigger_restore_request_payload.go b/pkg/sqlserverflexalpha/model_trigger_restore_request_payload.go
deleted file mode 100644
index 560d05ef..00000000
--- a/pkg/sqlserverflexalpha/model_trigger_restore_request_payload.go
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the TriggerRestoreRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &TriggerRestoreRequestPayload{}
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type TriggerRestoreRequestPayloadGetNameAttributeType = *string
-
-func getTriggerRestoreRequestPayloadGetNameAttributeTypeOk(arg TriggerRestoreRequestPayloadGetNameAttributeType) (ret TriggerRestoreRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setTriggerRestoreRequestPayloadGetNameAttributeType(arg *TriggerRestoreRequestPayloadGetNameAttributeType, val TriggerRestoreRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type TriggerRestoreRequestPayloadGetNameArgType = string
-type TriggerRestoreRequestPayloadGetNameRetType = string
-
-/*
- types and functions for restoreDateTime
-*/
-
-// isNotNullableString
-type TriggerRestoreRequestPayloadGetRestoreDateTimeAttributeType = *string
-
-func getTriggerRestoreRequestPayloadGetRestoreDateTimeAttributeTypeOk(arg TriggerRestoreRequestPayloadGetRestoreDateTimeAttributeType) (ret TriggerRestoreRequestPayloadGetRestoreDateTimeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setTriggerRestoreRequestPayloadGetRestoreDateTimeAttributeType(arg *TriggerRestoreRequestPayloadGetRestoreDateTimeAttributeType, val TriggerRestoreRequestPayloadGetRestoreDateTimeRetType) {
- *arg = &val
-}
-
-type TriggerRestoreRequestPayloadGetRestoreDateTimeArgType = string
-type TriggerRestoreRequestPayloadGetRestoreDateTimeRetType = string
-
-// TriggerRestoreRequestPayload struct for TriggerRestoreRequestPayload
-type TriggerRestoreRequestPayload struct {
- // The name of the database.
- // REQUIRED
- Name TriggerRestoreRequestPayloadGetNameAttributeType `json:"name" required:"true"`
- // the time for the restore it will be calculated between first backup and last backup
- // REQUIRED
- RestoreDateTime TriggerRestoreRequestPayloadGetRestoreDateTimeAttributeType `json:"restoreDateTime" required:"true"`
-}
-
-type _TriggerRestoreRequestPayload TriggerRestoreRequestPayload
-
-// NewTriggerRestoreRequestPayload instantiates a new TriggerRestoreRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewTriggerRestoreRequestPayload(name TriggerRestoreRequestPayloadGetNameArgType, restoreDateTime TriggerRestoreRequestPayloadGetRestoreDateTimeArgType) *TriggerRestoreRequestPayload {
- this := TriggerRestoreRequestPayload{}
- setTriggerRestoreRequestPayloadGetNameAttributeType(&this.Name, name)
- setTriggerRestoreRequestPayloadGetRestoreDateTimeAttributeType(&this.RestoreDateTime, restoreDateTime)
- return &this
-}
-
-// NewTriggerRestoreRequestPayloadWithDefaults instantiates a new TriggerRestoreRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewTriggerRestoreRequestPayloadWithDefaults() *TriggerRestoreRequestPayload {
- this := TriggerRestoreRequestPayload{}
- return &this
-}
-
-// GetName returns the Name field value
-func (o *TriggerRestoreRequestPayload) GetName() (ret TriggerRestoreRequestPayloadGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *TriggerRestoreRequestPayload) GetNameOk() (ret TriggerRestoreRequestPayloadGetNameRetType, ok bool) {
- return getTriggerRestoreRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *TriggerRestoreRequestPayload) SetName(v TriggerRestoreRequestPayloadGetNameRetType) {
- setTriggerRestoreRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetRestoreDateTime returns the RestoreDateTime field value
-func (o *TriggerRestoreRequestPayload) GetRestoreDateTime() (ret TriggerRestoreRequestPayloadGetRestoreDateTimeRetType) {
- ret, _ = o.GetRestoreDateTimeOk()
- return ret
-}
-
-// GetRestoreDateTimeOk returns a tuple with the RestoreDateTime field value
-// and a boolean to check if the value has been set.
-func (o *TriggerRestoreRequestPayload) GetRestoreDateTimeOk() (ret TriggerRestoreRequestPayloadGetRestoreDateTimeRetType, ok bool) {
- return getTriggerRestoreRequestPayloadGetRestoreDateTimeAttributeTypeOk(o.RestoreDateTime)
-}
-
-// SetRestoreDateTime sets field value
-func (o *TriggerRestoreRequestPayload) SetRestoreDateTime(v TriggerRestoreRequestPayloadGetRestoreDateTimeRetType) {
- setTriggerRestoreRequestPayloadGetRestoreDateTimeAttributeType(&o.RestoreDateTime, v)
-}
-
-func (o TriggerRestoreRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getTriggerRestoreRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getTriggerRestoreRequestPayloadGetRestoreDateTimeAttributeTypeOk(o.RestoreDateTime); ok {
- toSerialize["RestoreDateTime"] = val
- }
- return toSerialize, nil
-}
-
-type NullableTriggerRestoreRequestPayload struct {
- value *TriggerRestoreRequestPayload
- isSet bool
-}
-
-func (v NullableTriggerRestoreRequestPayload) Get() *TriggerRestoreRequestPayload {
- return v.value
-}
-
-func (v *NullableTriggerRestoreRequestPayload) Set(val *TriggerRestoreRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableTriggerRestoreRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableTriggerRestoreRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableTriggerRestoreRequestPayload(val *TriggerRestoreRequestPayload) *NullableTriggerRestoreRequestPayload {
- return &NullableTriggerRestoreRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableTriggerRestoreRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableTriggerRestoreRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_trigger_restore_request_payload_test.go b/pkg/sqlserverflexalpha/model_trigger_restore_request_payload_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_trigger_restore_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_update_instance_partially_request_payload.go b/pkg/sqlserverflexalpha/model_update_instance_partially_request_payload.go
deleted file mode 100644
index cfe78435..00000000
--- a/pkg/sqlserverflexalpha/model_update_instance_partially_request_payload.go
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the UpdateInstancePartiallyRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &UpdateInstancePartiallyRequestPayload{}
-
-/*
- types and functions for acl
-*/
-
-// isArray
-type UpdateInstancePartiallyRequestPayloadGetAclAttributeType = *[]string
-type UpdateInstancePartiallyRequestPayloadGetAclArgType = []string
-type UpdateInstancePartiallyRequestPayloadGetAclRetType = []string
-
-func getUpdateInstancePartiallyRequestPayloadGetAclAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetAclAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetAclRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetAclAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetAclAttributeType, val UpdateInstancePartiallyRequestPayloadGetAclRetType) {
- *arg = &val
-}
-
-/*
- types and functions for backupSchedule
-*/
-
-// isNotNullableString
-type UpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType = *string
-
-func getUpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType, val UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType) {
- *arg = &val
-}
-
-type UpdateInstancePartiallyRequestPayloadGetBackupScheduleArgType = string
-type UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType = string
-
-/*
- types and functions for flavorId
-*/
-
-// isNotNullableString
-type UpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType = *string
-
-func getUpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType, val UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType) {
- *arg = &val
-}
-
-type UpdateInstancePartiallyRequestPayloadGetFlavorIdArgType = string
-type UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType = string
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type UpdateInstancePartiallyRequestPayloadGetNameAttributeType = *string
-
-func getUpdateInstancePartiallyRequestPayloadGetNameAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetNameAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetNameAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetNameAttributeType, val UpdateInstancePartiallyRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type UpdateInstancePartiallyRequestPayloadGetNameArgType = string
-type UpdateInstancePartiallyRequestPayloadGetNameRetType = string
-
-/*
- types and functions for replicas
-*/
-
-// isEnumRef
-type UpdateInstancePartiallyRequestPayloadGetReplicasAttributeType = *ReplicasOpt
-type UpdateInstancePartiallyRequestPayloadGetReplicasArgType = ReplicasOpt
-type UpdateInstancePartiallyRequestPayloadGetReplicasRetType = ReplicasOpt
-
-func getUpdateInstancePartiallyRequestPayloadGetReplicasAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetReplicasAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetReplicasRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetReplicasAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetReplicasAttributeType, val UpdateInstancePartiallyRequestPayloadGetReplicasRetType) {
- *arg = &val
-}
-
-/*
- types and functions for retentionDays
-*/
-
-// isInteger
-type UpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType = *int64
-type UpdateInstancePartiallyRequestPayloadGetRetentionDaysArgType = int64
-type UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType = int64
-
-func getUpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType, val UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType) {
- *arg = &val
-}
-
-/*
- types and functions for storage
-*/
-
-// isModel
-type UpdateInstancePartiallyRequestPayloadGetStorageAttributeType = *StorageUpdate
-type UpdateInstancePartiallyRequestPayloadGetStorageArgType = StorageUpdate
-type UpdateInstancePartiallyRequestPayloadGetStorageRetType = StorageUpdate
-
-func getUpdateInstancePartiallyRequestPayloadGetStorageAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetStorageAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetStorageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetStorageAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetStorageAttributeType, val UpdateInstancePartiallyRequestPayloadGetStorageRetType) {
- *arg = &val
-}
-
-/*
- types and functions for version
-*/
-
-// isEnumRef
-type UpdateInstancePartiallyRequestPayloadGetVersionAttributeType = *InstanceVersionOpt
-type UpdateInstancePartiallyRequestPayloadGetVersionArgType = InstanceVersionOpt
-type UpdateInstancePartiallyRequestPayloadGetVersionRetType = InstanceVersionOpt
-
-func getUpdateInstancePartiallyRequestPayloadGetVersionAttributeTypeOk(arg UpdateInstancePartiallyRequestPayloadGetVersionAttributeType) (ret UpdateInstancePartiallyRequestPayloadGetVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstancePartiallyRequestPayloadGetVersionAttributeType(arg *UpdateInstancePartiallyRequestPayloadGetVersionAttributeType, val UpdateInstancePartiallyRequestPayloadGetVersionRetType) {
- *arg = &val
-}
-
-// UpdateInstancePartiallyRequestPayload struct for UpdateInstancePartiallyRequestPayload
-type UpdateInstancePartiallyRequestPayload struct {
- // List of IPV4 cidr.
- Acl UpdateInstancePartiallyRequestPayloadGetAclAttributeType `json:"acl,omitempty"`
- // The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.
- BackupSchedule UpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType `json:"backupSchedule,omitempty"`
- // The id of the instance flavor.
- FlavorId UpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType `json:"flavorId,omitempty"`
- // The name of the instance.
- Name UpdateInstancePartiallyRequestPayloadGetNameAttributeType `json:"name,omitempty"`
- Replicas UpdateInstancePartiallyRequestPayloadGetReplicasAttributeType `json:"replicas,omitempty"`
- // Can be cast to int32 without loss of precision.
- RetentionDays UpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType `json:"retentionDays,omitempty"`
- Storage UpdateInstancePartiallyRequestPayloadGetStorageAttributeType `json:"storage,omitempty"`
- Version UpdateInstancePartiallyRequestPayloadGetVersionAttributeType `json:"version,omitempty"`
-}
-
-// NewUpdateInstancePartiallyRequestPayload instantiates a new UpdateInstancePartiallyRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewUpdateInstancePartiallyRequestPayload() *UpdateInstancePartiallyRequestPayload {
- this := UpdateInstancePartiallyRequestPayload{}
- return &this
-}
-
-// NewUpdateInstancePartiallyRequestPayloadWithDefaults instantiates a new UpdateInstancePartiallyRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewUpdateInstancePartiallyRequestPayloadWithDefaults() *UpdateInstancePartiallyRequestPayload {
- this := UpdateInstancePartiallyRequestPayload{}
- return &this
-}
-
-// GetAcl returns the Acl field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetAcl() (res UpdateInstancePartiallyRequestPayloadGetAclRetType) {
- res, _ = o.GetAclOk()
- return
-}
-
-// GetAclOk returns a tuple with the Acl field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetAclOk() (ret UpdateInstancePartiallyRequestPayloadGetAclRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetAclAttributeTypeOk(o.Acl)
-}
-
-// HasAcl returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasAcl() bool {
- _, ok := o.GetAclOk()
- return ok
-}
-
-// SetAcl gets a reference to the given []string and assigns it to the Acl field.
-func (o *UpdateInstancePartiallyRequestPayload) SetAcl(v UpdateInstancePartiallyRequestPayloadGetAclRetType) {
- setUpdateInstancePartiallyRequestPayloadGetAclAttributeType(&o.Acl, v)
-}
-
-// GetBackupSchedule returns the BackupSchedule field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetBackupSchedule() (res UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType) {
- res, _ = o.GetBackupScheduleOk()
- return
-}
-
-// GetBackupScheduleOk returns a tuple with the BackupSchedule field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetBackupScheduleOk() (ret UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule)
-}
-
-// HasBackupSchedule returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasBackupSchedule() bool {
- _, ok := o.GetBackupScheduleOk()
- return ok
-}
-
-// SetBackupSchedule gets a reference to the given string and assigns it to the BackupSchedule field.
-func (o *UpdateInstancePartiallyRequestPayload) SetBackupSchedule(v UpdateInstancePartiallyRequestPayloadGetBackupScheduleRetType) {
- setUpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeType(&o.BackupSchedule, v)
-}
-
-// GetFlavorId returns the FlavorId field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetFlavorId() (res UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType) {
- res, _ = o.GetFlavorIdOk()
- return
-}
-
-// GetFlavorIdOk returns a tuple with the FlavorId field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetFlavorIdOk() (ret UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId)
-}
-
-// HasFlavorId returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasFlavorId() bool {
- _, ok := o.GetFlavorIdOk()
- return ok
-}
-
-// SetFlavorId gets a reference to the given string and assigns it to the FlavorId field.
-func (o *UpdateInstancePartiallyRequestPayload) SetFlavorId(v UpdateInstancePartiallyRequestPayloadGetFlavorIdRetType) {
- setUpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeType(&o.FlavorId, v)
-}
-
-// GetName returns the Name field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetName() (res UpdateInstancePartiallyRequestPayloadGetNameRetType) {
- res, _ = o.GetNameOk()
- return
-}
-
-// GetNameOk returns a tuple with the Name field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetNameOk() (ret UpdateInstancePartiallyRequestPayloadGetNameRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// HasName returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasName() bool {
- _, ok := o.GetNameOk()
- return ok
-}
-
-// SetName gets a reference to the given string and assigns it to the Name field.
-func (o *UpdateInstancePartiallyRequestPayload) SetName(v UpdateInstancePartiallyRequestPayloadGetNameRetType) {
- setUpdateInstancePartiallyRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetReplicas returns the Replicas field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetReplicas() (res UpdateInstancePartiallyRequestPayloadGetReplicasRetType) {
- res, _ = o.GetReplicasOk()
- return
-}
-
-// GetReplicasOk returns a tuple with the Replicas field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetReplicasOk() (ret UpdateInstancePartiallyRequestPayloadGetReplicasRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetReplicasAttributeTypeOk(o.Replicas)
-}
-
-// HasReplicas returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasReplicas() bool {
- _, ok := o.GetReplicasOk()
- return ok
-}
-
-// SetReplicas gets a reference to the given ReplicasOpt and assigns it to the Replicas field.
-func (o *UpdateInstancePartiallyRequestPayload) SetReplicas(v UpdateInstancePartiallyRequestPayloadGetReplicasRetType) {
- setUpdateInstancePartiallyRequestPayloadGetReplicasAttributeType(&o.Replicas, v)
-}
-
-// GetRetentionDays returns the RetentionDays field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetRetentionDays() (res UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType) {
- res, _ = o.GetRetentionDaysOk()
- return
-}
-
-// GetRetentionDaysOk returns a tuple with the RetentionDays field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetRetentionDaysOk() (ret UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays)
-}
-
-// HasRetentionDays returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasRetentionDays() bool {
- _, ok := o.GetRetentionDaysOk()
- return ok
-}
-
-// SetRetentionDays gets a reference to the given int64 and assigns it to the RetentionDays field.
-func (o *UpdateInstancePartiallyRequestPayload) SetRetentionDays(v UpdateInstancePartiallyRequestPayloadGetRetentionDaysRetType) {
- setUpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeType(&o.RetentionDays, v)
-}
-
-// GetStorage returns the Storage field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetStorage() (res UpdateInstancePartiallyRequestPayloadGetStorageRetType) {
- res, _ = o.GetStorageOk()
- return
-}
-
-// GetStorageOk returns a tuple with the Storage field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetStorageOk() (ret UpdateInstancePartiallyRequestPayloadGetStorageRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetStorageAttributeTypeOk(o.Storage)
-}
-
-// HasStorage returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasStorage() bool {
- _, ok := o.GetStorageOk()
- return ok
-}
-
-// SetStorage gets a reference to the given StorageUpdate and assigns it to the Storage field.
-func (o *UpdateInstancePartiallyRequestPayload) SetStorage(v UpdateInstancePartiallyRequestPayloadGetStorageRetType) {
- setUpdateInstancePartiallyRequestPayloadGetStorageAttributeType(&o.Storage, v)
-}
-
-// GetVersion returns the Version field value if set, zero value otherwise.
-func (o *UpdateInstancePartiallyRequestPayload) GetVersion() (res UpdateInstancePartiallyRequestPayloadGetVersionRetType) {
- res, _ = o.GetVersionOk()
- return
-}
-
-// GetVersionOk returns a tuple with the Version field value if set, nil otherwise
-// and a boolean to check if the value has been set.
-func (o *UpdateInstancePartiallyRequestPayload) GetVersionOk() (ret UpdateInstancePartiallyRequestPayloadGetVersionRetType, ok bool) {
- return getUpdateInstancePartiallyRequestPayloadGetVersionAttributeTypeOk(o.Version)
-}
-
-// HasVersion returns a boolean if a field has been set.
-func (o *UpdateInstancePartiallyRequestPayload) HasVersion() bool {
- _, ok := o.GetVersionOk()
- return ok
-}
-
-// SetVersion gets a reference to the given InstanceVersionOpt and assigns it to the Version field.
-func (o *UpdateInstancePartiallyRequestPayload) SetVersion(v UpdateInstancePartiallyRequestPayloadGetVersionRetType) {
- setUpdateInstancePartiallyRequestPayloadGetVersionAttributeType(&o.Version, v)
-}
-
-func (o UpdateInstancePartiallyRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetAclAttributeTypeOk(o.Acl); ok {
- toSerialize["Acl"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule); ok {
- toSerialize["BackupSchedule"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId); ok {
- toSerialize["FlavorId"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetReplicasAttributeTypeOk(o.Replicas); ok {
- toSerialize["Replicas"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays); ok {
- toSerialize["RetentionDays"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetStorageAttributeTypeOk(o.Storage); ok {
- toSerialize["Storage"] = val
- }
- if val, ok := getUpdateInstancePartiallyRequestPayloadGetVersionAttributeTypeOk(o.Version); ok {
- toSerialize["Version"] = val
- }
- return toSerialize, nil
-}
-
-type NullableUpdateInstancePartiallyRequestPayload struct {
- value *UpdateInstancePartiallyRequestPayload
- isSet bool
-}
-
-func (v NullableUpdateInstancePartiallyRequestPayload) Get() *UpdateInstancePartiallyRequestPayload {
- return v.value
-}
-
-func (v *NullableUpdateInstancePartiallyRequestPayload) Set(val *UpdateInstancePartiallyRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUpdateInstancePartiallyRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUpdateInstancePartiallyRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUpdateInstancePartiallyRequestPayload(val *UpdateInstancePartiallyRequestPayload) *NullableUpdateInstancePartiallyRequestPayload {
- return &NullableUpdateInstancePartiallyRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableUpdateInstancePartiallyRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUpdateInstancePartiallyRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_update_instance_partially_request_payload_test.go b/pkg/sqlserverflexalpha/model_update_instance_partially_request_payload_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_update_instance_partially_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_update_instance_request_payload.go b/pkg/sqlserverflexalpha/model_update_instance_request_payload.go
deleted file mode 100644
index c978ab68..00000000
--- a/pkg/sqlserverflexalpha/model_update_instance_request_payload.go
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the UpdateInstanceRequestPayload type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &UpdateInstanceRequestPayload{}
-
-/*
- types and functions for acl
-*/
-
-// isArray
-type UpdateInstanceRequestPayloadGetAclAttributeType = *[]string
-type UpdateInstanceRequestPayloadGetAclArgType = []string
-type UpdateInstanceRequestPayloadGetAclRetType = []string
-
-func getUpdateInstanceRequestPayloadGetAclAttributeTypeOk(arg UpdateInstanceRequestPayloadGetAclAttributeType) (ret UpdateInstanceRequestPayloadGetAclRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetAclAttributeType(arg *UpdateInstanceRequestPayloadGetAclAttributeType, val UpdateInstanceRequestPayloadGetAclRetType) {
- *arg = &val
-}
-
-/*
- types and functions for backupSchedule
-*/
-
-// isNotNullableString
-type UpdateInstanceRequestPayloadGetBackupScheduleAttributeType = *string
-
-func getUpdateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(arg UpdateInstanceRequestPayloadGetBackupScheduleAttributeType) (ret UpdateInstanceRequestPayloadGetBackupScheduleRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetBackupScheduleAttributeType(arg *UpdateInstanceRequestPayloadGetBackupScheduleAttributeType, val UpdateInstanceRequestPayloadGetBackupScheduleRetType) {
- *arg = &val
-}
-
-type UpdateInstanceRequestPayloadGetBackupScheduleArgType = string
-type UpdateInstanceRequestPayloadGetBackupScheduleRetType = string
-
-/*
- types and functions for flavorId
-*/
-
-// isNotNullableString
-type UpdateInstanceRequestPayloadGetFlavorIdAttributeType = *string
-
-func getUpdateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(arg UpdateInstanceRequestPayloadGetFlavorIdAttributeType) (ret UpdateInstanceRequestPayloadGetFlavorIdRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetFlavorIdAttributeType(arg *UpdateInstanceRequestPayloadGetFlavorIdAttributeType, val UpdateInstanceRequestPayloadGetFlavorIdRetType) {
- *arg = &val
-}
-
-type UpdateInstanceRequestPayloadGetFlavorIdArgType = string
-type UpdateInstanceRequestPayloadGetFlavorIdRetType = string
-
-/*
- types and functions for name
-*/
-
-// isNotNullableString
-type UpdateInstanceRequestPayloadGetNameAttributeType = *string
-
-func getUpdateInstanceRequestPayloadGetNameAttributeTypeOk(arg UpdateInstanceRequestPayloadGetNameAttributeType) (ret UpdateInstanceRequestPayloadGetNameRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetNameAttributeType(arg *UpdateInstanceRequestPayloadGetNameAttributeType, val UpdateInstanceRequestPayloadGetNameRetType) {
- *arg = &val
-}
-
-type UpdateInstanceRequestPayloadGetNameArgType = string
-type UpdateInstanceRequestPayloadGetNameRetType = string
-
-/*
- types and functions for replicas
-*/
-
-// isEnumRef
-type UpdateInstanceRequestPayloadGetReplicasAttributeType = *Replicas
-type UpdateInstanceRequestPayloadGetReplicasArgType = Replicas
-type UpdateInstanceRequestPayloadGetReplicasRetType = Replicas
-
-func getUpdateInstanceRequestPayloadGetReplicasAttributeTypeOk(arg UpdateInstanceRequestPayloadGetReplicasAttributeType) (ret UpdateInstanceRequestPayloadGetReplicasRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetReplicasAttributeType(arg *UpdateInstanceRequestPayloadGetReplicasAttributeType, val UpdateInstanceRequestPayloadGetReplicasRetType) {
- *arg = &val
-}
-
-/*
- types and functions for retentionDays
-*/
-
-// isInteger
-type UpdateInstanceRequestPayloadGetRetentionDaysAttributeType = *int64
-type UpdateInstanceRequestPayloadGetRetentionDaysArgType = int64
-type UpdateInstanceRequestPayloadGetRetentionDaysRetType = int64
-
-func getUpdateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(arg UpdateInstanceRequestPayloadGetRetentionDaysAttributeType) (ret UpdateInstanceRequestPayloadGetRetentionDaysRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetRetentionDaysAttributeType(arg *UpdateInstanceRequestPayloadGetRetentionDaysAttributeType, val UpdateInstanceRequestPayloadGetRetentionDaysRetType) {
- *arg = &val
-}
-
-/*
- types and functions for storage
-*/
-
-// isModel
-type UpdateInstanceRequestPayloadGetStorageAttributeType = *StorageUpdate
-type UpdateInstanceRequestPayloadGetStorageArgType = StorageUpdate
-type UpdateInstanceRequestPayloadGetStorageRetType = StorageUpdate
-
-func getUpdateInstanceRequestPayloadGetStorageAttributeTypeOk(arg UpdateInstanceRequestPayloadGetStorageAttributeType) (ret UpdateInstanceRequestPayloadGetStorageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetStorageAttributeType(arg *UpdateInstanceRequestPayloadGetStorageAttributeType, val UpdateInstanceRequestPayloadGetStorageRetType) {
- *arg = &val
-}
-
-/*
- types and functions for version
-*/
-
-// isEnumRef
-type UpdateInstanceRequestPayloadGetVersionAttributeType = *InstanceVersion
-type UpdateInstanceRequestPayloadGetVersionArgType = InstanceVersion
-type UpdateInstanceRequestPayloadGetVersionRetType = InstanceVersion
-
-func getUpdateInstanceRequestPayloadGetVersionAttributeTypeOk(arg UpdateInstanceRequestPayloadGetVersionAttributeType) (ret UpdateInstanceRequestPayloadGetVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setUpdateInstanceRequestPayloadGetVersionAttributeType(arg *UpdateInstanceRequestPayloadGetVersionAttributeType, val UpdateInstanceRequestPayloadGetVersionRetType) {
- *arg = &val
-}
-
-// UpdateInstanceRequestPayload struct for UpdateInstanceRequestPayload
-type UpdateInstanceRequestPayload struct {
- // List of IPV4 cidr.
- // REQUIRED
- Acl UpdateInstanceRequestPayloadGetAclAttributeType `json:"acl" required:"true"`
- // The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.
- // REQUIRED
- BackupSchedule UpdateInstanceRequestPayloadGetBackupScheduleAttributeType `json:"backupSchedule" required:"true"`
- // The id of the instance flavor.
- // REQUIRED
- FlavorId UpdateInstanceRequestPayloadGetFlavorIdAttributeType `json:"flavorId" required:"true"`
- // The name of the instance.
- // REQUIRED
- Name UpdateInstanceRequestPayloadGetNameAttributeType `json:"name" required:"true"`
- // REQUIRED
- Replicas UpdateInstanceRequestPayloadGetReplicasAttributeType `json:"replicas" required:"true"`
- // The days for how long the backup files should be stored before cleaned up. 30 to 365
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- RetentionDays UpdateInstanceRequestPayloadGetRetentionDaysAttributeType `json:"retentionDays" required:"true"`
- // REQUIRED
- Storage UpdateInstanceRequestPayloadGetStorageAttributeType `json:"storage" required:"true"`
- // REQUIRED
- Version UpdateInstanceRequestPayloadGetVersionAttributeType `json:"version" required:"true"`
-}
-
-type _UpdateInstanceRequestPayload UpdateInstanceRequestPayload
-
-// NewUpdateInstanceRequestPayload instantiates a new UpdateInstanceRequestPayload object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewUpdateInstanceRequestPayload(acl UpdateInstanceRequestPayloadGetAclArgType, backupSchedule UpdateInstanceRequestPayloadGetBackupScheduleArgType, flavorId UpdateInstanceRequestPayloadGetFlavorIdArgType, name UpdateInstanceRequestPayloadGetNameArgType, replicas UpdateInstanceRequestPayloadGetReplicasArgType, retentionDays UpdateInstanceRequestPayloadGetRetentionDaysArgType, storage UpdateInstanceRequestPayloadGetStorageArgType, version UpdateInstanceRequestPayloadGetVersionArgType) *UpdateInstanceRequestPayload {
- this := UpdateInstanceRequestPayload{}
- setUpdateInstanceRequestPayloadGetAclAttributeType(&this.Acl, acl)
- setUpdateInstanceRequestPayloadGetBackupScheduleAttributeType(&this.BackupSchedule, backupSchedule)
- setUpdateInstanceRequestPayloadGetFlavorIdAttributeType(&this.FlavorId, flavorId)
- setUpdateInstanceRequestPayloadGetNameAttributeType(&this.Name, name)
- setUpdateInstanceRequestPayloadGetReplicasAttributeType(&this.Replicas, replicas)
- setUpdateInstanceRequestPayloadGetRetentionDaysAttributeType(&this.RetentionDays, retentionDays)
- setUpdateInstanceRequestPayloadGetStorageAttributeType(&this.Storage, storage)
- setUpdateInstanceRequestPayloadGetVersionAttributeType(&this.Version, version)
- return &this
-}
-
-// NewUpdateInstanceRequestPayloadWithDefaults instantiates a new UpdateInstanceRequestPayload object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewUpdateInstanceRequestPayloadWithDefaults() *UpdateInstanceRequestPayload {
- this := UpdateInstanceRequestPayload{}
- return &this
-}
-
-// GetAcl returns the Acl field value
-func (o *UpdateInstanceRequestPayload) GetAcl() (ret UpdateInstanceRequestPayloadGetAclRetType) {
- ret, _ = o.GetAclOk()
- return ret
-}
-
-// GetAclOk returns a tuple with the Acl field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetAclOk() (ret UpdateInstanceRequestPayloadGetAclRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetAclAttributeTypeOk(o.Acl)
-}
-
-// SetAcl sets field value
-func (o *UpdateInstanceRequestPayload) SetAcl(v UpdateInstanceRequestPayloadGetAclRetType) {
- setUpdateInstanceRequestPayloadGetAclAttributeType(&o.Acl, v)
-}
-
-// GetBackupSchedule returns the BackupSchedule field value
-func (o *UpdateInstanceRequestPayload) GetBackupSchedule() (ret UpdateInstanceRequestPayloadGetBackupScheduleRetType) {
- ret, _ = o.GetBackupScheduleOk()
- return ret
-}
-
-// GetBackupScheduleOk returns a tuple with the BackupSchedule field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetBackupScheduleOk() (ret UpdateInstanceRequestPayloadGetBackupScheduleRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule)
-}
-
-// SetBackupSchedule sets field value
-func (o *UpdateInstanceRequestPayload) SetBackupSchedule(v UpdateInstanceRequestPayloadGetBackupScheduleRetType) {
- setUpdateInstanceRequestPayloadGetBackupScheduleAttributeType(&o.BackupSchedule, v)
-}
-
-// GetFlavorId returns the FlavorId field value
-func (o *UpdateInstanceRequestPayload) GetFlavorId() (ret UpdateInstanceRequestPayloadGetFlavorIdRetType) {
- ret, _ = o.GetFlavorIdOk()
- return ret
-}
-
-// GetFlavorIdOk returns a tuple with the FlavorId field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetFlavorIdOk() (ret UpdateInstanceRequestPayloadGetFlavorIdRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId)
-}
-
-// SetFlavorId sets field value
-func (o *UpdateInstanceRequestPayload) SetFlavorId(v UpdateInstanceRequestPayloadGetFlavorIdRetType) {
- setUpdateInstanceRequestPayloadGetFlavorIdAttributeType(&o.FlavorId, v)
-}
-
-// GetName returns the Name field value
-func (o *UpdateInstanceRequestPayload) GetName() (ret UpdateInstanceRequestPayloadGetNameRetType) {
- ret, _ = o.GetNameOk()
- return ret
-}
-
-// GetNameOk returns a tuple with the Name field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetNameOk() (ret UpdateInstanceRequestPayloadGetNameRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetNameAttributeTypeOk(o.Name)
-}
-
-// SetName sets field value
-func (o *UpdateInstanceRequestPayload) SetName(v UpdateInstanceRequestPayloadGetNameRetType) {
- setUpdateInstanceRequestPayloadGetNameAttributeType(&o.Name, v)
-}
-
-// GetReplicas returns the Replicas field value
-func (o *UpdateInstanceRequestPayload) GetReplicas() (ret UpdateInstanceRequestPayloadGetReplicasRetType) {
- ret, _ = o.GetReplicasOk()
- return ret
-}
-
-// GetReplicasOk returns a tuple with the Replicas field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetReplicasOk() (ret UpdateInstanceRequestPayloadGetReplicasRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetReplicasAttributeTypeOk(o.Replicas)
-}
-
-// SetReplicas sets field value
-func (o *UpdateInstanceRequestPayload) SetReplicas(v UpdateInstanceRequestPayloadGetReplicasRetType) {
- setUpdateInstanceRequestPayloadGetReplicasAttributeType(&o.Replicas, v)
-}
-
-// GetRetentionDays returns the RetentionDays field value
-func (o *UpdateInstanceRequestPayload) GetRetentionDays() (ret UpdateInstanceRequestPayloadGetRetentionDaysRetType) {
- ret, _ = o.GetRetentionDaysOk()
- return ret
-}
-
-// GetRetentionDaysOk returns a tuple with the RetentionDays field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetRetentionDaysOk() (ret UpdateInstanceRequestPayloadGetRetentionDaysRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays)
-}
-
-// SetRetentionDays sets field value
-func (o *UpdateInstanceRequestPayload) SetRetentionDays(v UpdateInstanceRequestPayloadGetRetentionDaysRetType) {
- setUpdateInstanceRequestPayloadGetRetentionDaysAttributeType(&o.RetentionDays, v)
-}
-
-// GetStorage returns the Storage field value
-func (o *UpdateInstanceRequestPayload) GetStorage() (ret UpdateInstanceRequestPayloadGetStorageRetType) {
- ret, _ = o.GetStorageOk()
- return ret
-}
-
-// GetStorageOk returns a tuple with the Storage field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetStorageOk() (ret UpdateInstanceRequestPayloadGetStorageRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetStorageAttributeTypeOk(o.Storage)
-}
-
-// SetStorage sets field value
-func (o *UpdateInstanceRequestPayload) SetStorage(v UpdateInstanceRequestPayloadGetStorageRetType) {
- setUpdateInstanceRequestPayloadGetStorageAttributeType(&o.Storage, v)
-}
-
-// GetVersion returns the Version field value
-func (o *UpdateInstanceRequestPayload) GetVersion() (ret UpdateInstanceRequestPayloadGetVersionRetType) {
- ret, _ = o.GetVersionOk()
- return ret
-}
-
-// GetVersionOk returns a tuple with the Version field value
-// and a boolean to check if the value has been set.
-func (o *UpdateInstanceRequestPayload) GetVersionOk() (ret UpdateInstanceRequestPayloadGetVersionRetType, ok bool) {
- return getUpdateInstanceRequestPayloadGetVersionAttributeTypeOk(o.Version)
-}
-
-// SetVersion sets field value
-func (o *UpdateInstanceRequestPayload) SetVersion(v UpdateInstanceRequestPayloadGetVersionRetType) {
- setUpdateInstanceRequestPayloadGetVersionAttributeType(&o.Version, v)
-}
-
-func (o UpdateInstanceRequestPayload) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getUpdateInstanceRequestPayloadGetAclAttributeTypeOk(o.Acl); ok {
- toSerialize["Acl"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetBackupScheduleAttributeTypeOk(o.BackupSchedule); ok {
- toSerialize["BackupSchedule"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetFlavorIdAttributeTypeOk(o.FlavorId); ok {
- toSerialize["FlavorId"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetNameAttributeTypeOk(o.Name); ok {
- toSerialize["Name"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetReplicasAttributeTypeOk(o.Replicas); ok {
- toSerialize["Replicas"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetRetentionDaysAttributeTypeOk(o.RetentionDays); ok {
- toSerialize["RetentionDays"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetStorageAttributeTypeOk(o.Storage); ok {
- toSerialize["Storage"] = val
- }
- if val, ok := getUpdateInstanceRequestPayloadGetVersionAttributeTypeOk(o.Version); ok {
- toSerialize["Version"] = val
- }
- return toSerialize, nil
-}
-
-type NullableUpdateInstanceRequestPayload struct {
- value *UpdateInstanceRequestPayload
- isSet bool
-}
-
-func (v NullableUpdateInstanceRequestPayload) Get() *UpdateInstanceRequestPayload {
- return v.value
-}
-
-func (v *NullableUpdateInstanceRequestPayload) Set(val *UpdateInstanceRequestPayload) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUpdateInstanceRequestPayload) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUpdateInstanceRequestPayload) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUpdateInstanceRequestPayload(val *UpdateInstanceRequestPayload) *NullableUpdateInstanceRequestPayload {
- return &NullableUpdateInstanceRequestPayload{value: val, isSet: true}
-}
-
-func (v NullableUpdateInstanceRequestPayload) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUpdateInstanceRequestPayload) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_update_instance_request_payload_test.go b/pkg/sqlserverflexalpha/model_update_instance_request_payload_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_update_instance_request_payload_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_user_role.go b/pkg/sqlserverflexalpha/model_user_role.go
deleted file mode 100644
index 7687df2a..00000000
--- a/pkg/sqlserverflexalpha/model_user_role.go
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// UserRole The user role for the instance.
-type UserRole string
-
-// List of user.role
-const (
- USERROLE_LOGIN_MANAGER UserRole = "##STACKIT_LoginManager##"
- USERROLE_DATABASE_MANAGER UserRole = "##STACKIT_DatabaseManager##"
-)
-
-// All allowed values of UserRole enum
-var AllowedUserRoleEnumValues = []UserRole{
- "##STACKIT_LoginManager##",
- "##STACKIT_DatabaseManager##",
-}
-
-func (v *UserRole) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := UserRole(value)
- for _, existing := range AllowedUserRoleEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid UserRole", value)
-}
-
-// NewUserRoleFromValue returns a pointer to a valid UserRole
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewUserRoleFromValue(v string) (*UserRole, error) {
- ev := UserRole(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for UserRole: valid values are %v", v, AllowedUserRoleEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v UserRole) IsValid() bool {
- for _, existing := range AllowedUserRoleEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to user.role value
-func (v UserRole) Ptr() *UserRole {
- return &v
-}
-
-type NullableUserRole struct {
- value *UserRole
- isSet bool
-}
-
-func (v NullableUserRole) Get() *UserRole {
- return v.value
-}
-
-func (v *NullableUserRole) Set(val *UserRole) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUserRole) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUserRole) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUserRole(val *UserRole) *NullableUserRole {
- return &NullableUserRole{value: val, isSet: true}
-}
-
-func (v NullableUserRole) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUserRole) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_user_role_test.go b/pkg/sqlserverflexalpha/model_user_role_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_user_role_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_user_sort.go b/pkg/sqlserverflexalpha/model_user_sort.go
deleted file mode 100644
index 64827ce7..00000000
--- a/pkg/sqlserverflexalpha/model_user_sort.go
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// UserSort the model 'UserSort'
-type UserSort string
-
-// List of user.sort
-const (
- USERSORT_ID_ASC UserSort = "id.asc"
- USERSORT_ID_DESC UserSort = "id.desc"
- USERSORT_INDEX_DESC UserSort = "index.desc"
- USERSORT_INDEX_ASC UserSort = "index.asc"
- USERSORT_NAME_DESC UserSort = "name.desc"
- USERSORT_NAME_ASC UserSort = "name.asc"
- USERSORT_STATUS_DESC UserSort = "status.desc"
- USERSORT_STATUS_ASC UserSort = "status.asc"
-)
-
-// All allowed values of UserSort enum
-var AllowedUserSortEnumValues = []UserSort{
- "id.asc",
- "id.desc",
- "index.desc",
- "index.asc",
- "name.desc",
- "name.asc",
- "status.desc",
- "status.asc",
-}
-
-func (v *UserSort) UnmarshalJSON(src []byte) error {
- var value string
- err := json.Unmarshal(src, &value)
- if err != nil {
- return err
- }
- // Allow unmarshalling zero value for testing purposes
- var zeroValue string
- if value == zeroValue {
- return nil
- }
- enumTypeValue := UserSort(value)
- for _, existing := range AllowedUserSortEnumValues {
- if existing == enumTypeValue {
- *v = enumTypeValue
- return nil
- }
- }
-
- return fmt.Errorf("%+v is not a valid UserSort", value)
-}
-
-// NewUserSortFromValue returns a pointer to a valid UserSort
-// for the value passed as argument, or an error if the value passed is not allowed by the enum
-func NewUserSortFromValue(v string) (*UserSort, error) {
- ev := UserSort(v)
- if ev.IsValid() {
- return &ev, nil
- } else {
- return nil, fmt.Errorf("invalid value '%v' for UserSort: valid values are %v", v, AllowedUserSortEnumValues)
- }
-}
-
-// IsValid return true if the value is valid for the enum, false otherwise
-func (v UserSort) IsValid() bool {
- for _, existing := range AllowedUserSortEnumValues {
- if existing == v {
- return true
- }
- }
- return false
-}
-
-// Ptr returns reference to user.sort value
-func (v UserSort) Ptr() *UserSort {
- return &v
-}
-
-type NullableUserSort struct {
- value *UserSort
- isSet bool
-}
-
-func (v NullableUserSort) Get() *UserSort {
- return v.value
-}
-
-func (v *NullableUserSort) Set(val *UserSort) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableUserSort) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableUserSort) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableUserSort(val *UserSort) *NullableUserSort {
- return &NullableUserSort{value: val, isSet: true}
-}
-
-func (v NullableUserSort) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableUserSort) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_user_sort_test.go b/pkg/sqlserverflexalpha/model_user_sort_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_user_sort_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_validation_error.go b/pkg/sqlserverflexalpha/model_validation_error.go
deleted file mode 100644
index 6d72ce43..00000000
--- a/pkg/sqlserverflexalpha/model_validation_error.go
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ValidationError type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ValidationError{}
-
-/*
- types and functions for code
-*/
-
-// isInteger
-type ValidationErrorGetCodeAttributeType = *int64
-type ValidationErrorGetCodeArgType = int64
-type ValidationErrorGetCodeRetType = int64
-
-func getValidationErrorGetCodeAttributeTypeOk(arg ValidationErrorGetCodeAttributeType) (ret ValidationErrorGetCodeRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setValidationErrorGetCodeAttributeType(arg *ValidationErrorGetCodeAttributeType, val ValidationErrorGetCodeRetType) {
- *arg = &val
-}
-
-/*
- types and functions for validation
-*/
-
-// isArray
-type ValidationErrorGetValidationAttributeType = *[]ValidationErrorValidationInner
-type ValidationErrorGetValidationArgType = []ValidationErrorValidationInner
-type ValidationErrorGetValidationRetType = []ValidationErrorValidationInner
-
-func getValidationErrorGetValidationAttributeTypeOk(arg ValidationErrorGetValidationAttributeType) (ret ValidationErrorGetValidationRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setValidationErrorGetValidationAttributeType(arg *ValidationErrorGetValidationAttributeType, val ValidationErrorGetValidationRetType) {
- *arg = &val
-}
-
-// ValidationError struct for ValidationError
-type ValidationError struct {
- // the http error should be always 422 for validationError
- // Can be cast to int32 without loss of precision.
- // REQUIRED
- Code ValidationErrorGetCodeAttributeType `json:"code" required:"true"`
- // errors for all fields where the error happened
- // REQUIRED
- Validation ValidationErrorGetValidationAttributeType `json:"validation" required:"true"`
-}
-
-type _ValidationError ValidationError
-
-// NewValidationError instantiates a new ValidationError object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewValidationError(code ValidationErrorGetCodeArgType, validation ValidationErrorGetValidationArgType) *ValidationError {
- this := ValidationError{}
- setValidationErrorGetCodeAttributeType(&this.Code, code)
- setValidationErrorGetValidationAttributeType(&this.Validation, validation)
- return &this
-}
-
-// NewValidationErrorWithDefaults instantiates a new ValidationError object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewValidationErrorWithDefaults() *ValidationError {
- this := ValidationError{}
- return &this
-}
-
-// GetCode returns the Code field value
-func (o *ValidationError) GetCode() (ret ValidationErrorGetCodeRetType) {
- ret, _ = o.GetCodeOk()
- return ret
-}
-
-// GetCodeOk returns a tuple with the Code field value
-// and a boolean to check if the value has been set.
-func (o *ValidationError) GetCodeOk() (ret ValidationErrorGetCodeRetType, ok bool) {
- return getValidationErrorGetCodeAttributeTypeOk(o.Code)
-}
-
-// SetCode sets field value
-func (o *ValidationError) SetCode(v ValidationErrorGetCodeRetType) {
- setValidationErrorGetCodeAttributeType(&o.Code, v)
-}
-
-// GetValidation returns the Validation field value
-func (o *ValidationError) GetValidation() (ret ValidationErrorGetValidationRetType) {
- ret, _ = o.GetValidationOk()
- return ret
-}
-
-// GetValidationOk returns a tuple with the Validation field value
-// and a boolean to check if the value has been set.
-func (o *ValidationError) GetValidationOk() (ret ValidationErrorGetValidationRetType, ok bool) {
- return getValidationErrorGetValidationAttributeTypeOk(o.Validation)
-}
-
-// SetValidation sets field value
-func (o *ValidationError) SetValidation(v ValidationErrorGetValidationRetType) {
- setValidationErrorGetValidationAttributeType(&o.Validation, v)
-}
-
-func (o ValidationError) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getValidationErrorGetCodeAttributeTypeOk(o.Code); ok {
- toSerialize["Code"] = val
- }
- if val, ok := getValidationErrorGetValidationAttributeTypeOk(o.Validation); ok {
- toSerialize["Validation"] = val
- }
- return toSerialize, nil
-}
-
-type NullableValidationError struct {
- value *ValidationError
- isSet bool
-}
-
-func (v NullableValidationError) Get() *ValidationError {
- return v.value
-}
-
-func (v *NullableValidationError) Set(val *ValidationError) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableValidationError) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableValidationError) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableValidationError(val *ValidationError) *NullableValidationError {
- return &NullableValidationError{value: val, isSet: true}
-}
-
-func (v NullableValidationError) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableValidationError) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_validation_error_test.go b/pkg/sqlserverflexalpha/model_validation_error_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_validation_error_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_validation_error_validation_inner.go b/pkg/sqlserverflexalpha/model_validation_error_validation_inner.go
deleted file mode 100644
index 7b54ff1d..00000000
--- a/pkg/sqlserverflexalpha/model_validation_error_validation_inner.go
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the ValidationErrorValidationInner type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &ValidationErrorValidationInner{}
-
-/*
- types and functions for field
-*/
-
-// isNotNullableString
-type ValidationErrorValidationInnerGetFieldAttributeType = *string
-
-func getValidationErrorValidationInnerGetFieldAttributeTypeOk(arg ValidationErrorValidationInnerGetFieldAttributeType) (ret ValidationErrorValidationInnerGetFieldRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setValidationErrorValidationInnerGetFieldAttributeType(arg *ValidationErrorValidationInnerGetFieldAttributeType, val ValidationErrorValidationInnerGetFieldRetType) {
- *arg = &val
-}
-
-type ValidationErrorValidationInnerGetFieldArgType = string
-type ValidationErrorValidationInnerGetFieldRetType = string
-
-/*
- types and functions for message
-*/
-
-// isNotNullableString
-type ValidationErrorValidationInnerGetMessageAttributeType = *string
-
-func getValidationErrorValidationInnerGetMessageAttributeTypeOk(arg ValidationErrorValidationInnerGetMessageAttributeType) (ret ValidationErrorValidationInnerGetMessageRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setValidationErrorValidationInnerGetMessageAttributeType(arg *ValidationErrorValidationInnerGetMessageAttributeType, val ValidationErrorValidationInnerGetMessageRetType) {
- *arg = &val
-}
-
-type ValidationErrorValidationInnerGetMessageArgType = string
-type ValidationErrorValidationInnerGetMessageRetType = string
-
-// ValidationErrorValidationInner struct for ValidationErrorValidationInner
-type ValidationErrorValidationInner struct {
- // REQUIRED
- Field ValidationErrorValidationInnerGetFieldAttributeType `json:"field" required:"true"`
- // REQUIRED
- Message ValidationErrorValidationInnerGetMessageAttributeType `json:"message" required:"true"`
-}
-
-type _ValidationErrorValidationInner ValidationErrorValidationInner
-
-// NewValidationErrorValidationInner instantiates a new ValidationErrorValidationInner object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewValidationErrorValidationInner(field ValidationErrorValidationInnerGetFieldArgType, message ValidationErrorValidationInnerGetMessageArgType) *ValidationErrorValidationInner {
- this := ValidationErrorValidationInner{}
- setValidationErrorValidationInnerGetFieldAttributeType(&this.Field, field)
- setValidationErrorValidationInnerGetMessageAttributeType(&this.Message, message)
- return &this
-}
-
-// NewValidationErrorValidationInnerWithDefaults instantiates a new ValidationErrorValidationInner object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewValidationErrorValidationInnerWithDefaults() *ValidationErrorValidationInner {
- this := ValidationErrorValidationInner{}
- return &this
-}
-
-// GetField returns the Field field value
-func (o *ValidationErrorValidationInner) GetField() (ret ValidationErrorValidationInnerGetFieldRetType) {
- ret, _ = o.GetFieldOk()
- return ret
-}
-
-// GetFieldOk returns a tuple with the Field field value
-// and a boolean to check if the value has been set.
-func (o *ValidationErrorValidationInner) GetFieldOk() (ret ValidationErrorValidationInnerGetFieldRetType, ok bool) {
- return getValidationErrorValidationInnerGetFieldAttributeTypeOk(o.Field)
-}
-
-// SetField sets field value
-func (o *ValidationErrorValidationInner) SetField(v ValidationErrorValidationInnerGetFieldRetType) {
- setValidationErrorValidationInnerGetFieldAttributeType(&o.Field, v)
-}
-
-// GetMessage returns the Message field value
-func (o *ValidationErrorValidationInner) GetMessage() (ret ValidationErrorValidationInnerGetMessageRetType) {
- ret, _ = o.GetMessageOk()
- return ret
-}
-
-// GetMessageOk returns a tuple with the Message field value
-// and a boolean to check if the value has been set.
-func (o *ValidationErrorValidationInner) GetMessageOk() (ret ValidationErrorValidationInnerGetMessageRetType, ok bool) {
- return getValidationErrorValidationInnerGetMessageAttributeTypeOk(o.Message)
-}
-
-// SetMessage sets field value
-func (o *ValidationErrorValidationInner) SetMessage(v ValidationErrorValidationInnerGetMessageRetType) {
- setValidationErrorValidationInnerGetMessageAttributeType(&o.Message, v)
-}
-
-func (o ValidationErrorValidationInner) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getValidationErrorValidationInnerGetFieldAttributeTypeOk(o.Field); ok {
- toSerialize["Field"] = val
- }
- if val, ok := getValidationErrorValidationInnerGetMessageAttributeTypeOk(o.Message); ok {
- toSerialize["Message"] = val
- }
- return toSerialize, nil
-}
-
-type NullableValidationErrorValidationInner struct {
- value *ValidationErrorValidationInner
- isSet bool
-}
-
-func (v NullableValidationErrorValidationInner) Get() *ValidationErrorValidationInner {
- return v.value
-}
-
-func (v *NullableValidationErrorValidationInner) Set(val *ValidationErrorValidationInner) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableValidationErrorValidationInner) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableValidationErrorValidationInner) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableValidationErrorValidationInner(val *ValidationErrorValidationInner) *NullableValidationErrorValidationInner {
- return &NullableValidationErrorValidationInner{value: val, isSet: true}
-}
-
-func (v NullableValidationErrorValidationInner) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableValidationErrorValidationInner) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_validation_error_validation_inner_test.go b/pkg/sqlserverflexalpha/model_validation_error_validation_inner_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_validation_error_validation_inner_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/model_version.go b/pkg/sqlserverflexalpha/model_version.go
deleted file mode 100644
index 578d7ade..00000000
--- a/pkg/sqlserverflexalpha/model_version.go
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
-)
-
-// checks if the Version type satisfies the MappedNullable interface at compile time
-var _ MappedNullable = &Version{}
-
-/*
- types and functions for beta
-*/
-
-// isBoolean
-type VersiongetBetaAttributeType = *bool
-type VersiongetBetaArgType = bool
-type VersiongetBetaRetType = bool
-
-func getVersiongetBetaAttributeTypeOk(arg VersiongetBetaAttributeType) (ret VersiongetBetaRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setVersiongetBetaAttributeType(arg *VersiongetBetaAttributeType, val VersiongetBetaRetType) {
- *arg = &val
-}
-
-/*
- types and functions for deprecated
-*/
-
-// isNotNullableString
-type VersionGetDeprecatedAttributeType = *string
-
-func getVersionGetDeprecatedAttributeTypeOk(arg VersionGetDeprecatedAttributeType) (ret VersionGetDeprecatedRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setVersionGetDeprecatedAttributeType(arg *VersionGetDeprecatedAttributeType, val VersionGetDeprecatedRetType) {
- *arg = &val
-}
-
-type VersionGetDeprecatedArgType = string
-type VersionGetDeprecatedRetType = string
-
-/*
- types and functions for recommend
-*/
-
-// isBoolean
-type VersiongetRecommendAttributeType = *bool
-type VersiongetRecommendArgType = bool
-type VersiongetRecommendRetType = bool
-
-func getVersiongetRecommendAttributeTypeOk(arg VersiongetRecommendAttributeType) (ret VersiongetRecommendRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setVersiongetRecommendAttributeType(arg *VersiongetRecommendAttributeType, val VersiongetRecommendRetType) {
- *arg = &val
-}
-
-/*
- types and functions for version
-*/
-
-// isNotNullableString
-type VersionGetVersionAttributeType = *string
-
-func getVersionGetVersionAttributeTypeOk(arg VersionGetVersionAttributeType) (ret VersionGetVersionRetType, ok bool) {
- if arg == nil {
- return ret, false
- }
- return *arg, true
-}
-
-func setVersionGetVersionAttributeType(arg *VersionGetVersionAttributeType, val VersionGetVersionRetType) {
- *arg = &val
-}
-
-type VersionGetVersionArgType = string
-type VersionGetVersionRetType = string
-
-// Version The version of the sqlserver instance and more details.
-type Version struct {
- // Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.
- // REQUIRED
- Beta VersiongetBetaAttributeType `json:"beta" required:"true"`
- // Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.
- // REQUIRED
- Deprecated VersionGetDeprecatedAttributeType `json:"deprecated" required:"true"`
- // Flag if the version is recommend by the STACKIT Team.
- // REQUIRED
- Recommend VersiongetRecommendAttributeType `json:"recommend" required:"true"`
- // The sqlserver version used for the instance.
- // REQUIRED
- Version VersionGetVersionAttributeType `json:"version" required:"true"`
-}
-
-type _Version Version
-
-// NewVersion instantiates a new Version object
-// This constructor will assign default values to properties that have it defined,
-// and makes sure properties required by API are set, but the set of arguments
-// will change when the set of required properties is changed
-func NewVersion(beta VersiongetBetaArgType, deprecated VersionGetDeprecatedArgType, recommend VersiongetRecommendArgType, version VersionGetVersionArgType) *Version {
- this := Version{}
- setVersiongetBetaAttributeType(&this.Beta, beta)
- setVersionGetDeprecatedAttributeType(&this.Deprecated, deprecated)
- setVersiongetRecommendAttributeType(&this.Recommend, recommend)
- setVersionGetVersionAttributeType(&this.Version, version)
- return &this
-}
-
-// NewVersionWithDefaults instantiates a new Version object
-// This constructor will only assign default values to properties that have it defined,
-// but it doesn't guarantee that properties required by API are set
-func NewVersionWithDefaults() *Version {
- this := Version{}
- return &this
-}
-
-// GetBeta returns the Beta field value
-func (o *Version) GetBeta() (ret VersiongetBetaRetType) {
- ret, _ = o.GetBetaOk()
- return ret
-}
-
-// GetBetaOk returns a tuple with the Beta field value
-// and a boolean to check if the value has been set.
-func (o *Version) GetBetaOk() (ret VersiongetBetaRetType, ok bool) {
- return getVersiongetBetaAttributeTypeOk(o.Beta)
-}
-
-// SetBeta sets field value
-func (o *Version) SetBeta(v VersiongetBetaRetType) {
- setVersiongetBetaAttributeType(&o.Beta, v)
-}
-
-// GetDeprecated returns the Deprecated field value
-func (o *Version) GetDeprecated() (ret VersionGetDeprecatedRetType) {
- ret, _ = o.GetDeprecatedOk()
- return ret
-}
-
-// GetDeprecatedOk returns a tuple with the Deprecated field value
-// and a boolean to check if the value has been set.
-func (o *Version) GetDeprecatedOk() (ret VersionGetDeprecatedRetType, ok bool) {
- return getVersionGetDeprecatedAttributeTypeOk(o.Deprecated)
-}
-
-// SetDeprecated sets field value
-func (o *Version) SetDeprecated(v VersionGetDeprecatedRetType) {
- setVersionGetDeprecatedAttributeType(&o.Deprecated, v)
-}
-
-// GetRecommend returns the Recommend field value
-func (o *Version) GetRecommend() (ret VersiongetRecommendRetType) {
- ret, _ = o.GetRecommendOk()
- return ret
-}
-
-// GetRecommendOk returns a tuple with the Recommend field value
-// and a boolean to check if the value has been set.
-func (o *Version) GetRecommendOk() (ret VersiongetRecommendRetType, ok bool) {
- return getVersiongetRecommendAttributeTypeOk(o.Recommend)
-}
-
-// SetRecommend sets field value
-func (o *Version) SetRecommend(v VersiongetRecommendRetType) {
- setVersiongetRecommendAttributeType(&o.Recommend, v)
-}
-
-// GetVersion returns the Version field value
-func (o *Version) GetVersion() (ret VersionGetVersionRetType) {
- ret, _ = o.GetVersionOk()
- return ret
-}
-
-// GetVersionOk returns a tuple with the Version field value
-// and a boolean to check if the value has been set.
-func (o *Version) GetVersionOk() (ret VersionGetVersionRetType, ok bool) {
- return getVersionGetVersionAttributeTypeOk(o.Version)
-}
-
-// SetVersion sets field value
-func (o *Version) SetVersion(v VersionGetVersionRetType) {
- setVersionGetVersionAttributeType(&o.Version, v)
-}
-
-func (o Version) ToMap() (map[string]interface{}, error) {
- toSerialize := map[string]interface{}{}
- if val, ok := getVersiongetBetaAttributeTypeOk(o.Beta); ok {
- toSerialize["Beta"] = val
- }
- if val, ok := getVersionGetDeprecatedAttributeTypeOk(o.Deprecated); ok {
- toSerialize["Deprecated"] = val
- }
- if val, ok := getVersiongetRecommendAttributeTypeOk(o.Recommend); ok {
- toSerialize["Recommend"] = val
- }
- if val, ok := getVersionGetVersionAttributeTypeOk(o.Version); ok {
- toSerialize["Version"] = val
- }
- return toSerialize, nil
-}
-
-type NullableVersion struct {
- value *Version
- isSet bool
-}
-
-func (v NullableVersion) Get() *Version {
- return v.value
-}
-
-func (v *NullableVersion) Set(val *Version) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableVersion) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableVersion) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableVersion(val *Version) *NullableVersion {
- return &NullableVersion{value: val, isSet: true}
-}
-
-func (v NullableVersion) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableVersion) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
diff --git a/pkg/sqlserverflexalpha/model_version_test.go b/pkg/sqlserverflexalpha/model_version_test.go
deleted file mode 100644
index f551e1f0..00000000
--- a/pkg/sqlserverflexalpha/model_version_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
diff --git a/pkg/sqlserverflexalpha/utils.go b/pkg/sqlserverflexalpha/utils.go
deleted file mode 100644
index 5d52a8ba..00000000
--- a/pkg/sqlserverflexalpha/utils.go
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
-STACKIT MSSQL Service API
-
-This is the documentation for the STACKIT MSSQL service
-
-API version: 3alpha1
-*/
-
-// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
-
-package sqlserverflexalpha
-
-import (
- "encoding/json"
- "math/rand"
- "reflect"
- "time"
-)
-
-// PtrBool is a helper routine that returns a pointer to given boolean value.
-func PtrBool(v bool) *bool { return &v }
-
-// PtrInt is a helper routine that returns a pointer to given integer value.
-func PtrInt(v int) *int { return &v }
-
-// PtrInt32 is a helper routine that returns a pointer to given integer value.
-func PtrInt32(v int32) *int32 { return &v }
-
-// PtrInt64 is a helper routine that returns a pointer to given integer value.
-func PtrInt64(v int64) *int64 { return &v }
-
-// PtrFloat32 is a helper routine that returns a pointer to given float value.
-func PtrFloat32(v float32) *float32 { return &v }
-
-// PtrFloat64 is a helper routine that returns a pointer to given float value.
-func PtrFloat64(v float64) *float64 { return &v }
-
-// PtrString is a helper routine that returns a pointer to given string value.
-func PtrString(v string) *string { return &v }
-
-// PtrTime is helper routine that returns a pointer to given Time value.
-func PtrTime(v time.Time) *time.Time { return &v }
-
-type NullableValue[T any] struct {
- value *T
- isSet bool
-}
-
-func (v NullableValue[T]) Get() *T {
- return v.value
-}
-
-func (v *NullableValue[T]) Set(val *T) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableValue[T]) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableValue[T]) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-type NullableBool struct {
- value *bool
- isSet bool
-}
-
-func (v NullableBool) Get() *bool {
- return v.value
-}
-
-func (v *NullableBool) Set(val *bool) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableBool) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableBool) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableBool(val *bool) *NullableBool {
- return &NullableBool{value: val, isSet: true}
-}
-
-func (v NullableBool) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableBool) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableInt struct {
- value *int
- isSet bool
-}
-
-func (v NullableInt) Get() *int {
- return v.value
-}
-
-func (v *NullableInt) Set(val *int) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInt) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInt) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInt(val *int) *NullableInt {
- return &NullableInt{value: val, isSet: true}
-}
-
-func (v NullableInt) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInt) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableInt32 struct {
- value *int32
- isSet bool
-}
-
-func (v NullableInt32) Get() *int32 {
- return v.value
-}
-
-func (v *NullableInt32) Set(val *int32) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInt32) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInt32) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInt32(val *int32) *NullableInt32 {
- return &NullableInt32{value: val, isSet: true}
-}
-
-func (v NullableInt32) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInt32) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableInt64 struct {
- value *int64
- isSet bool
-}
-
-func (v NullableInt64) Get() *int64 {
- return v.value
-}
-
-func (v *NullableInt64) Set(val *int64) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableInt64) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableInt64) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableInt64(val *int64) *NullableInt64 {
- return &NullableInt64{value: val, isSet: true}
-}
-
-func (v NullableInt64) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableInt64) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableFloat32 struct {
- value *float32
- isSet bool
-}
-
-func (v NullableFloat32) Get() *float32 {
- return v.value
-}
-
-func (v *NullableFloat32) Set(val *float32) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableFloat32) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableFloat32) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableFloat32(val *float32) *NullableFloat32 {
- return &NullableFloat32{value: val, isSet: true}
-}
-
-func (v NullableFloat32) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableFloat32) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableFloat64 struct {
- value *float64
- isSet bool
-}
-
-func (v NullableFloat64) Get() *float64 {
- return v.value
-}
-
-func (v *NullableFloat64) Set(val *float64) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableFloat64) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableFloat64) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableFloat64(val *float64) *NullableFloat64 {
- return &NullableFloat64{value: val, isSet: true}
-}
-
-func (v NullableFloat64) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableFloat64) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableString struct {
- value *string
- isSet bool
-}
-
-func (v NullableString) Get() *string {
- return v.value
-}
-
-func (v *NullableString) Set(val *string) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableString) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableString) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableString(val *string) *NullableString {
- return &NullableString{value: val, isSet: true}
-}
-
-func (v NullableString) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.value)
-}
-
-func (v *NullableString) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-type NullableTime struct {
- value *time.Time
- isSet bool
-}
-
-func (v NullableTime) Get() *time.Time {
- return v.value
-}
-
-func (v *NullableTime) Set(val *time.Time) {
- v.value = val
- v.isSet = true
-}
-
-func (v NullableTime) IsSet() bool {
- return v.isSet
-}
-
-func (v *NullableTime) Unset() {
- v.value = nil
- v.isSet = false
-}
-
-func NewNullableTime(val *time.Time) *NullableTime {
- return &NullableTime{value: val, isSet: true}
-}
-
-func (v NullableTime) MarshalJSON() ([]byte, error) {
- return v.value.MarshalJSON()
-}
-
-func (v *NullableTime) UnmarshalJSON(src []byte) error {
- v.isSet = true
- return json.Unmarshal(src, &v.value)
-}
-
-// IsNil checks if an input is nil
-func IsNil(i interface{}) bool {
- if i == nil {
- return true
- }
- if t, ok := i.(interface{ IsSet() bool }); ok {
- return !t.IsSet()
- }
- switch reflect.TypeOf(i).Kind() {
- case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice:
- return reflect.ValueOf(i).IsNil()
- case reflect.Array:
- return reflect.ValueOf(i).IsZero()
- }
- return false
-}
-
-type MappedNullable interface {
- ToMap() (map[string]interface{}, error)
-}
-
-const letterRunes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-
-// randString returns a random string with a specified length. It panics if n <= 0.
-func randString(n int) string {
- b := make([]byte, n)
- for i := range b {
- b[i] = letterRunes[rand.Intn(len(letterRunes))]
- }
- return string(b)
-}
diff --git a/pkg/sqlserverflexalpha/wait/wait.go b/pkg/sqlserverflexalpha/wait/wait.go
deleted file mode 100644
index 025720e5..00000000
--- a/pkg/sqlserverflexalpha/wait/wait.go
+++ /dev/null
@@ -1,101 +0,0 @@
-package wait
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "strings"
- "time"
-
- "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
- "github.com/stackitcloud/stackit-sdk-go/core/wait"
- sqlserverflex "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
-)
-
-const (
- InstanceStateEmpty = ""
- InstanceStateProcessing = "Progressing"
- InstanceStateUnknown = "Unknown"
- InstanceStateSuccess = "Ready"
- InstanceStateFailed = "Failed"
-)
-
-// Interface needed for tests
-type APIClientInstanceInterface interface {
- GetInstanceRequestExecute(ctx context.Context, projectId, region, instanceId string) (*sqlserverflex.GetInstanceResponse, error)
-}
-
-// CreateInstanceWaitHandler will wait for instance creation
-func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
- handler := wait.New(func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
- s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
- if err != nil {
- return false, nil, err
- }
- if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
- return false, nil, nil
- }
- switch strings.ToLower(string(*s.Status)) {
- case strings.ToLower(InstanceStateSuccess):
- return true, s, nil
- case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed):
- return true, s, fmt.Errorf("create failed for instance with id %s", instanceId)
- default:
- return false, s, nil
- }
- })
- handler.SetTimeout(45 * time.Minute)
- handler.SetSleepBeforeWait(5 * time.Second)
- return handler
-}
-
-// UpdateInstanceWaitHandler will wait for instance update
-func UpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
- handler := wait.New(func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
- s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
- if err != nil {
- return false, nil, err
- }
- if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
- return false, nil, nil
- }
- switch strings.ToLower(string(*s.Status)) {
- case strings.ToLower(InstanceStateSuccess):
- return true, s, nil
- case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed):
- return true, s, fmt.Errorf("update failed for instance with id %s", instanceId)
- default:
- return false, s, nil
- }
- })
- handler.SetSleepBeforeWait(2 * time.Second)
- handler.SetTimeout(45 * time.Minute)
- return handler
-}
-
-// PartialUpdateInstanceWaitHandler will wait for instance update
-func PartialUpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
- return UpdateInstanceWaitHandler(ctx, a, projectId, instanceId, region)
-}
-
-// DeleteInstanceWaitHandler will wait for instance deletion
-func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[struct{}] {
- handler := wait.New(func() (waitFinished bool, response *struct{}, err error) {
- _, err = a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
- if err == nil {
- return false, nil, nil
- }
- var oapiErr *oapierror.GenericOpenAPIError
- ok := errors.As(err, &oapiErr)
- if !ok {
- return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
- }
- if oapiErr.StatusCode != http.StatusNotFound {
- return false, nil, err
- }
- return true, nil, nil
- })
- handler.SetTimeout(15 * time.Minute)
- return handler
-}
diff --git a/pkg/sqlserverflexalpha/wait/wait_test.go b/pkg/sqlserverflexalpha/wait/wait_test.go
deleted file mode 100644
index 2d194112..00000000
--- a/pkg/sqlserverflexalpha/wait/wait_test.go
+++ /dev/null
@@ -1,236 +0,0 @@
-package wait
-
-import (
- "context"
- "testing"
- "time"
-
- "github.com/google/go-cmp/cmp"
- "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
- "github.com/stackitcloud/stackit-sdk-go/core/utils"
- sqlserverflex "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
-)
-
-// Used for testing instance operations
-type apiClientInstanceMocked struct {
- instanceId string
- instanceState string
- instanceIsDeleted bool
- instanceGetFails bool
-}
-
-func (a *apiClientInstanceMocked) GetInstanceRequestExecute(_ context.Context, _, _, _ string) (*sqlserverflex.GetInstanceResponse, error) {
- if a.instanceGetFails {
- return nil, &oapierror.GenericOpenAPIError{
- StatusCode: 500,
- }
- }
-
- if a.instanceIsDeleted {
- return nil, &oapierror.GenericOpenAPIError{
- StatusCode: 404,
- }
- }
-
- return &sqlserverflex.GetInstanceResponse{
- Id: &a.instanceId,
- Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(&a.instanceState),
- }, nil
-}
-func TestCreateInstanceWaitHandler(t *testing.T) {
- tests := []struct {
- desc string
- instanceGetFails bool
- instanceState string
- usersGetErrorStatus int
- wantErr bool
- wantResp bool
- }{
- {
- desc: "create_succeeded",
- instanceGetFails: false,
- instanceState: InstanceStateSuccess,
- wantErr: false,
- wantResp: true,
- },
- {
- desc: "create_failed",
- instanceGetFails: false,
- instanceState: InstanceStateFailed,
- wantErr: true,
- wantResp: true,
- },
- {
- desc: "create_failed_2",
- instanceGetFails: false,
- instanceState: InstanceStateEmpty,
- wantErr: true,
- wantResp: true,
- },
- {
- desc: "instance_get_fails",
- instanceGetFails: true,
- wantErr: true,
- wantResp: false,
- },
- {
- desc: "timeout",
- instanceGetFails: false,
- instanceState: InstanceStateProcessing,
- wantErr: true,
- wantResp: true,
- },
- }
- for _, tt := range tests {
- t.Run(tt.desc, func(t *testing.T) {
- instanceId := "foo-bar"
-
- apiClient := &apiClientInstanceMocked{
- instanceId: instanceId,
- instanceState: tt.instanceState,
- instanceGetFails: tt.instanceGetFails,
- }
-
- var wantRes *sqlserverflex.GetInstanceResponse
- if tt.wantResp {
- wantRes = &sqlserverflex.GetInstanceResponse{
- Id: &instanceId,
- Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(tt.instanceState)),
- }
- }
-
- handler := CreateInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "")
-
- gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
-
- if (err != nil) != tt.wantErr {
- t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
- }
- if !cmp.Equal(gotRes, wantRes) {
- t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
- }
- })
- }
-}
-
-func TestUpdateInstanceWaitHandler(t *testing.T) {
- tests := []struct {
- desc string
- instanceGetFails bool
- instanceState string
- wantErr bool
- wantResp bool
- }{
- {
- desc: "update_succeeded",
- instanceGetFails: false,
- instanceState: InstanceStateSuccess,
- wantErr: false,
- wantResp: true,
- },
- {
- desc: "update_failed",
- instanceGetFails: false,
- instanceState: InstanceStateFailed,
- wantErr: true,
- wantResp: true,
- },
- {
- desc: "update_failed_2",
- instanceGetFails: false,
- instanceState: InstanceStateEmpty,
- wantErr: true,
- wantResp: true,
- },
- {
- desc: "get_fails",
- instanceGetFails: true,
- wantErr: true,
- wantResp: false,
- },
- {
- desc: "timeout",
- instanceGetFails: false,
- instanceState: InstanceStateProcessing,
- wantErr: true,
- wantResp: true,
- },
- }
- for _, tt := range tests {
- t.Run(tt.desc, func(t *testing.T) {
- instanceId := "foo-bar"
-
- apiClient := &apiClientInstanceMocked{
- instanceId: instanceId,
- instanceState: tt.instanceState,
- instanceGetFails: tt.instanceGetFails,
- }
-
- var wantRes *sqlserverflex.GetInstanceResponse
- if tt.wantResp {
- wantRes = &sqlserverflex.GetInstanceResponse{
- Id: &instanceId,
- Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(tt.instanceState)),
- }
- }
-
- handler := UpdateInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "")
-
- gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
-
- if (err != nil) != tt.wantErr {
- t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
- }
- if !cmp.Equal(gotRes, wantRes) {
- t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
- }
- })
- }
-}
-
-func TestDeleteInstanceWaitHandler(t *testing.T) {
- tests := []struct {
- desc string
- instanceGetFails bool
- instanceState string
- wantErr bool
- }{
- {
- desc: "delete_succeeded",
- instanceGetFails: false,
- instanceState: InstanceStateSuccess,
- wantErr: false,
- },
- {
- desc: "delete_failed",
- instanceGetFails: false,
- instanceState: InstanceStateFailed,
- wantErr: true,
- },
- {
- desc: "get_fails",
- instanceGetFails: true,
- wantErr: true,
- },
- }
- for _, tt := range tests {
- t.Run(tt.desc, func(t *testing.T) {
- instanceId := "foo-bar"
-
- apiClient := &apiClientInstanceMocked{
- instanceGetFails: tt.instanceGetFails,
- instanceIsDeleted: tt.instanceState == InstanceStateSuccess,
- instanceId: instanceId,
- instanceState: tt.instanceState,
- }
-
- handler := DeleteInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "")
-
- _, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
-
- if (err != nil) != tt.wantErr {
- t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
-}
diff --git a/sample/sample.tfrc.example b/sample/config.tfrc.example
similarity index 75%
rename from sample/sample.tfrc.example
rename to sample/config.tfrc.example
index 98ddc32d..a9adc18f 100644
--- a/sample/sample.tfrc.example
+++ b/sample/config.tfrc.example
@@ -1,6 +1,6 @@
provider_installation {
dev_overrides {
- "registry.terraform.io/stackitcloud/stackitalpha" = "/bin/"
+ "registry.terraform.io/mhenselin/stackitprivatepreview" = "/bin/"
}
# For all other providers, install them directly from their origin provider
diff --git a/sample/main.tf b/sample/main.tf
deleted file mode 100644
index f87ce3f9..00000000
--- a/sample/main.tf
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright (c) STACKIT
-
-resource "stackitalpha_kms_keyring" "keyring" {
- project_id = var.project_id
- display_name = "keyring01"
- description = "This is a test keyring for private endpoints"
-}
-
-resource "stackitalpha_kms_key" "key" {
- project_id = var.project_id
- keyring_id = stackitalpha_kms_keyring.keyring.keyring_id
- display_name = "key01"
- protection = "software"
- algorithm = "aes_256_gcm"
- purpose = "symmetric_encrypt_decrypt"
- access_scope = "SNA"
-}
-
-resource "stackitalpha_postgresflexalpha_instance" "ptlsdbsrv" {
- project_id = var.project_id
- name = "example-instance"
- acl = ["0.0.0.0/0"]
- backup_schedule = "0 0 * * *"
- flavor = {
- cpu = 2
- ram = 4
- }
- replicas = 3
- storage = {
- class = "premium-perf12-stackit"
- size = 5
- }
- version = 14
- encryption = {
- key_id = stackitalpha_kms_key.key.id
- key_ring_id = stackitalpha_kms_keyring.keyring.keyring_id
- key_version = "1"
- service_account = var.sa_email
- }
- network = {
- access_scope = "SNA"
- }
-}
diff --git a/sample/postgres/outputs.tf b/sample/postgres/outputs.tf
new file mode 100644
index 00000000..674ca8b9
--- /dev/null
+++ b/sample/postgres/outputs.tf
@@ -0,0 +1,4 @@
+
+output "postgres_flavor" {
+ value = data.stackitprivatepreview_postgresflexalpha_flavor.pgsql_flavor.flavor_id
+}
diff --git a/sample/postgres/postresql.tf b/sample/postgres/postresql.tf
new file mode 100644
index 00000000..531b17e2
--- /dev/null
+++ b/sample/postgres/postresql.tf
@@ -0,0 +1,116 @@
+
+data "stackitprivatepreview_postgresflexalpha_flavor" "pgsql_flavor" {
+ project_id = var.project_id
+ region = "eu01"
+ cpu = 2
+ ram = 4
+ node_type = "Single"
+ storage_class = "premium-perf2-stackit"
+}
+
+resource "stackitprivatepreview_postgresflexalpha_instance" "msh-sna-pe-example" {
+ project_id = var.project_id
+ name = "mshpetest2"
+ backup_schedule = "0 0 * * *"
+ retention_days = 45
+ flavor_id = data.stackitprivatepreview_postgresflexalpha_flavor.pgsql_flavor.flavor_id
+ replicas = 1
+ storage = {
+ # class = "premium-perf2-stackit"
+ performance_class = "premium-perf2-stackit"
+ size = 10
+ }
+ encryption = {
+ # key_id = stackit_kms_key.key.key_id
+ # keyring_id = stackit_kms_keyring.keyring.keyring_id
+ kek_key_id = var.key_id
+ kek_key_ring_id = var.keyring_id
+ kek_key_version = var.key_version
+ service_account = var.sa_email
+ }
+ network = {
+ acl = ["0.0.0.0/0", "193.148.160.0/19", "170.85.2.177/32"]
+ access_scope = "PUBLIC"
+ }
+ version = 17
+}
+
+resource "stackitprivatepreview_postgresflexalpha_instance" "msh-sna-pe-example2" {
+ project_id = var.project_id
+ name = "mshpetest2-1"
+ backup_schedule = "0 0 * * *"
+ retention_days = 45
+ flavor_id = data.stackitprivatepreview_postgresflexalpha_flavor.pgsql_flavor.flavor_id
+ replicas = 1
+ storage = {
+ # class = "premium-perf2-stackit"
+ performance_class = "premium-perf2-stackit"
+ size = 10
+ }
+ encryption = {
+ # key_id = stackit_kms_key.key.key_id
+ # keyring_id = stackit_kms_keyring.keyring.keyring_id
+ kek_key_id = var.key_id
+ kek_key_ring_id = var.keyring_id
+ kek_key_version = var.key_version
+ service_account = var.sa_email
+ }
+ network = {
+ acl = ["0.0.0.0/0", "193.148.160.0/19", "170.85.2.177/32"]
+ access_scope = "SNA"
+ }
+ version = 16
+}
+
+resource "stackitprivatepreview_postgresflexalpha_user" "ptlsdbadminuser" {
+ project_id = var.project_id
+ instance_id = stackitprivatepreview_postgresflexalpha_instance.msh-sna-pe-example.instance_id
+ name = var.db_admin_username
+ roles = ["createdb", "login", "login"]
+ # roles = ["createdb", "login", "createrole"]
+}
+
+resource "stackitprivatepreview_postgresflexalpha_user" "ptlsdbadminuser2" {
+ project_id = var.project_id
+ instance_id = stackitprivatepreview_postgresflexalpha_instance.msh-sna-pe-example2.instance_id
+ name = var.db_admin_username
+ roles = ["createdb", "login"]
+ # roles = ["createdb", "login", "createrole"]
+}
+
+resource "stackitprivatepreview_postgresflexalpha_user" "ptlsdbuser" {
+ project_id = var.project_id
+ instance_id = stackitprivatepreview_postgresflexalpha_instance.msh-sna-pe-example.instance_id
+ name = var.db_name
+ roles = ["login"]
+ # roles = ["createdb", "login", "createrole"]
+}
+
+resource "stackitprivatepreview_postgresflexalpha_database" "example" {
+ count = 5
+ depends_on = [stackitprivatepreview_postgresflexalpha_user.ptlsdbadminuser]
+ project_id = var.project_id
+ instance_id = stackitprivatepreview_postgresflexalpha_instance.msh-sna-pe-example.instance_id
+ name = "${var.db_name}${count.index}"
+ owner = var.db_admin_username
+}
+
+# data "stackitprivatepreview_postgresflexalpha_instance" "datapsql" {
+# project_id = var.project_id
+# instance_id = var.instance_id
+# region = "eu01"
+# }
+
+# output "psql_instance_id" {
+# value = data.stackitprivatepreview_postgresflexalpha_instance.datapsql.instance_id
+# }
+
+output "psql_user_password" {
+ value = stackitprivatepreview_postgresflexalpha_user.ptlsdbuser.password
+ sensitive = true
+}
+
+output "psql_user_conn" {
+ value = stackitprivatepreview_postgresflexalpha_user.ptlsdbuser.connection_string
+ sensitive = true
+}
diff --git a/sample/postgres/providers.tf b/sample/postgres/providers.tf
new file mode 100644
index 00000000..5a54a129
--- /dev/null
+++ b/sample/postgres/providers.tf
@@ -0,0 +1,25 @@
+
+terraform {
+ required_providers {
+ # stackit = {
+ # source = "registry.terraform.io/stackitcloud/stackit"
+ # version = "~> 0.70"
+ # }
+ stackitprivatepreview = {
+ source = "tfregistry.sysops.stackit.rocks/mhenselin/stackitprivatepreview"
+ version = "> 0.0"
+ }
+ }
+}
+
+# provider "stackit" {
+# default_region = "eu01"
+# enable_beta_resources = true
+# service_account_key_path = "./service_account.json"
+# }
+
+provider "stackitprivatepreview" {
+ default_region = "eu01"
+ enable_beta_resources = true
+ service_account_key_path = "../service_account.json"
+}
diff --git a/sample/variables.tf.example b/sample/postgres/variables.tf.example
similarity index 100%
rename from sample/variables.tf.example
rename to sample/postgres/variables.tf.example
diff --git a/sample/providers.tf b/sample/providers.tf
deleted file mode 100644
index 8af98505..00000000
--- a/sample/providers.tf
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (c) STACKIT
-
-terraform {
- required_providers {
- stackitalpha = {
- source = "registry.terraform.io/stackitcloud/stackitalpha"
- version = "~> 0.1"
- }
- }
-}
-
-provider "stackitalpha" {
- default_region = "eu01"
- enable_beta_resources = true
- service_account_key_path = "./service_account.json"
-}
diff --git a/sample/sqlserver/flavor.tf b/sample/sqlserver/flavor.tf
new file mode 100644
index 00000000..c491cc09
--- /dev/null
+++ b/sample/sqlserver/flavor.tf
@@ -0,0 +1,13 @@
+
+data "stackitprivatepreview_sqlserverflexbeta_flavor" "sqlserver_flavor" {
+ project_id = var.project_id
+ region = "eu01"
+ cpu = 4
+ ram = 16
+ node_type = "Single"
+ storage_class = "premium-perf2-stackit"
+}
+
+output "sqlserver_flavor" {
+ value = data.stackitprivatepreview_sqlserverflexbeta_flavor.sqlserver_flavor.flavor_id
+}
diff --git a/sample/sqlserver/providers.tf b/sample/sqlserver/providers.tf
new file mode 100644
index 00000000..233d4df2
--- /dev/null
+++ b/sample/sqlserver/providers.tf
@@ -0,0 +1,25 @@
+
+terraform {
+ required_providers {
+ # stackit = {
+ # source = "registry.terraform.io/stackitcloud/stackit"
+ # version = "~> 0.70"
+ # }
+ stackitprivatepreview = {
+ source = "tfregistry.sysops.stackit.rocks/mhenselin/stackitprivatepreview"
+ version = "> 0.0"
+ }
+ }
+}
+
+# provider "stackit" {
+# default_region = "eu01"
+# enable_beta_resources = true
+# service_account_key_path = "../service_account.json"
+# }
+
+provider "stackitprivatepreview" {
+ default_region = "eu01"
+ enable_beta_resources = true
+ service_account_key_path = "../service_account.json"
+}
diff --git a/sample/sqlserver/sqlserver.tf b/sample/sqlserver/sqlserver.tf
new file mode 100644
index 00000000..d18f499c
--- /dev/null
+++ b/sample/sqlserver/sqlserver.tf
@@ -0,0 +1,63 @@
+# resource "stackit_kms_keyring" "keyring" {
+# project_id = var.project_id
+# display_name = "msh-keyring01"
+# description = "This is a test keyring for private endpoints"
+# }
+#
+# resource "stackit_kms_key" "key" {
+# project_id = var.project_id
+# keyring_id = stackit_kms_keyring.keyring.keyring_id
+# display_name = "msh-key01"
+# protection = "software"
+# algorithm = "aes_256_gcm"
+# purpose = "symmetric_encrypt_decrypt"
+# access_scope = "SNA"
+# }
+#
+# output "keyid" {
+# value = stackit_kms_key.key.key_id
+# }
+
+resource "stackitprivatepreview_sqlserverflexbeta_instance" "msh-beta-sna-001" {
+ project_id = var.project_id
+ name = "msh-beta-sna-001"
+ backup_schedule = "0 3 * * *"
+ retention_days = 31
+ flavor_id = data.stackitprivatepreview_sqlserverflexbeta_flavor.sqlserver_flavor.flavor_id
+ storage = {
+ class = "premium-perf2-stackit"
+ size = 10
+ }
+ version = 2022
+ encryption = {
+ #key_id = stackit_kms_key.key.key_id
+ #keyring_id = stackit_kms_keyring.keyring.keyring_id
+ #key_version = 1
+ # key with scope public
+ # kek_key_id = "fe039bcf-8d7b-431a-801d-9e81371a6b7b"
+ kek_key_id = "c6878f92-ce55-4b79-8236-ba9d001d7967" # msh-k-001
+ # key_id = var.key_id
+ # kek_key_ring_id = var.keyring_id
+ kek_key_ring_id = "0dea3f5f-9947-4dda-a9d3-18418832cefe" # msh-kr-sna01
+ kek_key_version = var.key_version
+ service_account = var.sa_email
+ }
+ network = {
+ acl = ["0.0.0.0/0", "193.148.160.0/19"]
+ access_scope = "SNA"
+ }
+}
+
+resource "stackitprivatepreview_sqlserverflexbeta_user" "betauser" {
+ project_id = var.project_id
+ instance_id = stackitprivatepreview_sqlserverflexbeta_instance.msh-beta-sna-001.instance_id
+ username = "betauser"
+ roles = ["##STACKIT_DatabaseManager##", "##STACKIT_LoginManager##"]
+}
+
+resource "stackitprivatepreview_sqlserverflexbeta_database" "betadb" {
+ project_id = var.project_id
+ instance_id = stackitprivatepreview_sqlserverflexbeta_instance.msh-beta-sna-001.instance_id
+ name = "mshtest002"
+ owner = stackitprivatepreview_sqlserverflexbeta_user.betauser.username
+}
diff --git a/sample/sqlserver/variables.tf.example b/sample/sqlserver/variables.tf.example
new file mode 100644
index 00000000..51a70be4
--- /dev/null
+++ b/sample/sqlserver/variables.tf.example
@@ -0,0 +1,11 @@
+variable "project_id" {
+ default = ""
+}
+
+variable "sa_email" {
+ default = ""
+}
+
+variable "db_username" {
+ default = ""
+}
diff --git a/sample/tf.sh b/sample/tf.sh
index 9f597428..8feaf799 100755
--- a/sample/tf.sh
+++ b/sample/tf.sh
@@ -1,9 +1,53 @@
#!/usr/bin/env bash
-# Copyright (c) STACKIT
-# copy or rename sample.tfrc.example and adjust it
-TERRAFORM_CONFIG=$(pwd)/sample.tfrc
+
+# ./tf.sh apply > >(tee -a stdout.log) 2> >(tee -a stderr.log >&2)
+
+usage() {
+ echo "$0 usage:" && grep "[[:space:]].)\ #" "$0" | sed 's/#//' | sed -r 's/([a-z])\)/-\1/';
+ exit 0;
+}
+
+[ $# -eq 0 ] && usage
+
+CONFIG_FOLDER=$(dirname "$0")
+BINARY=terraform
+
+ADD=""
+
+while getopts ":b:hdirt" arg; do
+ case $arg in
+ b) # Set binary (default is terraform).
+ BINARY=${OPTARG}
+ shift 2
+ ;;
+ d) # Set log level to DEBUG.
+ TF_LOG=DEBUG
+ export TF_LOG
+ shift
+ ;;
+ i) # Set log level to INFO.
+ TF_LOG=INFO
+ export TF_LOG
+ shift
+ ;;
+ r) # Set log level to INFO.
+ ADD="-refresh-only"
+ shift
+ ;;
+ t) # Set log level to TRACE.
+ TF_LOG=TRACE
+ export TF_LOG
+ shift
+ ;;
+ h | *) # Display help.
+ usage
+ ;;
+ esac
+done
+
+TERRAFORM_CONFIG=${CONFIG_FOLDER}/config.tfrc
export TERRAFORM_CONFIG
-terraform "$1"
+${BINARY} "$@" ${ADD}
diff --git a/sample/tofu.sh b/sample/tofu.sh
deleted file mode 100755
index bea0e72c..00000000
--- a/sample/tofu.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env bash
-# Copyright (c) STACKIT
-
-
-# copy or rename sample.tfrc.example and adjust it
-TERRAFORM_CONFIG=$(pwd)/sample.tfrc
-export TERRAFORM_CONFIG
-
-tofu "$1"
diff --git a/sample/user.tf b/sample/user.tf
deleted file mode 100644
index 5729307b..00000000
--- a/sample/user.tf
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright (c) STACKIT
-
-resource "stackit_sqlserverflexalpha_user" "ptlsdbuser" {
- project_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.project_id
- instance_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.id
- username = var.db_username
- roles = ["createdb", "login", "createrole"]
-}
\ No newline at end of file
diff --git a/scripts/check-docs.sh b/scripts/check-docs.sh
index 602244cf..f741baf4 100755
--- a/scripts/check-docs.sh
+++ b/scripts/check-docs.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-# Copyright (c) STACKIT
# This script is used to ensure for PRs the docs are up-to-date via the CI pipeline
@@ -11,7 +10,7 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
before_hash=$(find docs -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}')
# re-generate the docs
-$ROOT_DIR/scripts/tfplugindocs.sh
+"${ROOT_DIR}/scripts/tfplugindocs.sh"
after_hash=$(find docs -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}')
diff --git a/scripts/lint-golangci-lint.sh b/scripts/lint-golangci-lint.sh
deleted file mode 100755
index b9e07251..00000000
--- a/scripts/lint-golangci-lint.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env bash
-# Copyright (c) STACKIT
-
-# This script lints the SDK modules and the internal examples
-# Pre-requisites: golangci-lint
-set -eo pipefail
-
-ROOT_DIR=$(git rev-parse --show-toplevel)
-GOLANG_CI_YAML_PATH="${ROOT_DIR}/golang-ci.yaml"
-GOLANG_CI_ARGS="--allow-parallel-runners --timeout=5m --config=${GOLANG_CI_YAML_PATH}"
-
-if type -p golangci-lint >/dev/null; then
- :
-else
- echo "golangci-lint not installed, unable to proceed."
- exit 1
-fi
-
-cd ${ROOT_DIR}
-golangci-lint run ${GOLANG_CI_ARGS}
diff --git a/scripts/project.sh b/scripts/project.sh
index 159ba952..68585774 100755
--- a/scripts/project.sh
+++ b/scripts/project.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-# Copyright (c) STACKIT
# This script is used to manage the project, only used for installing the required tools for now
@@ -18,8 +17,7 @@ elif [ "$action" = "tools" ]; then
go mod download
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0
- go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.21.0
+ go install golang.org/x/tools/cmd/goimports@v0.42.0
else
echo "Invalid action: '$action', please use $0 help for help"
fi
diff --git a/scripts/replace.sh b/scripts/replace.sh
index 953ac6e0..a3169638 100755
--- a/scripts/replace.sh
+++ b/scripts/replace.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-# Copyright (c) STACKIT
# Add replace directives to local files to go.work
set -eo pipefail
diff --git a/scripts/tfplugindocs.sh b/scripts/tfplugindocs.sh
index 8c79e7ef..e77b6a98 100755
--- a/scripts/tfplugindocs.sh
+++ b/scripts/tfplugindocs.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-# Copyright (c) STACKIT
# Pre-requisites: tfplugindocs
set -eo pipefail
@@ -15,5 +14,5 @@ fi
mkdir -p ${ROOT_DIR}/docs
echo ">> Generating documentation"
-tfplugindocs generate \
+go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate \
--provider-name "stackitprivatepreview"
diff --git a/service_specs/postgres-flex/alpha/database_config.yml b/service_specs/postgres-flex/alpha/database_config.yml
new file mode 100644
index 00000000..c7bb4e29
--- /dev/null
+++ b/service_specs/postgres-flex/alpha/database_config.yml
@@ -0,0 +1,28 @@
+provider:
+ name: stackitprivatepreview
+
+resources:
+ database:
+ create:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases
+ method: POST
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}
+ method: GET
+ update:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}
+ method: PUT
+ delete:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}
+ method: DELETE
+
+data_sources:
+ database:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}
+ method: GET
+
+ databases:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases
+ method: GET
diff --git a/service_specs/postgres-flex/alpha/flavors_config.yml b/service_specs/postgres-flex/alpha/flavors_config.yml
new file mode 100644
index 00000000..ad0f33e5
--- /dev/null
+++ b/service_specs/postgres-flex/alpha/flavors_config.yml
@@ -0,0 +1,9 @@
+
+provider:
+ name: stackitprivatepreview
+
+data_sources:
+ flavors:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/flavors
+ method: GET
diff --git a/service_specs/postgres-flex/alpha/instance_config.yml b/service_specs/postgres-flex/alpha/instance_config.yml
new file mode 100644
index 00000000..91d70ed6
--- /dev/null
+++ b/service_specs/postgres-flex/alpha/instance_config.yml
@@ -0,0 +1,35 @@
+
+provider:
+ name: stackitprivatepreview
+
+resources:
+ instance:
+ schema:
+ attributes:
+ name:
+ plan_modifiers:
+ - UseStateForUnknown
+
+ create:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances
+ method: POST
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: GET
+ update:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: PUT
+ delete:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: DELETE
+
+data_sources:
+ instances:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances
+ method: GET
+
+ instance:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: GET
diff --git a/service_specs/postgres-flex/alpha/role_config.yml b/service_specs/postgres-flex/alpha/role_config.yml
new file mode 100644
index 00000000..74ae78f9
--- /dev/null
+++ b/service_specs/postgres-flex/alpha/role_config.yml
@@ -0,0 +1,9 @@
+
+provider:
+ name: stackitprivatepreview
+
+data_sources:
+ roles:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/roles
+ method: GET
diff --git a/service_specs/postgres-flex/alpha/user_config.yml b/service_specs/postgres-flex/alpha/user_config.yml
new file mode 100644
index 00000000..2ce03079
--- /dev/null
+++ b/service_specs/postgres-flex/alpha/user_config.yml
@@ -0,0 +1,29 @@
+
+provider:
+ name: stackitprivatepreview
+
+resources:
+ user:
+ create:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users
+ method: POST
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}
+ method: GET
+ update:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}
+ method: PUT
+ delete:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}
+ method: DELETE
+
+data_sources:
+ users:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users
+ method: GET
+
+ user:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}
+ method: GET
diff --git a/service_specs/postgres-flex/alpha/version_config.yml b/service_specs/postgres-flex/alpha/version_config.yml
new file mode 100644
index 00000000..937dccd5
--- /dev/null
+++ b/service_specs/postgres-flex/alpha/version_config.yml
@@ -0,0 +1,9 @@
+
+provider:
+ name: stackitprivatepreview
+
+data_sources:
+ versions:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/versions
+ method: GET
diff --git a/service_specs/sqlserverflex/alpha/backup_config.yml.disabled b/service_specs/sqlserverflex/alpha/backup_config.yml.disabled
new file mode 100644
index 00000000..c75d34ef
--- /dev/null
+++ b/service_specs/sqlserverflex/alpha/backup_config.yml.disabled
@@ -0,0 +1,13 @@
+provider:
+ name: stackitprivatepreview
+
+data_sources:
+ backups:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups
+ method: GET
+
+ backup:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/{backupId}
+ method: GET
diff --git a/service_specs/sqlserverflex/alpha/collation_config.yml.bak b/service_specs/sqlserverflex/alpha/collation_config.yml.bak
new file mode 100644
index 00000000..9ebfe5b4
--- /dev/null
+++ b/service_specs/sqlserverflex/alpha/collation_config.yml.bak
@@ -0,0 +1,8 @@
+provider:
+ name: stackitprivatepreview
+
+data_sources:
+ collations:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/collations
+ method: GET
diff --git a/service_specs/sqlserverflex/alpha/database_config.yml b/service_specs/sqlserverflex/alpha/database_config.yml
new file mode 100644
index 00000000..cd592e80
--- /dev/null
+++ b/service_specs/sqlserverflex/alpha/database_config.yml
@@ -0,0 +1,34 @@
+provider:
+ name: stackitprivatepreview
+
+resources:
+ database:
+ create:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases
+ method: POST
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}
+ method: GET
+ delete:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}
+ method: DELETE
+ schema:
+ attributes:
+ aliases:
+ id: databaseId
+
+
+data_sources:
+ databases:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases
+ method: GET
+
+ database:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}
+ method: GET
+ schema:
+ attributes:
+ aliases:
+ id: database_id
diff --git a/service_specs/sqlserverflex/alpha/flavors_config.yml b/service_specs/sqlserverflex/alpha/flavors_config.yml
new file mode 100644
index 00000000..ad0f33e5
--- /dev/null
+++ b/service_specs/sqlserverflex/alpha/flavors_config.yml
@@ -0,0 +1,9 @@
+
+provider:
+ name: stackitprivatepreview
+
+data_sources:
+ flavors:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/flavors
+ method: GET
diff --git a/service_specs/sqlserverflex/alpha/instance_config.yml b/service_specs/sqlserverflex/alpha/instance_config.yml
new file mode 100644
index 00000000..c7ae4c2a
--- /dev/null
+++ b/service_specs/sqlserverflex/alpha/instance_config.yml
@@ -0,0 +1,28 @@
+provider:
+ name: stackitprivatepreview
+
+resources:
+ instance:
+ create:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances
+ method: POST
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: GET
+ update:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: PUT
+ delete:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: DELETE
+
+data_sources:
+ instances:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances
+ method: GET
+
+ instance:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: GET
diff --git a/service_specs/sqlserverflex/alpha/user_config.yml b/service_specs/sqlserverflex/alpha/user_config.yml
new file mode 100644
index 00000000..574f1f12
--- /dev/null
+++ b/service_specs/sqlserverflex/alpha/user_config.yml
@@ -0,0 +1,24 @@
+
+provider:
+ name: stackitprivatepreview
+
+resources:
+ user:
+ create:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users
+ method: POST
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}
+ method: GET
+ update:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}
+ method: PUT
+ delete:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}
+ method: DELETE
+
+data_sources:
+ user:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users
+ method: GET
diff --git a/service_specs/sqlserverflex/alpha/version_config.yml.bak b/service_specs/sqlserverflex/alpha/version_config.yml.bak
new file mode 100644
index 00000000..937dccd5
--- /dev/null
+++ b/service_specs/sqlserverflex/alpha/version_config.yml.bak
@@ -0,0 +1,9 @@
+
+provider:
+ name: stackitprivatepreview
+
+data_sources:
+ versions:
+ read:
+ path: /v3alpha1/projects/{projectId}/regions/{region}/versions
+ method: GET
diff --git a/service_specs/sqlserverflex/beta/backup_config.yml.disabled b/service_specs/sqlserverflex/beta/backup_config.yml.disabled
new file mode 100644
index 00000000..7df5fc4b
--- /dev/null
+++ b/service_specs/sqlserverflex/beta/backup_config.yml.disabled
@@ -0,0 +1,13 @@
+provider:
+ name: stackitprivatepreview
+
+data_sources:
+ backups:
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups
+ method: GET
+
+ backup:
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/{backupId}
+ method: GET
diff --git a/service_specs/sqlserverflex/beta/collation_config.yml.disabled b/service_specs/sqlserverflex/beta/collation_config.yml.disabled
new file mode 100644
index 00000000..d1160ec3
--- /dev/null
+++ b/service_specs/sqlserverflex/beta/collation_config.yml.disabled
@@ -0,0 +1,8 @@
+provider:
+ name: stackitprivatepreview
+
+data_sources:
+ collation:
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/collations
+ method: GET
diff --git a/service_specs/sqlserverflex/beta/database_config.yml b/service_specs/sqlserverflex/beta/database_config.yml
new file mode 100644
index 00000000..135010d2
--- /dev/null
+++ b/service_specs/sqlserverflex/beta/database_config.yml
@@ -0,0 +1,33 @@
+provider:
+ name: stackitprivatepreview
+
+resources:
+ database:
+ schema:
+ attributes:
+ aliases:
+ databaseId: id
+ create:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases
+ method: POST
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}
+ method: GET
+ delete:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}
+ method: DELETE
+
+data_sources:
+ databases:
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases
+ method: GET
+
+ database:
+ schema:
+ attributes:
+ aliases:
+ databaseId: id
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}
+ method: GET
diff --git a/service_specs/sqlserverflex/beta/flavors_config.yml b/service_specs/sqlserverflex/beta/flavors_config.yml
new file mode 100644
index 00000000..4b985a4c
--- /dev/null
+++ b/service_specs/sqlserverflex/beta/flavors_config.yml
@@ -0,0 +1,9 @@
+
+provider:
+ name: stackitprivatepreview
+
+data_sources:
+ flavors:
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/flavors
+ method: GET
diff --git a/service_specs/sqlserverflex/beta/instance_config.yml b/service_specs/sqlserverflex/beta/instance_config.yml
new file mode 100644
index 00000000..cea25959
--- /dev/null
+++ b/service_specs/sqlserverflex/beta/instance_config.yml
@@ -0,0 +1,28 @@
+provider:
+ name: stackitprivatepreview
+
+resources:
+ instance:
+ create:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances
+ method: POST
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: GET
+ update:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: PUT
+ delete:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: DELETE
+
+data_sources:
+ instances:
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances
+ method: GET
+
+ instance:
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}
+ method: GET
diff --git a/service_specs/sqlserverflex/beta/user_config.yml b/service_specs/sqlserverflex/beta/user_config.yml
new file mode 100644
index 00000000..bfa9a3a7
--- /dev/null
+++ b/service_specs/sqlserverflex/beta/user_config.yml
@@ -0,0 +1,24 @@
+
+provider:
+ name: stackitprivatepreview
+
+resources:
+ user:
+ create:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/users
+ method: POST
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}
+ method: GET
+ update:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}
+ method: PUT
+ delete:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}
+ method: DELETE
+
+data_sources:
+ user:
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/users
+ method: GET
diff --git a/service_specs/sqlserverflex/beta/versions_config.yml b/service_specs/sqlserverflex/beta/versions_config.yml
new file mode 100644
index 00000000..70d79676
--- /dev/null
+++ b/service_specs/sqlserverflex/beta/versions_config.yml
@@ -0,0 +1,9 @@
+
+provider:
+ name: stackitprivatepreview
+
+data_sources:
+ version:
+ read:
+ path: /v3beta1/projects/{projectId}/regions/{region}/versions
+ method: GET
diff --git a/stackit/internal/conversion/conversion.go b/stackit/internal/conversion/conversion.go
index bdcacdfd..48871213 100644
--- a/stackit/internal/conversion/conversion.go
+++ b/stackit/internal/conversion/conversion.go
@@ -11,7 +11,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
)
func ToString(ctx context.Context, v attr.Value) (string, error) {
@@ -89,6 +90,16 @@ func StringValueToPointer(s basetypes.StringValue) *string {
return &value
}
+// Int32ValueToPointer converts basetypes.Int64Value to a pointer to int64.
+// It returns nil if the value is null or unknown.
+func Int32ValueToPointer(s basetypes.Int32Value) *int32 {
+ if s.IsNull() || s.IsUnknown() {
+ return nil
+ }
+ value := s.ValueInt32()
+ return &value
+}
+
// Int64ValueToPointer converts basetypes.Int64Value to a pointer to int64.
// It returns nil if the value is null or unknown.
func Int64ValueToPointer(s basetypes.Int64Value) *int64 {
diff --git a/stackit/internal/conversion/conversion_test.go b/stackit/internal/conversion/conversion_test.go
index 53fd738a..ac5f4535 100644
--- a/stackit/internal/conversion/conversion_test.go
+++ b/stackit/internal/conversion/conversion_test.go
@@ -8,7 +8,8 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-framework/diag"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-framework/attr"
diff --git a/stackit/internal/core/core.go b/stackit/internal/core/core.go
index d3ea252c..3680ae65 100644
--- a/stackit/internal/core/core.go
+++ b/stackit/internal/core/core.go
@@ -32,7 +32,7 @@ const (
type EphemeralProviderData struct {
ProviderData
- PrivateKey string
+ PrivateKey string //nolint:gosec //this is a placeholder and not used in this code
PrivateKeyPath string
ServiceAccountKey string
ServiceAccountKeyPath string
@@ -105,11 +105,13 @@ func DiagsToError(diags diag.Diagnostics) error {
diagsError := diags.Errors()
diagsStrings := make([]string, 0)
for _, diagnostic := range diagsError {
- diagsStrings = append(diagsStrings, fmt.Sprintf(
- "(%s) %s",
- diagnostic.Summary(),
- diagnostic.Detail(),
- ))
+ diagsStrings = append(
+ diagsStrings, fmt.Sprintf(
+ "(%s) %s",
+ diagnostic.Summary(),
+ diagnostic.Detail(),
+ ),
+ )
}
return fmt.Errorf("%s", strings.Join(diagsStrings, ";"))
}
@@ -136,14 +138,22 @@ func LogAndAddWarning(ctx context.Context, diags *diag.Diagnostics, summary, det
func LogAndAddWarningBeta(ctx context.Context, diags *diag.Diagnostics, name string, resourceType ResourceType) {
warnTitle := fmt.Sprintf("The %s %q is in beta", resourceType, name)
- warnContent := fmt.Sprintf("The %s %q is in beta and may be subject to breaking changes in the future. Use with caution.", resourceType, name)
+ warnContent := fmt.Sprintf(
+ "The %s %q is in beta and may be subject to breaking changes in the future. Use with caution.",
+ resourceType,
+ name,
+ )
tflog.Warn(ctx, fmt.Sprintf("%s | %s", warnTitle, warnContent))
diags.AddWarning(warnTitle, warnContent)
}
func LogAndAddErrorBeta(ctx context.Context, diags *diag.Diagnostics, name string, resourceType ResourceType) {
errTitle := fmt.Sprintf("The %s %q is in beta and beta is not enabled", resourceType, name)
- errContent := fmt.Sprintf(`The %s %q is in beta and the beta functionality is currently not enabled. To enable it, set the environment variable STACKIT_TF_ENABLE_BETA_RESOURCES to "true" or set the "enable_beta_resources" provider field to true.`, resourceType, name)
+ errContent := fmt.Sprintf(
+ `The %s %q is in beta and the beta functionality is currently not enabled. To enable it, set the environment variable STACKIT_TF_ENABLE_BETA_RESOURCES to "true" or set the "enable_beta_resources" provider field to true.`,
+ resourceType,
+ name,
+ )
tflog.Error(ctx, fmt.Sprintf("%s | %s", errTitle, errContent))
diags.AddError(errTitle, errContent)
}
@@ -161,8 +171,10 @@ func LogResponse(ctx context.Context) context.Context {
traceId := runtime.GetTraceId(ctx)
ctx = tflog.SetField(ctx, "x-trace-id", traceId)
- tflog.Info(ctx, "response data", map[string]interface{}{
- "x-trace-id": traceId,
- })
+ tflog.Info(
+ ctx, "response data", map[string]interface{}{
+ "x-trace-id": traceId,
+ },
+ )
return ctx
}
diff --git a/stackit/internal/core/retry_round_tripper.go b/stackit/internal/core/retry_round_tripper.go
new file mode 100644
index 00000000..568be431
--- /dev/null
+++ b/stackit/internal/core/retry_round_tripper.go
@@ -0,0 +1,237 @@
+package core
+
+import (
+ "context"
+ "crypto/rand"
+ "errors"
+ "fmt"
+ "math/big"
+ "net/http"
+ "time"
+
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+)
+
+const (
+ // backoffMultiplier is the factor by which the delay is multiplied for exponential backoff.
+ backoffMultiplier = 2
+ // jitterFactor is the divisor used to calculate jitter (e.g., half of the base delay).
+ jitterFactor = 2
+)
+
+var (
+ // ErrRequestFailedAfterRetries is returned when a request fails after all retry attempts.
+ ErrRequestFailedAfterRetries = errors.New("request failed after all retry attempts")
+)
+
+// RetryRoundTripper implements an http.RoundTripper that adds automatic retry logic for failed requests.
+type RetryRoundTripper struct {
+ next http.RoundTripper
+ maxRetries int
+ initialDelay time.Duration
+ maxDelay time.Duration
+ perTryTimeout time.Duration
+}
+
+// NewRetryRoundTripper creates a new instance of the RetryRoundTripper with the specified configuration.
+func NewRetryRoundTripper(
+ next http.RoundTripper,
+ maxRetries int,
+ initialDelay, maxDelay, perTryTimeout time.Duration,
+) *RetryRoundTripper {
+ return &RetryRoundTripper{
+ next: next,
+ maxRetries: maxRetries,
+ initialDelay: initialDelay,
+ maxDelay: maxDelay,
+ perTryTimeout: perTryTimeout,
+ }
+}
+
+// RoundTrip executes the request and retries on failure.
+func (rrt *RetryRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
+ resp, err := rrt.executeRequest(req)
+ if !rrt.shouldRetry(resp, err) {
+ if err != nil {
+ return resp, fmt.Errorf("initial request failed, not retrying: %w", err)
+ }
+
+ return resp, nil
+ }
+
+ return rrt.retryLoop(req, resp, err)
+}
+
+// executeRequest performs a single HTTP request with a per-try timeout.
+func (rrt *RetryRoundTripper) executeRequest(req *http.Request) (*http.Response, error) {
+ ctx, cancel := context.WithTimeout(req.Context(), rrt.perTryTimeout)
+ defer cancel()
+
+ resp, err := rrt.next.RoundTrip(req.WithContext(ctx))
+ if err != nil {
+ if errors.Is(err, context.DeadlineExceeded) {
+ return resp, fmt.Errorf("per-try timeout of %v exceeded: %w", rrt.perTryTimeout, err)
+ }
+
+ return resp, fmt.Errorf("http roundtrip failed: %w", err)
+ }
+
+ return resp, nil
+}
+
+// retryLoop handles the retry logic for a failed request.
+func (rrt *RetryRoundTripper) retryLoop(
+ req *http.Request,
+ initialResp *http.Response,
+ initialErr error,
+) (*http.Response, error) {
+ var (
+ lastErr = initialErr
+ resp = initialResp
+ currentDelay = rrt.initialDelay
+ )
+
+ ctx := req.Context()
+
+ for attempt := 1; attempt <= rrt.maxRetries; attempt++ {
+ rrt.logRetryAttempt(ctx, attempt, currentDelay, lastErr)
+
+ waitDuration := rrt.calculateWaitDurationWithJitter(ctx, currentDelay)
+ if err := rrt.waitForDelay(ctx, waitDuration); err != nil {
+ return nil, err // Context was canceled during wait.
+ }
+
+ // Exponential backoff for the next potential retry.
+ currentDelay = rrt.updateCurrentDelay(currentDelay)
+
+ // Retry attempt.
+ resp, lastErr = rrt.executeRequest(req)
+ if !rrt.shouldRetry(resp, lastErr) {
+ if lastErr != nil {
+ return resp, fmt.Errorf("request failed on retry attempt %d: %w", attempt, lastErr)
+ }
+
+ return resp, nil
+ }
+ }
+
+ return nil, rrt.handleFinalError(ctx, resp, lastErr)
+}
+
+// logRetryAttempt logs the details of a retry attempt.
+func (rrt *RetryRoundTripper) logRetryAttempt(
+ ctx context.Context,
+ attempt int,
+ delay time.Duration,
+ err error,
+) {
+ tflog.Info(
+ ctx, "Request failed, retrying...", map[string]interface{}{
+ "attempt": attempt,
+ "max_attempts": rrt.maxRetries,
+ "delay": delay,
+ "error": err,
+ },
+ )
+}
+
+// updateCurrentDelay calculates the next delay for exponential backoff.
+func (rrt *RetryRoundTripper) updateCurrentDelay(currentDelay time.Duration) time.Duration {
+ currentDelay *= backoffMultiplier
+ if currentDelay > rrt.maxDelay {
+ return rrt.maxDelay
+ }
+
+ return currentDelay
+}
+
+// handleFinalError constructs and returns the final error after all retries have been exhausted.
+func (rrt *RetryRoundTripper) handleFinalError(
+ ctx context.Context,
+ resp *http.Response,
+ lastErr error,
+) error {
+ if resp != nil {
+ if err := resp.Body.Close(); err != nil {
+ tflog.Warn(
+ ctx, "Failed to close response body", map[string]interface{}{
+ "error": err.Error(),
+ },
+ )
+ }
+ }
+
+ if lastErr != nil {
+ return fmt.Errorf("%w: %w", ErrRequestFailedAfterRetries, lastErr)
+ }
+
+ // This case occurs if shouldRetry was true due to a retryable status code,
+ // but all retries failed with similar status codes.
+ if resp != nil {
+ return fmt.Errorf(
+ "%w: last retry attempt failed with status code %d",
+ ErrRequestFailedAfterRetries,
+ resp.StatusCode,
+ )
+ }
+
+ return fmt.Errorf("%w: no response received", ErrRequestFailedAfterRetries)
+}
+
+// shouldRetry determines if a request should be retried based on the response or an error.
+func (rrt *RetryRoundTripper) shouldRetry(resp *http.Response, err error) bool {
+ if err != nil {
+ return true
+ }
+
+ if resp != nil {
+ if resp.StatusCode == http.StatusBadGateway ||
+ resp.StatusCode == http.StatusServiceUnavailable ||
+ resp.StatusCode == http.StatusGatewayTimeout {
+ return true
+ }
+ }
+
+ return false
+}
+
+// calculateWaitDurationWithJitter calculates the backoff duration for the next retry,
+// adding a random jitter to prevent thundering herd issues.
+func (rrt *RetryRoundTripper) calculateWaitDurationWithJitter(
+ ctx context.Context,
+ baseDelay time.Duration,
+) time.Duration {
+ if baseDelay <= 0 {
+ return 0
+ }
+
+ maxJitter := int64(baseDelay / jitterFactor)
+ if maxJitter <= 0 {
+ return baseDelay
+ }
+
+ random, err := rand.Int(rand.Reader, big.NewInt(maxJitter))
+ if err != nil {
+ tflog.Warn(
+ ctx, "Failed to generate random jitter, proceeding without it.", map[string]interface{}{
+ "error": err.Error(),
+ },
+ )
+
+ return baseDelay
+ }
+
+ jitter := time.Duration(random.Int64())
+
+ return baseDelay + jitter
+}
+
+// waitForDelay pauses execution for a given duration or until the context is canceled.
+func (rrt *RetryRoundTripper) waitForDelay(ctx context.Context, delay time.Duration) error {
+ select {
+ case <-ctx.Done():
+ return fmt.Errorf("context canceled during backoff wait: %w", ctx.Err())
+ case <-time.After(delay):
+ return nil
+ }
+}
diff --git a/stackit/internal/core/retry_round_tripper_test.go b/stackit/internal/core/retry_round_tripper_test.go
new file mode 100644
index 00000000..ac84db8b
--- /dev/null
+++ b/stackit/internal/core/retry_round_tripper_test.go
@@ -0,0 +1,252 @@
+package core
+
+import (
+ "context"
+ "errors"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "sync/atomic"
+ "testing"
+ "time"
+)
+
+type mockRoundTripper struct {
+ roundTripFunc func(req *http.Request) (*http.Response, error)
+ callCount int32
+}
+
+func (m *mockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
+ atomic.AddInt32(&m.callCount, 1)
+
+ return m.roundTripFunc(req)
+}
+
+func (m *mockRoundTripper) CallCount() int32 {
+ return atomic.LoadInt32(&m.callCount)
+}
+
+func TestRetryRoundTripper_RoundTrip(t *testing.T) {
+ t.Parallel()
+
+ testRetryConfig := func(next http.RoundTripper) *RetryRoundTripper {
+ return NewRetryRoundTripper(
+ next,
+ 3,
+ 1*time.Millisecond,
+ 10*time.Millisecond,
+ 50*time.Millisecond,
+ )
+ }
+
+ noRetryTests := []struct {
+ name string
+ mockStatusCode int
+ expectedStatusCode int
+ }{
+ {
+ name: "should succeed on the first try",
+ mockStatusCode: http.StatusOK,
+ expectedStatusCode: http.StatusOK,
+ },
+ {
+ name: "should not retry on a non-retryable status code like 400",
+ mockStatusCode: http.StatusBadRequest,
+ expectedStatusCode: http.StatusBadRequest,
+ },
+ }
+
+ for _, testCase := range noRetryTests {
+ t.Run(
+ testCase.name, func(t *testing.T) {
+ t.Parallel()
+
+ mock := &mockRoundTripper{
+ roundTripFunc: func(req *http.Request) (*http.Response, error) {
+ return &http.Response{
+ StatusCode: testCase.mockStatusCode,
+ Body: io.NopCloser(nil),
+ Request: req,
+ }, nil
+ },
+ }
+ tripper := testRetryConfig(mock)
+ req := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
+
+ resp, err := tripper.RoundTrip(req)
+ if resp != nil {
+ defer func() {
+ if closeErr := resp.Body.Close(); closeErr != nil {
+ t.Errorf("failed to close response body: %v", closeErr)
+ }
+ }()
+ }
+
+ if err != nil {
+ t.Fatalf("expected no error, got %v", err)
+ }
+ if resp.StatusCode != testCase.expectedStatusCode {
+ t.Fatalf("expected status code %d, got %d", testCase.expectedStatusCode, resp.StatusCode)
+ }
+ if mock.CallCount() != 1 {
+ t.Fatalf("expected 1 call, got %d", mock.CallCount())
+ }
+ },
+ )
+ }
+
+ t.Run(
+ "should retry on retryable status code (503) and eventually fail", func(t *testing.T) {
+ t.Parallel()
+
+ mock := &mockRoundTripper{
+ roundTripFunc: func(req *http.Request) (*http.Response, error) {
+ return &http.Response{
+ StatusCode: http.StatusServiceUnavailable,
+ Body: io.NopCloser(nil),
+ Request: req,
+ }, nil
+ },
+ }
+ tripper := testRetryConfig(mock)
+ req := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
+
+ resp, err := tripper.RoundTrip(req)
+ if resp != nil {
+ defer func() {
+ if closeErr := resp.Body.Close(); closeErr != nil {
+ t.Errorf("failed to close response body: %v", closeErr)
+ }
+ }()
+ }
+
+ if err == nil {
+ t.Fatal("expected an error, but got nil")
+ }
+ expectedErrorMsg := "last retry attempt failed with status code 503"
+ if !strings.Contains(err.Error(), expectedErrorMsg) {
+ t.Fatalf("expected error to contain %q, got %q", expectedErrorMsg, err.Error())
+ }
+ if mock.CallCount() != 4 { // 1 initial + 3 retries
+ t.Fatalf("expected 4 calls, got %d", mock.CallCount())
+ }
+ },
+ )
+
+ t.Run(
+ "should succeed after one retry", func(t *testing.T) {
+ t.Parallel()
+
+ mock := &mockRoundTripper{}
+ mock.roundTripFunc = func(req *http.Request) (*http.Response, error) {
+ if mock.CallCount() < 2 {
+ return &http.Response{
+ StatusCode: http.StatusServiceUnavailable,
+ Body: io.NopCloser(nil),
+ Request: req,
+ }, nil
+ }
+
+ return &http.Response{
+ StatusCode: http.StatusOK,
+ Body: io.NopCloser(nil),
+ Request: req,
+ }, nil
+ }
+ tripper := testRetryConfig(mock)
+ req := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
+
+ resp, err := tripper.RoundTrip(req)
+ if resp != nil {
+ defer func() {
+ if closeErr := resp.Body.Close(); closeErr != nil {
+ t.Errorf("failed to close response body: %v", closeErr)
+ }
+ }()
+ }
+
+ if err != nil {
+ t.Fatalf("expected no error, got %v", err)
+ }
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("expected status code %d, got %d", http.StatusOK, resp.StatusCode)
+ }
+ if mock.CallCount() != 2 {
+ t.Fatalf("expected 2 calls, got %d", mock.CallCount())
+ }
+ },
+ )
+
+ t.Run(
+ "should retry on network error", func(t *testing.T) {
+ t.Parallel()
+
+ mockErr := errors.New("simulated network error")
+
+ mock := &mockRoundTripper{
+ roundTripFunc: func(_ *http.Request) (*http.Response, error) {
+ return nil, mockErr
+ },
+ }
+ tripper := testRetryConfig(mock)
+ req := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
+
+ resp, err := tripper.RoundTrip(req)
+ if resp != nil {
+ defer func() {
+ if closeErr := resp.Body.Close(); closeErr != nil {
+ t.Errorf("failed to close response body: %v", closeErr)
+ }
+ }()
+ }
+
+ if !errors.Is(err, mockErr) {
+ t.Fatalf("expected error to be %v, got %v", mockErr, err)
+ }
+ if mock.CallCount() != 4 { // 1 initial + 3 retries
+ t.Fatalf("expected 4 calls, got %d", mock.CallCount())
+ }
+ },
+ )
+
+ t.Run(
+ "should abort retries if the main context is canceled", func(t *testing.T) {
+ t.Parallel()
+
+ mock := &mockRoundTripper{
+ roundTripFunc: func(req *http.Request) (*http.Response, error) {
+ select {
+ case <-time.After(100 * time.Millisecond):
+ return nil, errors.New("this should not be returned")
+ case <-req.Context().Done():
+ return nil, req.Context().Err()
+ }
+ },
+ }
+ tripper := testRetryConfig(mock)
+ baseCtx := context.Background()
+
+ ctx, cancel := context.WithTimeout(baseCtx, 20*time.Millisecond)
+ defer cancel()
+
+ req := httptest.NewRequest(http.MethodGet, "/", http.NoBody).WithContext(ctx)
+
+ resp, err := tripper.RoundTrip(req)
+ if resp != nil {
+ defer func() {
+ if closeErr := resp.Body.Close(); closeErr != nil {
+ t.Errorf("failed to close response body: %v", closeErr)
+ }
+ }()
+ }
+
+ if !errors.Is(err, context.DeadlineExceeded) {
+ t.Fatalf("expected error to be context.DeadlineExceeded, got %v", err)
+ }
+ if mock.CallCount() != 1 {
+ t.Fatalf("expected 1 call, got %d", mock.CallCount())
+ }
+ },
+ )
+}
diff --git a/stackit/internal/features/beta.go b/stackit/internal/features/beta.go
index f0615eaa..ab74e554 100644
--- a/stackit/internal/features/beta.go
+++ b/stackit/internal/features/beta.go
@@ -9,7 +9,8 @@ import (
"strings"
"github.com/hashicorp/terraform-plugin-framework/diag"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
)
// BetaResourcesEnabled returns whether this provider has beta functionality enabled.
diff --git a/stackit/internal/features/beta_test.go b/stackit/internal/features/beta_test.go
index 4ea67e10..366158f8 100644
--- a/stackit/internal/features/beta_test.go
+++ b/stackit/internal/features/beta_test.go
@@ -7,7 +7,8 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-framework/diag"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
)
func TestBetaResourcesEnabled(t *testing.T) {
diff --git a/stackit/internal/features/experiments.go b/stackit/internal/features/experiments.go
index 6f56fb64..2230a7b5 100644
--- a/stackit/internal/features/experiments.go
+++ b/stackit/internal/features/experiments.go
@@ -10,7 +10,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
)
const (
diff --git a/stackit/internal/features/experiments_test.go b/stackit/internal/features/experiments_test.go
index 256055ca..771a8444 100644
--- a/stackit/internal/features/experiments_test.go
+++ b/stackit/internal/features/experiments_test.go
@@ -7,7 +7,8 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-framework/diag"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
)
func TestValidExperiment(t *testing.T) {
diff --git a/stackit/internal/services/postgresflexalpha/database/datasource.go b/stackit/internal/services/postgresflexalpha/database/datasource.go
new file mode 100644
index 00000000..ead08493
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/database/datasource.go
@@ -0,0 +1,196 @@
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ postgresflexalpha2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/database/datasources_gen"
+ postgresflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/utils"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+)
+
+// Ensure the implementation satisfies the expected interfaces.
+var (
+ _ datasource.DataSource = &databaseDataSource{}
+)
+
+// NewDatabaseDataSource is a helper function to simplify the provider implementation.
+func NewDatabaseDataSource() datasource.DataSource {
+ return &databaseDataSource{}
+}
+
+// dataSourceModel maps the data source schema data.
+type dataSourceModel struct {
+ postgresflexalpha2.DatabaseModel
+ TerraformID types.String `tfsdk:"id"`
+}
+
+// databaseDataSource is the data source implementation.
+type databaseDataSource struct {
+ client *postgresflexalpha.APIClient
+ providerData core.ProviderData
+}
+
+// Metadata returns the data source type name.
+func (r *databaseDataSource) Metadata(
+ _ context.Context,
+ req datasource.MetadataRequest,
+ resp *datasource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_postgresflexalpha_database"
+}
+
+// Configure adds the provider configured client to the data source.
+func (r *databaseDataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
+ var ok bool
+ r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClient := postgresflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ r.client = apiClient
+ tflog.Info(ctx, "Postgres Flex database client configured")
+}
+
+// Schema defines the schema for the data source.
+func (r *databaseDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ s := postgresflexalpha2.DatabaseDataSourceSchema(ctx)
+ s.Attributes["id"] = schema.StringAttribute{
+ Description: "Terraform's internal resource ID. It is structured as \\\"`project_id`,`region`,`instance_id`," +
+ "`database_id`\\\".\",",
+ Computed: true,
+ }
+
+ resp.Schema = s
+}
+
+// Read fetches the data for the data source.
+func (r *databaseDataSource) Read(
+ ctx context.Context,
+ req datasource.ReadRequest,
+ resp *datasource.ReadResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model dataSourceModel
+ diags := req.Config.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ region := r.providerData.GetRegionWithOverride(model.Region)
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ databaseResp, err := r.getDatabaseByNameOrID(ctx, &model, projectId, region, instanceId, &resp.Diagnostics)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ if err != nil {
+ handleReadError(ctx, &resp.Diagnostics, err, projectId, instanceId)
+ resp.State.RemoveResource(ctx)
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ // Map response body to schema and populate Computed attribute values
+ err = mapFields(databaseResp, &model, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading database",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Set refreshed state
+ diags = resp.State.Set(ctx, model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ tflog.Info(ctx, "Postgres Flex database read")
+}
+
+// getDatabaseByNameOrID retrieves a single database by ensuring either a unique ID or name is provided.
+func (r *databaseDataSource) getDatabaseByNameOrID(
+ ctx context.Context,
+ model *dataSourceModel,
+ projectId, region, instanceId string,
+ diags *diag.Diagnostics,
+) (*postgresflexalpha.ListDatabase, error) {
+ isIdSet := !model.DatabaseId.IsNull() && !model.DatabaseId.IsUnknown()
+ isNameSet := !model.Name.IsNull() && !model.Name.IsUnknown()
+
+ if (isIdSet && isNameSet) || (!isIdSet && !isNameSet) {
+ diags.AddError(
+ "Invalid configuration",
+ "Exactly one of 'id' or 'name' must be specified.",
+ )
+ return nil, nil
+ }
+
+ if isIdSet {
+ databaseId := model.DatabaseId.ValueInt64()
+ ctx = tflog.SetField(ctx, "database_id", databaseId)
+ return getDatabaseById(ctx, r.client, projectId, region, instanceId, databaseId)
+ }
+
+ databaseName := model.Name.ValueString()
+ ctx = tflog.SetField(ctx, "name", databaseName)
+ return getDatabaseByName(ctx, r.client, projectId, region, instanceId, databaseName)
+}
+
+// handleReadError centralizes API error handling for the Read operation.
+func handleReadError(ctx context.Context, diags *diag.Diagnostics, err error, projectId, instanceId string) {
+ utils.LogError(
+ ctx,
+ diags,
+ err,
+ "Reading database",
+ fmt.Sprintf(
+ "Could not retrieve database for instance %q in project %q.",
+ instanceId,
+ projectId,
+ ),
+ map[int]string{
+ http.StatusBadRequest: fmt.Sprintf(
+ "Invalid request parameters for project %q and instance %q.",
+ projectId,
+ instanceId,
+ ),
+ http.StatusNotFound: fmt.Sprintf(
+ "Database, instance %q, or project %q not found.",
+ instanceId,
+ projectId,
+ ),
+ http.StatusForbidden: fmt.Sprintf("Forbidden access to project %q.", projectId),
+ },
+ )
+}
diff --git a/stackit/internal/services/postgresflexalpha/database/datasource.go.bak b/stackit/internal/services/postgresflexalpha/database/datasource.go.bak
deleted file mode 100644
index e4a2f197..00000000
--- a/stackit/internal/services/postgresflexalpha/database/datasource.go.bak
+++ /dev/null
@@ -1,171 +0,0 @@
-package postgresflexa
-
-import (
- "context"
- "fmt"
- "net/http"
-
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- postgresflexUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflexalpha/utils"
-
- "github.com/hashicorp/terraform-plugin-framework/datasource"
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
-
- "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
- "github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha"
-)
-
-// Ensure the implementation satisfies the expected interfaces.
-var (
- _ datasource.DataSource = &databaseDataSource{}
-)
-
-// NewDatabaseDataSource is a helper function to simplify the provider implementation.
-func NewDatabaseDataSource() datasource.DataSource {
- return &databaseDataSource{}
-}
-
-// databaseDataSource is the data source implementation.
-type databaseDataSource struct {
- client *postgresflexalpha.APIClient
- providerData core.ProviderData
-}
-
-// Metadata returns the data source type name.
-func (r *databaseDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
- resp.TypeName = req.ProviderTypeName + "_postgresflexalpha_database"
-}
-
-// Configure adds the provider configured client to the data source.
-func (r *databaseDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
- var ok bool
- r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
- if !ok {
- return
- }
-
- apiClient := postgresflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics)
- if resp.Diagnostics.HasError() {
- return
- }
- r.client = apiClient
- tflog.Info(ctx, "Postgres Flex database client configured")
-}
-
-// Schema defines the schema for the data source.
-func (r *databaseDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
- descriptions := map[string]string{
- "main": "Postgres Flex database resource schema. Must have a `region` specified in the provider configuration.",
- "id": "Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`,`database_id`\".",
- "database_id": "Database ID.",
- "instance_id": "ID of the Postgres Flex instance.",
- "project_id": "STACKIT project ID to which the instance is associated.",
- "name": "Database name.",
- "owner": "Username of the database owner.",
- "region": "The resource region. If not defined, the provider region is used.",
- }
-
- resp.Schema = schema.Schema{
- Description: descriptions["main"],
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Description: descriptions["id"],
- Computed: true,
- },
- "database_id": schema.StringAttribute{
- Description: descriptions["database_id"],
- Required: true,
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- "instance_id": schema.StringAttribute{
- Description: descriptions["instance_id"],
- Required: true,
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "project_id": schema.StringAttribute{
- Description: descriptions["project_id"],
- Required: true,
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "name": schema.StringAttribute{
- Description: descriptions["name"],
- Computed: true,
- },
- "owner": schema.StringAttribute{
- Description: descriptions["owner"],
- Computed: true,
- },
- "region": schema.StringAttribute{
- // the region cannot be found, so it has to be passed
- Optional: true,
- Description: descriptions["region"],
- },
- },
- }
-}
-
-// Read refreshes the Terraform state with the latest data.
-func (r *databaseDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
- var model Model
- diags := req.Config.Get(ctx, &model)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
-
- ctx = core.InitProviderContext(ctx)
-
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- databaseId := model.DatabaseId.ValueString()
- region := r.providerData.GetRegionWithOverride(model.Region)
- ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
- ctx = tflog.SetField(ctx, "database_id", databaseId)
- ctx = tflog.SetField(ctx, "region", region)
-
- databaseResp, err := getDatabase(ctx, r.client, projectId, region, instanceId, databaseId)
- if err != nil {
- utils.LogError(
- ctx,
- &resp.Diagnostics,
- err,
- "Reading database",
- fmt.Sprintf("Database with ID %q or instance with ID %q does not exist in project %q.", databaseId, instanceId, projectId),
- map[int]string{
- http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId),
- },
- )
- resp.State.RemoveResource(ctx)
- return
- }
-
- ctx = core.LogResponse(ctx)
-
- // Map response body to schema and populate Computed attribute values
- err = mapFields(databaseResp, &model, region)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading database", fmt.Sprintf("Processing API payload: %v", err))
- return
- }
-
- // Set refreshed state
- diags = resp.State.Set(ctx, model)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- tflog.Info(ctx, "Postgres Flex database read")
-}
diff --git a/stackit/internal/services/postgresflexalpha/database/datasources_gen/database_data_source_gen.go b/stackit/internal/services/postgresflexalpha/database/datasources_gen/database_data_source_gen.go
new file mode 100644
index 00000000..d5683a6c
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/database/datasources_gen/database_data_source_gen.go
@@ -0,0 +1,69 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func DatabaseDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "database_id": schema.Int64Attribute{
+ Required: true,
+ Description: "The ID of the database.",
+ MarkdownDescription: "The ID of the database.",
+ },
+ "tf_original_api_id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The id of the database.",
+ MarkdownDescription: "The id of the database.",
+ },
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "owner": schema.StringAttribute{
+ Computed: true,
+ Description: "The owner of the database.",
+ MarkdownDescription: "The owner of the database.",
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type DatabaseModel struct {
+ DatabaseId types.Int64 `tfsdk:"database_id"`
+ Id types.Int64 `tfsdk:"tf_original_api_id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Name types.String `tfsdk:"name"`
+ Owner types.String `tfsdk:"owner"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+}
diff --git a/stackit/internal/services/postgresflexalpha/database/datasources_gen/databases_data_source_gen.go b/stackit/internal/services/postgresflexalpha/database/datasources_gen/databases_data_source_gen.go
new file mode 100644
index 00000000..b8bc6010
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/database/datasources_gen/databases_data_source_gen.go
@@ -0,0 +1,1118 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func DatabasesDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "databases": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The id of the database.",
+ MarkdownDescription: "The id of the database.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "owner": schema.StringAttribute{
+ Computed: true,
+ Description: "The owner of the database.",
+ MarkdownDescription: "The owner of the database.",
+ },
+ },
+ CustomType: DatabasesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: DatabasesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "A list containing all databases for the instance.",
+ MarkdownDescription: "A list containing all databases for the instance.",
+ },
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the databases to be returned on each page.",
+ MarkdownDescription: "Sorting of the databases to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "created_at.desc",
+ "created_at.asc",
+ "database_id.desc",
+ "database_id.asc",
+ "database_name.desc",
+ "database_name.asc",
+ "database_owner.desc",
+ "database_owner.asc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type DatabasesModel struct {
+ Databases types.List `tfsdk:"databases"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = DatabasesType{}
+
+type DatabasesType struct {
+ basetypes.ObjectType
+}
+
+func (t DatabasesType) Equal(o attr.Type) bool {
+ other, ok := o.(DatabasesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t DatabasesType) String() string {
+ return "DatabasesType"
+}
+
+func (t DatabasesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return nil, diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ ownerAttribute, ok := attributes["owner"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `owner is missing from object`)
+
+ return nil, diags
+ }
+
+ ownerVal, ok := ownerAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`owner expected to be basetypes.StringValue, was: %T`, ownerAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return DatabasesValue{
+ Id: idVal,
+ Name: nameVal,
+ Owner: ownerVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewDatabasesValueNull() DatabasesValue {
+ return DatabasesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewDatabasesValueUnknown() DatabasesValue {
+ return DatabasesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewDatabasesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (DatabasesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing DatabasesValue Attribute Value",
+ "While creating a DatabasesValue value, a missing attribute value was detected. "+
+ "A DatabasesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("DatabasesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid DatabasesValue Attribute Type",
+ "While creating a DatabasesValue value, an invalid attribute value was detected. "+
+ "A DatabasesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("DatabasesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("DatabasesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra DatabasesValue Attribute Value",
+ "While creating a DatabasesValue value, an extra attribute value was detected. "+
+ "A DatabasesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra DatabasesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ ownerAttribute, ok := attributes["owner"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `owner is missing from object`)
+
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ ownerVal, ok := ownerAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`owner expected to be basetypes.StringValue, was: %T`, ownerAttribute))
+ }
+
+ if diags.HasError() {
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ return DatabasesValue{
+ Id: idVal,
+ Name: nameVal,
+ Owner: ownerVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewDatabasesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) DatabasesValue {
+ object, diags := NewDatabasesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewDatabasesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t DatabasesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewDatabasesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewDatabasesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewDatabasesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewDatabasesValueMust(DatabasesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t DatabasesType) ValueType(ctx context.Context) attr.Value {
+ return DatabasesValue{}
+}
+
+var _ basetypes.ObjectValuable = DatabasesValue{}
+
+type DatabasesValue struct {
+ Id basetypes.Int64Value `tfsdk:"id"`
+ Name basetypes.StringValue `tfsdk:"name"`
+ Owner basetypes.StringValue `tfsdk:"owner"`
+ state attr.ValueState
+}
+
+func (v DatabasesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 3)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["id"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["name"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["owner"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 3)
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.Name.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["name"] = val
+
+ val, err = v.Owner.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["owner"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v DatabasesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v DatabasesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v DatabasesValue) String() string {
+ return "DatabasesValue"
+}
+
+func (v DatabasesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "id": basetypes.Int64Type{},
+ "name": basetypes.StringType{},
+ "owner": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "id": v.Id,
+ "name": v.Name,
+ "owner": v.Owner,
+ })
+
+ return objVal, diags
+}
+
+func (v DatabasesValue) Equal(o attr.Value) bool {
+ other, ok := o.(DatabasesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.Name.Equal(other.Name) {
+ return false
+ }
+
+ if !v.Owner.Equal(other.Owner) {
+ return false
+ }
+
+ return true
+}
+
+func (v DatabasesValue) Type(ctx context.Context) attr.Type {
+ return DatabasesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v DatabasesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "id": basetypes.Int64Type{},
+ "name": basetypes.StringType{},
+ "owner": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/database/functions.go b/stackit/internal/services/postgresflexalpha/database/functions.go
new file mode 100644
index 00000000..e67f4926
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/database/functions.go
@@ -0,0 +1,91 @@
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+ "strings"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+)
+
+// databaseClientReader represents the contract to listing databases from postgresflex.APIClient.
+type databaseClientReader interface {
+ ListDatabasesRequest(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ ) postgresflex.ApiListDatabasesRequestRequest
+}
+
+// getDatabaseById gets a database by its ID.
+func getDatabaseById(
+ ctx context.Context,
+ client databaseClientReader,
+ projectId, region, instanceId string,
+ databaseId int64,
+) (*postgresflex.ListDatabase, error) {
+ filter := func(db postgresflex.ListDatabase) bool {
+ return db.Id != nil && *db.Id == databaseId
+ }
+ return getDatabase(ctx, client, projectId, region, instanceId, filter)
+}
+
+// getDatabaseByName gets a database by its name.
+func getDatabaseByName(
+ ctx context.Context,
+ client databaseClientReader,
+ projectId, region, instanceId, databaseName string,
+) (*postgresflex.ListDatabase, error) {
+ filter := func(db postgresflex.ListDatabase) bool {
+ return db.Name != nil && *db.Name == databaseName
+ }
+ return getDatabase(ctx, client, projectId, region, instanceId, filter)
+}
+
+// getDatabase is a helper function to retrieve a database using a filter function.
+// Hint: The API does not have a GetDatabase endpoint, only ListDatabases
+func getDatabase(
+ ctx context.Context,
+ client databaseClientReader,
+ projectId, region, instanceId string,
+ filter func(db postgresflex.ListDatabase) bool,
+) (*postgresflex.ListDatabase, error) {
+ if projectId == "" || region == "" || instanceId == "" {
+ return nil, fmt.Errorf("all parameters (project, region, instance) are required")
+ }
+
+ const pageSize = 25
+
+ for page := int32(1); ; page++ {
+ res, err := client.ListDatabasesRequest(ctx, projectId, region, instanceId).
+ Page(page).Size(pageSize).Sort(postgresflex.DATABASESORT_DATABASE_ID_ASC).Execute()
+ if err != nil {
+ return nil, fmt.Errorf("requesting database list (page %d): %w", page, err)
+ }
+
+ // If the API returns no databases, we have reached the end of the list.
+ if res.Databases == nil || len(*res.Databases) == 0 {
+ break
+ }
+
+ // Iterate over databases to find a match
+ for _, db := range *res.Databases {
+ if filter(db) {
+ foundDb := db
+ return &foundDb, nil
+ }
+ }
+ }
+
+ return nil, fmt.Errorf("database not found for instance %s", instanceId)
+}
+
+// cleanString removes leading and trailing quotes which are sometimes returned by the API.
+func cleanString(s *string) *string {
+ if s == nil {
+ return nil
+ }
+ res := strings.Trim(*s, "\"")
+ return &res
+}
diff --git a/stackit/internal/services/postgresflexalpha/database/functions_test.go b/stackit/internal/services/postgresflexalpha/database/functions_test.go
new file mode 100644
index 00000000..4c921b14
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/database/functions_test.go
@@ -0,0 +1,233 @@
+package postgresflexalpha
+
+import (
+ "context"
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+)
+
+type mockRequest struct {
+ executeFunc func() (*postgresflex.ListDatabasesResponse, error)
+}
+
+func (m *mockRequest) Page(_ int32) postgresflex.ApiListDatabasesRequestRequest { return m }
+func (m *mockRequest) Size(_ int32) postgresflex.ApiListDatabasesRequestRequest { return m }
+func (m *mockRequest) Sort(_ postgresflex.DatabaseSort) postgresflex.ApiListDatabasesRequestRequest {
+ return m
+}
+func (m *mockRequest) Execute() (*postgresflex.ListDatabasesResponse, error) {
+ return m.executeFunc()
+}
+
+type mockDBClient struct {
+ executeRequest func() postgresflex.ApiListDatabasesRequestRequest
+}
+
+var _ databaseClientReader = (*mockDBClient)(nil)
+
+func (m *mockDBClient) ListDatabasesRequest(
+ _ context.Context,
+ _, _, _ string,
+) postgresflex.ApiListDatabasesRequestRequest {
+ return m.executeRequest()
+}
+
+func TestGetDatabase(t *testing.T) {
+ mockResp := func(page int64) (*postgresflex.ListDatabasesResponse, error) {
+ if page == 1 {
+ return &postgresflex.ListDatabasesResponse{
+ Databases: &[]postgresflex.ListDatabase{
+ {Id: utils.Ptr(int64(1)), Name: utils.Ptr("first")},
+ {Id: utils.Ptr(int64(2)), Name: utils.Ptr("second")},
+ },
+ Pagination: &postgresflex.Pagination{
+ Page: utils.Ptr(int64(1)),
+ TotalPages: utils.Ptr(int64(2)),
+ Size: utils.Ptr(int64(3)),
+ },
+ }, nil
+ }
+
+ if page == 2 {
+ return &postgresflex.ListDatabasesResponse{
+ Databases: &[]postgresflex.ListDatabase{{Id: utils.Ptr(int64(3)), Name: utils.Ptr("three")}},
+ Pagination: &postgresflex.Pagination{
+ Page: utils.Ptr(int64(2)),
+ TotalPages: utils.Ptr(int64(2)),
+ Size: utils.Ptr(int64(3)),
+ },
+ }, nil
+ }
+
+ return &postgresflex.ListDatabasesResponse{
+ Databases: &[]postgresflex.ListDatabase{},
+ Pagination: &postgresflex.Pagination{
+ Page: utils.Ptr(int64(3)),
+ TotalPages: utils.Ptr(int64(2)),
+ Size: utils.Ptr(int64(3)),
+ },
+ }, nil
+ }
+
+ tests := []struct {
+ description string
+ projectId string
+ region string
+ instanceId string
+ wantErr bool
+ wantDbName string
+ wantDbId int64
+ }{
+ {
+ description: "Success - Found by name on first page",
+ projectId: "pid", region: "reg", instanceId: "inst",
+ wantErr: false,
+ wantDbName: "second",
+ },
+ {
+ description: "Success - Found by id on first page",
+ projectId: "pid", region: "reg", instanceId: "inst",
+ wantErr: false,
+ wantDbId: 2,
+ },
+ {
+ description: "Success - Found by name on second page",
+ projectId: "pid", region: "reg", instanceId: "inst",
+ wantErr: false,
+ wantDbName: "three",
+ },
+ {
+ description: "Success - Found by id on second page",
+ projectId: "pid", region: "reg", instanceId: "inst",
+ wantErr: false,
+ wantDbId: 1,
+ },
+ {
+ description: "Error - API failure",
+ projectId: "pid", region: "reg", instanceId: "inst",
+ wantErr: true,
+ },
+ {
+ description: "Error - Missing parameters",
+ projectId: "", region: "reg", instanceId: "inst",
+ wantErr: true,
+ },
+ {
+ description: "Error - Search by name not found after all pages",
+ projectId: "pid", region: "reg", instanceId: "inst",
+ wantDbName: "non-existent",
+ wantErr: true,
+ },
+ {
+ description: "Error - Search by id not found after all pages",
+ projectId: "pid", region: "reg", instanceId: "inst",
+ wantDbId: 999999,
+ wantErr: true,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ var currentPage int64
+ client := &mockDBClient{
+ executeRequest: func() postgresflex.ApiListDatabasesRequestRequest {
+ return &mockRequest{
+ executeFunc: func() (*postgresflex.ListDatabasesResponse, error) {
+ currentPage++
+ return mockResp(currentPage)
+ },
+ }
+ },
+ }
+
+ var actual *postgresflex.ListDatabase
+ var errDB error
+
+ if tt.wantDbName != "" {
+ actual, errDB = getDatabaseByName(
+ t.Context(),
+ client,
+ tt.projectId,
+ tt.region,
+ tt.instanceId,
+ tt.wantDbName,
+ )
+ } else if tt.wantDbId != 0 {
+ actual, errDB = getDatabaseById(
+ t.Context(),
+ client,
+ tt.projectId,
+ tt.region,
+ tt.instanceId,
+ tt.wantDbId,
+ )
+ } else {
+ actual, errDB = getDatabase(
+ context.Background(),
+ client,
+ tt.projectId,
+ tt.region,
+ tt.instanceId,
+ func(_ postgresflex.ListDatabase) bool { return false },
+ )
+ }
+
+ if (errDB != nil) != tt.wantErr {
+ t.Errorf("getDatabaseByNameOrID() error = %v, wantErr %v", errDB, tt.wantErr)
+ return
+ }
+ if !tt.wantErr && tt.wantDbName != "" && actual != nil {
+ if *actual.Name != tt.wantDbName {
+ t.Errorf("getDatabaseByNameOrID() got name = %v, want %v", *actual.Name, tt.wantDbName)
+ }
+ }
+
+ if !tt.wantErr && tt.wantDbId != 0 && actual != nil {
+ if *actual.Id != tt.wantDbId {
+ t.Errorf("getDatabaseByNameOrID() got id = %v, want %v", *actual.Id, tt.wantDbId)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestCleanString(t *testing.T) {
+ testcases := []struct {
+ name string
+ given *string
+ expected *string
+ }{
+ {
+ name: "should remove quotes",
+ given: utils.Ptr("\"quoted\""),
+ expected: utils.Ptr("quoted"),
+ },
+ {
+ name: "should handle nil",
+ given: nil,
+ expected: nil,
+ },
+ {
+ name: "should not change unquoted string",
+ given: utils.Ptr("unquoted"),
+ expected: utils.Ptr("unquoted"),
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ actual := cleanString(tc.given)
+ if diff := cmp.Diff(tc.expected, actual); diff != "" {
+ t.Errorf("string mismatch (-want +got):\n%s", diff)
+ }
+ },
+ )
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/database/mapper.go b/stackit/internal/services/postgresflexalpha/database/mapper.go
new file mode 100644
index 00000000..89140267
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/database/mapper.go
@@ -0,0 +1,93 @@
+package postgresflexalpha
+
+import (
+ "fmt"
+ "strconv"
+
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+// mapFields maps fields from a ListDatabase API response to a resourceModel for the data source.
+func mapFields(
+ source *postgresflexalpha.ListDatabase,
+ model *dataSourceModel,
+ region string,
+) error {
+ if source == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if source.Id == nil || *source.Id == 0 {
+ return fmt.Errorf("id not present")
+ }
+ if model == nil {
+ return fmt.Errorf("model given is nil")
+ }
+
+ var databaseId int64
+ if model.DatabaseId.ValueInt64() != 0 {
+ databaseId = model.DatabaseId.ValueInt64()
+ } else if source.Id != nil {
+ databaseId = *source.Id
+ } else {
+ return fmt.Errorf("database id not present")
+ }
+
+ model.Id = types.Int64Value(databaseId)
+ model.DatabaseId = types.Int64Value(databaseId)
+ model.Name = types.StringValue(source.GetName())
+ model.Owner = types.StringPointerValue(cleanString(source.Owner))
+ model.Region = types.StringValue(region)
+ model.ProjectId = types.StringValue(model.ProjectId.ValueString())
+ model.InstanceId = types.StringValue(model.InstanceId.ValueString())
+ model.TerraformID = utils.BuildInternalTerraformId(
+ model.ProjectId.ValueString(),
+ region,
+ model.InstanceId.ValueString(),
+ strconv.FormatInt(databaseId, 10),
+ )
+
+ return nil
+}
+
+// mapResourceFields maps fields from a GetDatabase API response to a resourceModel for the resource.
+func mapResourceFields(source *postgresflexalpha.GetDatabaseResponse, model *resourceModel) error {
+ if source == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if source.Id == nil || *source.Id == 0 {
+ return fmt.Errorf("id not present")
+ }
+ if model == nil {
+ return fmt.Errorf("model input is nil")
+ }
+
+ var databaseId int64
+ if model.Id.ValueInt64() != 0 {
+ databaseId = model.Id.ValueInt64()
+ } else if source.Id != nil {
+ databaseId = *source.Id
+ } else {
+ return fmt.Errorf("database id not present")
+ }
+
+ model.Id = types.Int64Value(databaseId)
+ model.DatabaseId = types.Int64Value(databaseId)
+ model.Name = types.StringValue(source.GetName())
+ model.Owner = types.StringPointerValue(cleanString(source.Owner))
+ return nil
+}
+
+// toCreatePayload converts the resource model to an API create payload.
+func toCreatePayload(model *resourceModel) (*postgresflexalpha.CreateDatabaseRequestPayload, error) {
+ if model == nil {
+ return nil, fmt.Errorf("nil model")
+ }
+
+ return &postgresflexalpha.CreateDatabaseRequestPayload{
+ Name: model.Name.ValueStringPointer(),
+ Owner: model.Owner.ValueStringPointer(),
+ }, nil
+}
diff --git a/stackit/internal/services/postgresflexalpha/database/mapper_test.go b/stackit/internal/services/postgresflexalpha/database/mapper_test.go
new file mode 100644
index 00000000..16fd0ce6
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/database/mapper_test.go
@@ -0,0 +1,246 @@
+package postgresflexalpha
+
+import (
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ datasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/database/datasources_gen"
+)
+
+func TestMapFields(t *testing.T) {
+ type given struct {
+ source *postgresflexalpha.ListDatabase
+ model *dataSourceModel
+ region string
+ }
+ type expected struct {
+ model *dataSourceModel
+ err bool
+ }
+
+ testcases := []struct {
+ name string
+ given given
+ expected expected
+ }{
+ {
+ name: "should map fields correctly",
+ given: given{
+ source: &postgresflexalpha.ListDatabase{
+ Id: utils.Ptr(int64(1)),
+ Name: utils.Ptr("my-db"),
+ Owner: utils.Ptr("\"my-owner\""),
+ },
+ model: &dataSourceModel{
+ DatabaseModel: datasource.DatabaseModel{
+ ProjectId: types.StringValue("my-project"),
+ InstanceId: types.StringValue("my-instance"),
+ },
+ },
+ region: "eu01",
+ },
+ expected: expected{
+ model: &dataSourceModel{
+ DatabaseModel: datasource.DatabaseModel{
+ Id: types.Int64Value(1),
+ Name: types.StringValue("my-db"),
+ Owner: types.StringValue("my-owner"),
+ Region: types.StringValue("eu01"),
+ DatabaseId: types.Int64Value(1),
+ InstanceId: types.StringValue("my-instance"),
+ ProjectId: types.StringValue("my-project"),
+ },
+ TerraformID: types.StringValue("my-project,eu01,my-instance,1"),
+ },
+ },
+ },
+ {
+ name: "should preserve existing model ID",
+ given: given{
+ source: &postgresflexalpha.ListDatabase{
+ Id: utils.Ptr(int64(1)),
+ Name: utils.Ptr("my-db"),
+ },
+ model: &dataSourceModel{
+ DatabaseModel: datasource.DatabaseModel{
+ Id: types.Int64Value(1),
+ ProjectId: types.StringValue("my-project"),
+ InstanceId: types.StringValue("my-instance"),
+ },
+ },
+ region: "eu01",
+ },
+ expected: expected{
+ model: &dataSourceModel{
+ DatabaseModel: datasource.DatabaseModel{
+ Id: types.Int64Value(1),
+ Name: types.StringValue("my-db"),
+ Owner: types.StringNull(), DatabaseId: types.Int64Value(1),
+ Region: types.StringValue("eu01"),
+ InstanceId: types.StringValue("my-instance"),
+ ProjectId: types.StringValue("my-project"),
+ },
+ TerraformID: types.StringValue("my-project,eu01,my-instance,1"),
+ },
+ },
+ },
+ {
+ name: "should fail on nil source",
+ given: given{
+ source: nil,
+ model: &dataSourceModel{},
+ },
+ expected: expected{err: true},
+ },
+ {
+ name: "should fail on nil source ID",
+ given: given{
+ source: &postgresflexalpha.ListDatabase{Id: nil},
+ model: &dataSourceModel{},
+ },
+ expected: expected{err: true},
+ },
+ {
+ name: "should fail on nil model",
+ given: given{
+ source: &postgresflexalpha.ListDatabase{Id: utils.Ptr(int64(1))},
+ model: nil,
+ },
+ expected: expected{err: true},
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ err := mapFields(tc.given.source, tc.given.model, tc.given.region)
+ if (err != nil) != tc.expected.err {
+ t.Fatalf("expected error: %v, got: %v", tc.expected.err, err)
+ }
+ if err == nil {
+ if diff := cmp.Diff(tc.expected.model, tc.given.model); diff != "" {
+ t.Errorf("model mismatch (-want +got):\n%s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestMapResourceFields(t *testing.T) {
+ type given struct {
+ source *postgresflexalpha.GetDatabaseResponse
+ model *resourceModel
+ }
+ type expected struct {
+ model *resourceModel
+ err bool
+ }
+
+ testcases := []struct {
+ name string
+ given given
+ expected expected
+ }{
+ {
+ name: "should map fields correctly",
+ given: given{
+ source: &postgresflexalpha.GetDatabaseResponse{
+ Id: utils.Ptr(int64(1)),
+ Name: utils.Ptr("my-db"),
+ Owner: utils.Ptr("my-owner"),
+ },
+ model: &resourceModel{},
+ },
+ expected: expected{
+ model: &resourceModel{
+ Id: types.Int64Value(1),
+ Name: types.StringValue("my-db"),
+ Owner: types.StringValue("my-owner"),
+ DatabaseId: types.Int64Value(1),
+ },
+ },
+ },
+ {
+ name: "should fail on nil source",
+ given: given{
+ source: nil,
+ model: &resourceModel{},
+ },
+ expected: expected{err: true},
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ err := mapResourceFields(tc.given.source, tc.given.model)
+ if (err != nil) != tc.expected.err {
+ t.Fatalf("expected error: %v, got: %v", tc.expected.err, err)
+ }
+ if err == nil {
+ if diff := cmp.Diff(tc.expected.model, tc.given.model); diff != "" {
+ t.Errorf("model mismatch (-want +got):\n%s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestToCreatePayload(t *testing.T) {
+ type given struct {
+ model *resourceModel
+ }
+ type expected struct {
+ payload *postgresflexalpha.CreateDatabaseRequestPayload
+ err bool
+ }
+
+ testcases := []struct {
+ name string
+ given given
+ expected expected
+ }{
+ {
+ name: "should convert model to payload",
+ given: given{
+ model: &resourceModel{
+ Name: types.StringValue("my-db"),
+ Owner: types.StringValue("my-owner"),
+ },
+ },
+ expected: expected{
+ payload: &postgresflexalpha.CreateDatabaseRequestPayload{
+ Name: utils.Ptr("my-db"),
+ Owner: utils.Ptr("my-owner"),
+ },
+ },
+ },
+ {
+ name: "should fail on nil model",
+ given: given{model: nil},
+ expected: expected{err: true},
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ actual, err := toCreatePayload(tc.given.model)
+ if (err != nil) != tc.expected.err {
+ t.Fatalf("expected error: %v, got: %v", tc.expected.err, err)
+ }
+ if err == nil {
+ if diff := cmp.Diff(tc.expected.payload, actual); diff != "" {
+ t.Errorf("payload mismatch (-want +got):\n%s", diff)
+ }
+ }
+ },
+ )
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/database/planModifiers.yaml b/stackit/internal/services/postgresflexalpha/database/planModifiers.yaml
new file mode 100644
index 00000000..f3f70aeb
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/database/planModifiers.yaml
@@ -0,0 +1,35 @@
+fields:
+ - name: 'id'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'database_id'
+ modifiers:
+ - 'UseStateForUnknown'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+
+ - name: 'instance_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'RequiresReplace'
+ - 'UseStateForUnknown'
+
+ - name: 'project_id'
+ modifiers:
+ - 'RequiresReplace'
+ - 'UseStateForUnknown'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+
+ - name: 'name'
+ validators:
+ - validate.NoSeparator
+
+ - name: 'region'
+ modifiers:
+ - 'RequiresReplace'
diff --git a/stackit/internal/services/postgresflexalpha/database/resource.go b/stackit/internal/services/postgresflexalpha/database/resource.go
new file mode 100644
index 00000000..2b12c281
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/database/resource.go
@@ -0,0 +1,626 @@
+package postgresflexalpha
+
+import (
+ "context"
+ _ "embed"
+ "fmt"
+ "math"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ postgresflexalpha2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/database/resources_gen"
+ postgresflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/utils"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+ postgresflexalpha3 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/postgresflexalpha"
+)
+
+var (
+ // Ensure the implementation satisfies the expected interfaces.
+ _ resource.Resource = &databaseResource{}
+ _ resource.ResourceWithConfigure = &databaseResource{}
+ _ resource.ResourceWithImportState = &databaseResource{}
+ _ resource.ResourceWithModifyPlan = &databaseResource{}
+ _ resource.ResourceWithIdentity = &databaseResource{}
+
+ // Error message constants
+ extractErrorSummary = "extracting failed"
+ extractErrorMessage = "Extracting identity data: %v"
+)
+
+// NewDatabaseResource is a helper function to simplify the provider implementation.
+func NewDatabaseResource() resource.Resource {
+ return &databaseResource{}
+}
+
+// resourceModel describes the resource data model.
+type resourceModel = postgresflexalpha2.DatabaseModel
+
+// DatabaseResourceIdentityModel describes the resource's identity attributes.
+type DatabaseResourceIdentityModel struct {
+ ProjectID types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ InstanceID types.String `tfsdk:"instance_id"`
+ DatabaseID types.Int64 `tfsdk:"database_id"`
+}
+
+// databaseResource is the resource implementation.
+type databaseResource struct {
+ client *postgresflexalpha.APIClient
+ providerData core.ProviderData
+}
+
+// ModifyPlan adjusts the plan to set the correct region.
+func (r *databaseResource) ModifyPlan(
+ ctx context.Context,
+ req resource.ModifyPlanRequest,
+ resp *resource.ModifyPlanResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var configModel resourceModel
+ // skip initial empty configuration to avoid follow-up errors
+ if req.Config.Raw.IsNull() {
+ return
+ }
+ resp.Diagnostics.Append(req.Config.Get(ctx, &configModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ var planModel resourceModel
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+}
+
+// Metadata returns the resource type name.
+func (r *databaseResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_postgresflexalpha_database"
+}
+
+// Configure adds the provider configured client to the resource.
+func (r *databaseResource) Configure(
+ ctx context.Context,
+ req resource.ConfigureRequest,
+ resp *resource.ConfigureResponse,
+) {
+ var ok bool
+ r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClient := postgresflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ r.client = apiClient
+ tflog.Info(ctx, "Postgres Flex database client configured")
+}
+
+//go:embed planModifiers.yaml
+var modifiersFileByte []byte
+
+// Schema defines the schema for the resource.
+func (r *databaseResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
+ s := postgresflexalpha2.DatabaseResourceSchema(ctx)
+
+ fields, err := utils.ReadModifiersConfig(modifiersFileByte)
+ if err != nil {
+ resp.Diagnostics.AddError("error during read modifiers config file", err.Error())
+ return
+ }
+
+ err = utils.AddPlanModifiersToResourceSchema(fields, &s)
+ if err != nil {
+ resp.Diagnostics.AddError("error adding plan modifiers", err.Error())
+ return
+ }
+ resp.Schema = s
+}
+
+// IdentitySchema defines the schema for the resource's identity attributes.
+func (r *databaseResource) IdentitySchema(
+ _ context.Context,
+ _ resource.IdentitySchemaRequest,
+ response *resource.IdentitySchemaResponse,
+) {
+ response.IdentitySchema = identityschema.Schema{
+ Attributes: map[string]identityschema.Attribute{
+ "project_id": identityschema.StringAttribute{
+ RequiredForImport: true,
+ },
+ "region": identityschema.StringAttribute{
+ RequiredForImport: true,
+ },
+ "instance_id": identityschema.StringAttribute{
+ RequiredForImport: true,
+ },
+ "database_id": identityschema.Int64Attribute{
+ RequiredForImport: true,
+ },
+ },
+ }
+}
+
+// Create creates the resource and sets the initial Terraform state.
+func (r *databaseResource) Create(
+ ctx context.Context,
+ req resource.CreateRequest,
+ resp *resource.CreateResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ const funcErrorSummary = "[database CREATE] error"
+ var model resourceModel
+ diags := req.Plan.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ region := model.Region.ValueString()
+ instanceId := model.InstanceId.ValueString()
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ // Generate API request body from model
+ payload, err := toCreatePayload(&model)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ funcErrorSummary,
+ fmt.Sprintf("Creating API payload: %v", err),
+ )
+ return
+ }
+ // Create new database
+ databaseResp, err := r.client.CreateDatabaseRequest(
+ ctx,
+ projectId,
+ region,
+ instanceId,
+ ).CreateDatabaseRequestPayload(*payload).Execute()
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, funcErrorSummary, fmt.Sprintf("Calling API: %v", err))
+ return
+ }
+
+ if databaseResp == nil || databaseResp.Id == nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ funcErrorSummary,
+ "API didn't return database Id. A database might have been created",
+ )
+ return
+ }
+ databaseId := *databaseResp.Id
+ ctx = tflog.SetField(ctx, "database_id", databaseId)
+ ctx = core.LogResponse(ctx)
+
+ // Save identity into Terraform state
+ identity := DatabaseResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ DatabaseID: types.Int64Value(databaseId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ database, err := postgresflexalpha3.GetDatabaseByIdWaitHandler(ctx, r.client, projectId, instanceId, region, databaseId).
+ SetTimeout(15 * time.Minute).
+ SetSleepBeforeWait(15 * time.Second).
+ WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ funcErrorSummary,
+ fmt.Sprintf("Getting database details after creation: %v", err),
+ )
+ return
+ }
+
+ // Map response body to schema
+ err = mapResourceFields(database, &model)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ funcErrorSummary,
+ fmt.Sprintf("map resource fields: %v", err),
+ )
+ return
+ }
+
+ // Set state to fully populated data
+ resp.Diagnostics.Append(resp.State.Set(ctx, model)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ tflog.Info(ctx, "Postgres Flex database created")
+}
+
+// Read refreshes the Terraform state with the latest data.
+func (r *databaseResource) Read(
+ ctx context.Context,
+ req resource.ReadRequest,
+ resp *resource.ReadResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
+ diags := req.State.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ region := model.Region.ValueString()
+ databaseId := model.DatabaseId.ValueInt64()
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "database_id", databaseId)
+
+ databaseResp, err := postgresflexalpha3.GetDatabaseByIdWaitHandler(ctx, r.client, projectId, instanceId, region, databaseId).
+ SetTimeout(15 * time.Minute).
+ SetSleepBeforeWait(15 * time.Second).
+ WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating database",
+ fmt.Sprintf("Getting database details after creation: %v", err),
+ )
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ // Map response body to schema
+ err = mapResourceFields(databaseResp, &model)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading database",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // TODO: use values from api to identify drift
+ // Save identity into Terraform state
+ identity := DatabaseResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ DatabaseID: types.Int64Value(databaseId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Set refreshed state
+ diags = resp.State.Set(ctx, model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ tflog.Info(ctx, "Postgres Flex database read")
+}
+
+// Update updates the resource and sets the updated Terraform state on success.
+func (r *databaseResource) Update(
+ ctx context.Context,
+ req resource.UpdateRequest,
+ resp *resource.UpdateResponse,
+) {
+ var model resourceModel
+ diags := req.Plan.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ region := model.Region.ValueString()
+ databaseId64 := model.DatabaseId.ValueInt64()
+
+ if databaseId64 > math.MaxInt32 {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (databaseId)")
+ return
+ }
+ databaseId := int32(databaseId64) // nolint:gosec // check is performed above
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "database_id", databaseId)
+
+ // Retrieve values from state
+ var stateModel resourceModel
+ diags = req.State.Get(ctx, &stateModel)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ modified := false
+ var payload postgresflexalpha.UpdateDatabasePartiallyRequestPayload
+ if stateModel.Name != model.Name {
+ payload.Name = model.Name.ValueStringPointer()
+ modified = true
+ }
+
+ if stateModel.Owner != model.Owner {
+ payload.Owner = model.Owner.ValueStringPointer()
+ modified = true
+ }
+
+ if !modified {
+ tflog.Info(ctx, "no modification detected")
+ return
+ }
+
+ // Update existing database
+ err := r.client.UpdateDatabasePartiallyRequest(
+ ctx,
+ projectId,
+ region,
+ instanceId,
+ databaseId,
+ ).UpdateDatabasePartiallyRequestPayload(payload).Execute()
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "error updating database", err.Error())
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ databaseResp, err := postgresflexalpha3.GetDatabaseByIdWaitHandler(ctx, r.client, projectId, instanceId, region, databaseId64).
+ SetTimeout(15 * time.Minute).
+ SetSleepBeforeWait(15 * time.Second).
+ WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "error updating database", err.Error())
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ // Map response body to schema
+ err = mapResourceFields(databaseResp, &model)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading database",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Save identity into Terraform state
+ identity := DatabaseResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ DatabaseID: types.Int64Value(databaseId64),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Set state to fully populated data
+ resp.Diagnostics.Append(resp.State.Set(ctx, &model)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ tflog.Info(ctx, "Postgres Flex database updated")
+}
+
+// Delete deletes the resource and removes the Terraform state on success.
+func (r *databaseResource) Delete(
+ ctx context.Context,
+ req resource.DeleteRequest,
+ resp *resource.DeleteResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
+ diags := req.State.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Read identity data
+ var identityData DatabaseResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId, region, instanceId, databaseId64, errExt := r.extractIdentityData(model, identityData)
+ if errExt != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ extractErrorSummary,
+ fmt.Sprintf(extractErrorMessage, errExt),
+ )
+ }
+
+ if databaseId64 > math.MaxInt32 {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (databaseId)")
+ return
+ }
+ databaseId := int32(databaseId64) // nolint:gosec // check is performed above
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "database_id", databaseId)
+
+ // Delete existing record set
+ err := r.client.DeleteDatabaseRequestExecute(ctx, projectId, region, instanceId, databaseId)
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting database", fmt.Sprintf("Calling API: %v", err))
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ tflog.Info(ctx, "Postgres Flex database deleted")
+}
+
+// ImportState imports a resource into the Terraform state on success.
+// The expected import identifier format is: [project_id],[region],[instance_id],[database_id]
+func (r *databaseResource) ImportState(
+ ctx context.Context,
+ req resource.ImportStateRequest,
+ resp *resource.ImportStateResponse,
+) {
+ ctx = core.InitProviderContext(ctx)
+
+ if req.ID != "" {
+ idParts := strings.Split(req.ID, core.Separator)
+
+ if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" {
+ core.LogAndAddError(
+ ctx, &resp.Diagnostics,
+ "Error importing database",
+ fmt.Sprintf(
+ "Expected import identifier with format [project_id],[region],[instance_id],[database_id], got %q",
+ req.ID,
+ ),
+ )
+ return
+ }
+
+ databaseId, err := strconv.ParseInt(idParts[3], 10, 64)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error importing database",
+ fmt.Sprintf("Invalid database_id format: %q. It must be a valid integer.", idParts[3]),
+ )
+ return
+ }
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("database_id"), databaseId)...)
+
+ core.LogAndAddWarning(
+ ctx,
+ &resp.Diagnostics,
+ "Postgresflex database imported with empty password",
+ "The database password is not imported as it is only available upon creation of a new database. The password field will be empty.",
+ )
+
+ tflog.Info(ctx, "Postgres Flex database state imported")
+
+ return
+ }
+
+ // If no ID is provided, attempt to read identity attributes from the import configuration
+ var identityData DatabaseResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ instanceId := identityData.InstanceID.ValueString()
+ databaseId := identityData.DatabaseID.ValueInt64()
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), projectId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), region)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), instanceId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("database_id"), databaseId)...)
+
+ tflog.Info(ctx, "Postgres Flex database state imported")
+}
+
+// extractIdentityData extracts essential identifiers from the resource model, falling back to the identity model.
+func (r *databaseResource) extractIdentityData(
+ model resourceModel,
+ identity DatabaseResourceIdentityModel,
+) (projectId, region, instanceId string, databaseId int64, err error) {
+ if !model.DatabaseId.IsNull() && !model.DatabaseId.IsUnknown() {
+ databaseId = model.DatabaseId.ValueInt64()
+ } else {
+ if identity.DatabaseID.IsNull() || identity.DatabaseID.IsUnknown() {
+ return "", "", "", 0, fmt.Errorf("database_id not found in config")
+ }
+ databaseId = identity.DatabaseID.ValueInt64()
+ }
+
+ if !model.ProjectId.IsNull() && !model.ProjectId.IsUnknown() {
+ projectId = model.ProjectId.ValueString()
+ } else {
+ if identity.ProjectID.IsNull() || identity.ProjectID.IsUnknown() {
+ return "", "", "", 0, fmt.Errorf("project_id not found in config")
+ }
+ projectId = identity.ProjectID.ValueString()
+ }
+
+ if !model.Region.IsNull() && !model.Region.IsUnknown() {
+ region = r.providerData.GetRegionWithOverride(model.Region)
+ } else {
+ if identity.Region.IsNull() || identity.Region.IsUnknown() {
+ return "", "", "", 0, fmt.Errorf("region not found in config")
+ }
+ region = r.providerData.GetRegionWithOverride(identity.Region)
+ }
+
+ if !model.InstanceId.IsNull() && !model.InstanceId.IsUnknown() {
+ instanceId = model.InstanceId.ValueString()
+ } else {
+ if identity.InstanceID.IsNull() || identity.InstanceID.IsUnknown() {
+ return "", "", "", 0, fmt.Errorf("instance_id not found in config")
+ }
+ instanceId = identity.InstanceID.ValueString()
+ }
+ return projectId, region, instanceId, databaseId, nil
+}
diff --git a/stackit/internal/services/postgresflexalpha/database/resource.go.bak b/stackit/internal/services/postgresflexalpha/database/resource.go.bak
deleted file mode 100644
index 44fe2157..00000000
--- a/stackit/internal/services/postgresflexalpha/database/resource.go.bak
+++ /dev/null
@@ -1,447 +0,0 @@
-package postgresflexa
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "strings"
-
- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
- "github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- postgresflexUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflexalpha/utils"
-
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
-
- "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/planmodifier"
- "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
-)
-
-// Ensure the implementation satisfies the expected interfaces.
-var (
- _ resource.Resource = &databaseResource{}
- _ resource.ResourceWithConfigure = &databaseResource{}
- _ resource.ResourceWithImportState = &databaseResource{}
- _ resource.ResourceWithModifyPlan = &databaseResource{}
-)
-
-type Model struct {
- Id types.String `tfsdk:"id"` // needed by TF
- DatabaseId types.String `tfsdk:"database_id"`
- InstanceId types.String `tfsdk:"instance_id"`
- ProjectId types.String `tfsdk:"project_id"`
- Name types.String `tfsdk:"name"`
- Owner types.String `tfsdk:"owner"`
- Region types.String `tfsdk:"region"`
- Encryption encryptionModel `tfsdk:"encryption"`
-}
-
-type encryptionModel struct {
- KeyId types.String `tfsdk:"key_id"`
- //keyringid = xxxx
- //keyversion = xxxx
- //serviceaccount = xxxx
-}
-
-// NewDatabaseResource is a helper function to simplify the provider implementation.
-func NewDatabaseResource() resource.Resource {
- return &databaseResource{}
-}
-
-// databaseResource is the resource implementation.
-type databaseResource struct {
- client *postgresflexalpha.APIClient
- providerData core.ProviderData
-}
-
-// ModifyPlan implements resource.ResourceWithModifyPlan.
-// Use the modifier to set the effective region in the current plan.
-func (r *databaseResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { // nolint:gocritic // function signature required by Terraform
- var configModel Model
- // skip initial empty configuration to avoid follow-up errors
- if req.Config.Raw.IsNull() {
- return
- }
- resp.Diagnostics.Append(req.Config.Get(ctx, &configModel)...)
- if resp.Diagnostics.HasError() {
- return
- }
-
- var planModel Model
- resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...)
- if resp.Diagnostics.HasError() {
- return
- }
-
- utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp)
- if resp.Diagnostics.HasError() {
- return
- }
-
- resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...)
- if resp.Diagnostics.HasError() {
- return
- }
-}
-
-// Metadata returns the resource type name.
-func (r *databaseResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
- resp.TypeName = req.ProviderTypeName + "_postgresflex_database"
-}
-
-// Configure adds the provider configured client to the resource.
-func (r *databaseResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
- var ok bool
- r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
- if !ok {
- return
- }
-
- apiClient := postgresflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics)
- if resp.Diagnostics.HasError() {
- return
- }
- r.client = apiClient
- tflog.Info(ctx, "Postgres Flex database client configured")
-}
-
-// Schema defines the schema for the resource.
-func (r *databaseResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
- descriptions := map[string]string{
- "main": "Postgres Flex database resource schema. Must have a `region` specified in the provider configuration.",
- "id": "Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`,`database_id`\".",
- "database_id": "Database ID.",
- "instance_id": "ID of the Postgres Flex instance.",
- "project_id": "STACKIT project ID to which the instance is associated.",
- "name": "Database name.",
- "owner": "Username of the database owner.",
- "region": "The resource region. If not defined, the provider region is used.",
- }
-
- resp.Schema = schema.Schema{
- Description: descriptions["main"],
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Description: descriptions["id"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- "database_id": schema.StringAttribute{
- Description: descriptions["database_id"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- "instance_id": schema.StringAttribute{
- Description: descriptions["instance_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "project_id": schema.StringAttribute{
- Description: descriptions["project_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "name": schema.StringAttribute{
- Description: descriptions["name"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- },
- "owner": schema.StringAttribute{
- Description: descriptions["owner"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- },
- "region": schema.StringAttribute{
- Optional: true,
- // must be computed to allow for storing the override value from the provider
- Computed: true,
- Description: descriptions["region"],
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- },
- },
- }
-}
-
-// Create creates the resource and sets the initial Terraform state.
-func (r *databaseResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
- var model Model
- diags := req.Plan.Get(ctx, &model)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
-
- ctx = core.InitProviderContext(ctx)
-
- projectId := model.ProjectId.ValueString()
- region := model.Region.ValueString()
- instanceId := model.InstanceId.ValueString()
- ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
- ctx = tflog.SetField(ctx, "region", region)
-
- // Generate API request body from model
- payload, err := toCreatePayload(&model)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating database", fmt.Sprintf("Creating API payload: %v", err))
- return
- }
- // Create new database
- databaseResp, err := r.client.CreateDatabaseRequest(ctx, projectId, region, instanceId).CreateDatabaseRequestPayload(*payload).Execute()
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating database", fmt.Sprintf("Calling API: %v", err))
- return
- }
-
- ctx = core.LogResponse(ctx)
-
- if databaseResp == nil || databaseResp.Id == nil || *databaseResp.Id == "" {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating database", "API didn't return database Id. A database might have been created")
- return
- }
- databaseId := *databaseResp.Id
- ctx = tflog.SetField(ctx, "database_id", databaseId)
-
- database, err := getDatabase(ctx, r.client, projectId, region, instanceId, databaseId)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating database", fmt.Sprintf("Getting database details after creation: %v", err))
- return
- }
-
- // Map response body to schema
- err = mapFields(database, &model, region)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating database", fmt.Sprintf("Processing API payload: %v", err))
- return
- }
- // Set state to fully populated data
- diags = resp.State.Set(ctx, model)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- tflog.Info(ctx, "Postgres Flex database created")
-}
-
-// Read refreshes the Terraform state with the latest data.
-func (r *databaseResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
- var model Model
- diags := req.State.Get(ctx, &model)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
-
- ctx = core.InitProviderContext(ctx)
-
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- databaseId := model.DatabaseId.ValueString()
- region := r.providerData.GetRegionWithOverride(model.Region)
- ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
- ctx = tflog.SetField(ctx, "database_id", databaseId)
- ctx = tflog.SetField(ctx, "region", region)
-
- databaseResp, err := getDatabase(ctx, r.client, projectId, region, instanceId, databaseId)
- if err != nil {
- oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
- if (ok && oapiErr.StatusCode == http.StatusNotFound) || errors.Is(err, databaseNotFoundErr) {
- resp.State.RemoveResource(ctx)
- return
- }
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading database", fmt.Sprintf("Calling API: %v", err))
- return
- }
-
- ctx = core.LogResponse(ctx)
-
- // Map response body to schema
- err = mapFields(databaseResp, &model, region)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading database", fmt.Sprintf("Processing API payload: %v", err))
- return
- }
-
- // Set refreshed state
- diags = resp.State.Set(ctx, model)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- tflog.Info(ctx, "Postgres Flex database read")
-}
-
-// Update updates the resource and sets the updated Terraform state on success.
-func (r *databaseResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
- // Update shouldn't be called
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating database", "Database can't be updated")
-}
-
-// Delete deletes the resource and removes the Terraform state on success.
-func (r *databaseResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
- // Retrieve values from plan
- var model Model
- diags := req.State.Get(ctx, &model)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
-
- ctx = core.InitProviderContext(ctx)
-
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- databaseId := model.DatabaseId.ValueString()
- region := model.Region.ValueString()
- ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
- ctx = tflog.SetField(ctx, "database_id", databaseId)
- ctx = tflog.SetField(ctx, "region", region)
-
- // Delete existing record set
- err := r.client.DeleteDatabase(ctx, projectId, region, instanceId, databaseId).Execute()
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting database", fmt.Sprintf("Calling API: %v", err))
- }
-
- ctx = core.LogResponse(ctx)
-
- tflog.Info(ctx, "Postgres Flex database deleted")
-}
-
-// ImportState imports a resource into the Terraform state on success.
-// The expected format of the resource import identifier is: project_id,zone_id,record_set_id
-func (r *databaseResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
- idParts := strings.Split(req.ID, core.Separator)
- if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" {
- core.LogAndAddError(ctx, &resp.Diagnostics,
- "Error importing database",
- fmt.Sprintf("Expected import identifier with format [project_id],[region],[instance_id],[database_id], got %q", req.ID),
- )
- return
- }
-
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("database_id"), idParts[3])...)
- core.LogAndAddWarning(ctx, &resp.Diagnostics,
- "Postgresflex database imported with empty password",
- "The database password is not imported as it is only available upon creation of a new database. The password field will be empty.",
- )
- tflog.Info(ctx, "Postgres Flex database state imported")
-}
-
-func mapFields(databaseResp *postgresflex.InstanceDatabase, model *Model, region string) error {
- if databaseResp == nil {
- return fmt.Errorf("response is nil")
- }
- if databaseResp.Id == nil || *databaseResp.Id == "" {
- return fmt.Errorf("id not present")
- }
- if model == nil {
- return fmt.Errorf("model input is nil")
- }
-
- var databaseId string
- if model.DatabaseId.ValueString() != "" {
- databaseId = model.DatabaseId.ValueString()
- } else if databaseResp.Id != nil {
- databaseId = *databaseResp.Id
- } else {
- return fmt.Errorf("database id not present")
- }
- model.Id = utils.BuildInternalTerraformId(
- model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), databaseId,
- )
- model.DatabaseId = types.StringValue(databaseId)
- model.Name = types.StringPointerValue(databaseResp.Name)
- model.Region = types.StringValue(region)
-
- if databaseResp.Options != nil {
- owner, ok := (*databaseResp.Options)["owner"]
- if ok {
- ownerStr, ok := owner.(string)
- if !ok {
- return fmt.Errorf("owner is not a string")
- }
- // If the field is returned between with quotes, we trim them to prevent an inconsistent result after apply
- ownerStr = strings.TrimPrefix(ownerStr, `"`)
- ownerStr = strings.TrimSuffix(ownerStr, `"`)
- model.Owner = types.StringValue(ownerStr)
- }
- }
-
- return nil
-}
-
-func toCreatePayload(model *Model) (*postgresflexalpha.CreateDatabaseRequestPayload, error) {
- if model == nil {
- return nil, fmt.Errorf("nil model")
- }
-
- return &postgresflexalpha.CreateDatabaseRequestPayload{
- Name: model.Name.ValueStringPointer(),
- // TODO
- //Options: &map[string]string{
- // "owner": model.Owner.ValueString(),
- //},
- }, nil
-}
-
-var databaseNotFoundErr = errors.New("database not found")
-
-// The API does not have a GetDatabase endpoint, only ListDatabases
-func getDatabase(ctx context.Context, client *postgresflexalpha.APIClient, projectId, region, instanceId, databaseId string) (*postgresflex.InstanceDatabase, error) {
- resp, err := client.ListDatabasesRequest(ctx, projectId, region, instanceId).Execute()
- if err != nil {
- return nil, err
- }
- if resp == nil || resp.Databases == nil {
- return nil, fmt.Errorf("response is nil")
- }
- for _, database := range *resp.Databases {
- if database.Id != nil && *database.Id == databaseId {
- return &database, nil
- }
- }
- return nil, databaseNotFoundErr
-}
diff --git a/stackit/internal/services/postgresflexalpha/database/resource_test.go.bak b/stackit/internal/services/postgresflexalpha/database/resource_test.go.bak
deleted file mode 100644
index c2cf6d96..00000000
--- a/stackit/internal/services/postgresflexalpha/database/resource_test.go.bak
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright (c) STACKIT
-
-package postgresflexa
-
-import (
- "testing"
-
- "github.com/google/go-cmp/cmp"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/stackit-sdk-go/core/utils"
- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
-)
-
-func TestMapFields(t *testing.T) {
- const testRegion = "region"
- tests := []struct {
- description string
- input *postgresflex.InstanceDatabase
- region string
- expected Model
- isValid bool
- }{
- {
- "default_values",
- &postgresflex.InstanceDatabase{
- Id: utils.Ptr("uid"),
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,uid"),
- DatabaseId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Name: types.StringNull(),
- Owner: types.StringNull(),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "simple_values",
- &postgresflex.InstanceDatabase{
- Id: utils.Ptr("uid"),
- Name: utils.Ptr("dbname"),
- Options: &map[string]interface{}{
- "owner": "username",
- },
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,uid"),
- DatabaseId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Name: types.StringValue("dbname"),
- Owner: types.StringValue("username"),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "null_fields_and_int_conversions",
- &postgresflex.InstanceDatabase{
- Id: utils.Ptr("uid"),
- Name: utils.Ptr(""),
- Options: &map[string]interface{}{
- "owner": "",
- },
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,uid"),
- DatabaseId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Name: types.StringValue(""),
- Owner: types.StringValue(""),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "nil_response",
- nil,
- testRegion,
- Model{},
- false,
- },
- {
- "empty_response",
- &postgresflex.InstanceDatabase{},
- testRegion,
- Model{},
- false,
- },
- {
- "no_resource_id",
- &postgresflex.InstanceDatabase{
- Id: utils.Ptr(""),
- Name: utils.Ptr("dbname"),
- Options: &map[string]interface{}{
- "owner": "username",
- },
- },
- testRegion,
- Model{},
- false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.description, func(t *testing.T) {
- state := &Model{
- ProjectId: tt.expected.ProjectId,
- InstanceId: tt.expected.InstanceId,
- }
- err := mapFields(tt.input, state, tt.region)
- if !tt.isValid && err == nil {
- t.Fatalf("Should have failed")
- }
- if tt.isValid && err != nil {
- t.Fatalf("Should not have failed: %v", err)
- }
- if tt.isValid {
- diff := cmp.Diff(state, &tt.expected)
- if diff != "" {
- t.Fatalf("Data does not match: %s", diff)
- }
- }
- })
- }
-}
-
-func TestToCreatePayload(t *testing.T) {
- tests := []struct {
- description string
- input *Model
- expected *postgresflex.CreateDatabasePayload
- isValid bool
- }{
- {
- "default_values",
- &Model{
- Name: types.StringValue("dbname"),
- Owner: types.StringValue("username"),
- },
- &postgresflex.CreateDatabasePayload{
- Name: utils.Ptr("dbname"),
- Options: &map[string]string{
- "owner": "username",
- },
- },
- true,
- },
- {
- "null_fields",
- &Model{
- Name: types.StringNull(),
- Owner: types.StringNull(),
- },
- &postgresflex.CreateDatabasePayload{
- Name: nil,
- Options: &map[string]string{
- "owner": "",
- },
- },
- true,
- },
- {
- "nil_model",
- nil,
- nil,
- false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.description, func(t *testing.T) {
- output, err := toCreatePayload(tt.input)
- if !tt.isValid && err == nil {
- t.Fatalf("Should have failed")
- }
- if tt.isValid && err != nil {
- t.Fatalf("Should not have failed: %v", err)
- }
- if tt.isValid {
- diff := cmp.Diff(output, tt.expected)
- if diff != "" {
- t.Fatalf("Data does not match: %s", diff)
- }
- }
- })
- }
-}
diff --git a/stackit/internal/services/postgresflexalpha/database/resources_gen/database_resource_gen.go b/stackit/internal/services/postgresflexalpha/database/resources_gen/database_resource_gen.go
new file mode 100644
index 00000000..6affc956
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/database/resources_gen/database_resource_gen.go
@@ -0,0 +1,74 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+)
+
+func DatabaseResourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "database_id": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the database.",
+ MarkdownDescription: "The ID of the database.",
+ },
+ "id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The id of the database.",
+ MarkdownDescription: "The id of the database.",
+ },
+ "instance_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "name": schema.StringAttribute{
+ Required: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "owner": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The owner of the database.",
+ MarkdownDescription: "The owner of the database.",
+ },
+ "project_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type DatabaseModel struct {
+ DatabaseId types.Int64 `tfsdk:"database_id"`
+ Id types.Int64 `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Name types.String `tfsdk:"name"`
+ Owner types.String `tfsdk:"owner"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+}
diff --git a/stackit/internal/services/postgresflexalpha/flavor/datasource.go b/stackit/internal/services/postgresflexalpha/flavor/datasource.go
new file mode 100644
index 00000000..52c6b779
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/flavor/datasource.go
@@ -0,0 +1,253 @@
+package postgresFlexAlphaFlavor
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ postgresflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavors/datasources_gen"
+ postgresflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/utils"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+)
+
+// Ensure the implementation satisfies the expected interfaces.
+var (
+ _ datasource.DataSource = &flavorDataSource{}
+)
+
+type FlavorModel struct {
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ StorageClass types.String `tfsdk:"storage_class"`
+ Cpu types.Int64 `tfsdk:"cpu"`
+ Description types.String `tfsdk:"description"`
+ Id types.String `tfsdk:"id"`
+ FlavorId types.String `tfsdk:"flavor_id"`
+ MaxGb types.Int64 `tfsdk:"max_gb"`
+ Memory types.Int64 `tfsdk:"ram"`
+ MinGb types.Int64 `tfsdk:"min_gb"`
+ NodeType types.String `tfsdk:"node_type"`
+ StorageClasses types.List `tfsdk:"storage_classes"`
+}
+
+// NewFlavorDataSource is a helper function to simplify the provider implementation.
+func NewFlavorDataSource() datasource.DataSource {
+ return &flavorDataSource{}
+}
+
+// flavorDataSource is the data source implementation.
+type flavorDataSource struct {
+ client *postgresflexalpha.APIClient
+ providerData core.ProviderData
+}
+
+// Metadata returns the data source type name.
+func (r *flavorDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_postgresflexalpha_flavor"
+}
+
+// Configure adds the provider configured client to the data source.
+func (r *flavorDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
+ var ok bool
+ r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClient := postgresflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ r.client = apiClient
+ tflog.Info(ctx, "Postgres Flex instance client configured")
+}
+
+func (r *flavorDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The cpu count of the instance.",
+ MarkdownDescription: "The cpu count of the instance.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The flavor description.",
+ MarkdownDescription: "The flavor description.",
+ },
+ "cpu": schema.Int64Attribute{
+ Required: true,
+ Description: "The cpu count of the instance.",
+ MarkdownDescription: "The cpu count of the instance.",
+ },
+ "ram": schema.Int64Attribute{
+ Required: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "storage_class": schema.StringAttribute{
+ Required: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "description": schema.StringAttribute{
+ Computed: true,
+ Description: "The flavor description.",
+ MarkdownDescription: "The flavor description.",
+ },
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The terraform id of the instance flavor.",
+ MarkdownDescription: "The terraform id of the instance flavor.",
+ },
+ "flavor_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The flavor id of the instance flavor.",
+ MarkdownDescription: "The flavor id of the instance flavor.",
+ },
+ "max_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ "min_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "minimum storage which is required to order in Gigabyte.",
+ MarkdownDescription: "minimum storage which is required to order in Gigabyte.",
+ },
+ "node_type": schema.StringAttribute{
+ Required: true,
+ Description: "defines the nodeType it can be either single or replica",
+ MarkdownDescription: "defines the nodeType it can be either single or replica",
+ },
+ "storage_classes": schema.ListNestedAttribute{
+ Computed: true,
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Computed: true,
+ },
+ "max_io_per_sec": schema.Int64Attribute{
+ Computed: true,
+ },
+ "max_through_in_mb": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: postgresflexalphaGen.StorageClassesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: postgresflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ },
+ },
+ }
+}
+
+func (r *flavorDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var model FlavorModel
+ diags := req.Config.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ region := r.providerData.GetRegionWithOverride(model.Region)
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ flavors, err := getAllFlavors(ctx, r.client, projectId, region)
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading flavors", fmt.Sprintf("getAllFlavors: %v", err))
+ return
+ }
+
+ var foundFlavors []postgresflexalpha.ListFlavors
+ for _, flavor := range flavors {
+ if model.Cpu.ValueInt64() != *flavor.Cpu {
+ continue
+ }
+ if model.Memory.ValueInt64() != *flavor.Memory {
+ continue
+ }
+ if model.NodeType.ValueString() != *flavor.NodeType {
+ continue
+ }
+ for _, sc := range *flavor.StorageClasses {
+ if model.StorageClass.ValueString() != *sc.Class {
+ continue
+ }
+ foundFlavors = append(foundFlavors, flavor)
+ }
+ }
+ if len(foundFlavors) == 0 {
+ resp.Diagnostics.AddError("get flavor", "could not find requested flavor")
+ return
+ }
+ if len(foundFlavors) > 1 {
+ resp.Diagnostics.AddError("get flavor", "found too many matching flavors")
+ return
+ }
+
+ f := foundFlavors[0]
+ model.Description = types.StringValue(*f.Description)
+ model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), region, *f.Id)
+ model.FlavorId = types.StringValue(*f.Id)
+ model.MaxGb = types.Int64Value(*f.MaxGB)
+ model.MinGb = types.Int64Value(*f.MinGB)
+
+ if f.StorageClasses == nil {
+ model.StorageClasses = types.ListNull(postgresflexalphaGen.StorageClassesType{
+ ObjectType: basetypes.ObjectType{
+ AttrTypes: postgresflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ })
+ } else {
+ var scList []attr.Value
+ for _, sc := range *f.StorageClasses {
+ scList = append(
+ scList,
+ postgresflexalphaGen.NewStorageClassesValueMust(
+ postgresflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "class": types.StringValue(*sc.Class),
+ "max_io_per_sec": types.Int64Value(*sc.MaxIoPerSec),
+ "max_through_in_mb": types.Int64Value(*sc.MaxThroughInMb),
+ },
+ ),
+ )
+ }
+ storageClassesList := types.ListValueMust(
+ postgresflexalphaGen.StorageClassesType{
+ ObjectType: basetypes.ObjectType{
+ AttrTypes: postgresflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ scList,
+ )
+ model.StorageClasses = storageClassesList
+ }
+
+ // Set refreshed state
+ diags = resp.State.Set(ctx, model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ tflog.Info(ctx, "Postgres Flex flavors read")
+}
diff --git a/stackit/internal/services/postgresflexalpha/flavor/datasources_gen/flavors_data_source_gen.go b/stackit/internal/services/postgresflexalpha/flavor/datasources_gen/flavors_data_source_gen.go
new file mode 100644
index 00000000..924d1375
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/flavor/datasources_gen/flavors_data_source_gen.go
@@ -0,0 +1,1909 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func FlavorsDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "flavors": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "cpu": schema.Int64Attribute{
+ Computed: true,
+ Description: "The cpu count of the instance.",
+ MarkdownDescription: "The cpu count of the instance.",
+ },
+ "description": schema.StringAttribute{
+ Computed: true,
+ Description: "The flavor description.",
+ MarkdownDescription: "The flavor description.",
+ },
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "max_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ "memory": schema.Int64Attribute{
+ Computed: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "min_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "minimum storage which is required to order in Gigabyte.",
+ MarkdownDescription: "minimum storage which is required to order in Gigabyte.",
+ },
+ "node_type": schema.StringAttribute{
+ Computed: true,
+ Description: "defines the nodeType it can be either single or replica",
+ MarkdownDescription: "defines the nodeType it can be either single or replica",
+ },
+ "storage_classes": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Computed: true,
+ },
+ "max_io_per_sec": schema.Int64Attribute{
+ Computed: true,
+ },
+ "max_through_in_mb": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: StorageClassesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ },
+ CustomType: FlavorsType{
+ ObjectType: types.ObjectType{
+ AttrTypes: FlavorsValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of flavors available for the project.",
+ MarkdownDescription: "List of flavors available for the project.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the flavors to be returned on each page.",
+ MarkdownDescription: "Sorting of the flavors to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "index.desc",
+ "index.asc",
+ "cpu.desc",
+ "cpu.asc",
+ "flavor_description.asc",
+ "flavor_description.desc",
+ "id.desc",
+ "id.asc",
+ "size_max.desc",
+ "size_max.asc",
+ "ram.desc",
+ "ram.asc",
+ "size_min.desc",
+ "size_min.asc",
+ "storage_class.asc",
+ "storage_class.desc",
+ "node_type.asc",
+ "node_type.desc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type FlavorsModel struct {
+ Flavors types.List `tfsdk:"flavors"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = FlavorsType{}
+
+type FlavorsType struct {
+ basetypes.ObjectType
+}
+
+func (t FlavorsType) Equal(o attr.Type) bool {
+ other, ok := o.(FlavorsType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t FlavorsType) String() string {
+ return "FlavorsType"
+}
+
+func (t FlavorsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return nil, diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return nil, diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return nil, diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return nil, diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return nil, diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueNull() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewFlavorsValueUnknown() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewFlavorsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (FlavorsValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, a missing attribute value was detected. "+
+ "A FlavorsValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid FlavorsValue Attribute Type",
+ "While creating a FlavorsValue value, an invalid attribute value was detected. "+
+ "A FlavorsValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, an extra attribute value was detected. "+
+ "A FlavorsValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra FlavorsValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) FlavorsValue {
+ object, diags := NewFlavorsValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewFlavorsValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t FlavorsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewFlavorsValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewFlavorsValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewFlavorsValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewFlavorsValueMust(FlavorsValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t FlavorsType) ValueType(ctx context.Context) attr.Value {
+ return FlavorsValue{}
+}
+
+var _ basetypes.ObjectValuable = FlavorsValue{}
+
+type FlavorsValue struct {
+ Cpu basetypes.Int64Value `tfsdk:"cpu"`
+ Description basetypes.StringValue `tfsdk:"description"`
+ Id basetypes.StringValue `tfsdk:"id"`
+ MaxGb basetypes.Int64Value `tfsdk:"max_gb"`
+ Memory basetypes.Int64Value `tfsdk:"memory"`
+ MinGb basetypes.Int64Value `tfsdk:"min_gb"`
+ NodeType basetypes.StringValue `tfsdk:"node_type"`
+ StorageClasses basetypes.ListValue `tfsdk:"storage_classes"`
+ state attr.ValueState
+}
+
+func (v FlavorsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 8)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["cpu"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["description"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["memory"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["min_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["node_type"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["storage_classes"] = basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ }.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 8)
+
+ val, err = v.Cpu.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["cpu"] = val
+
+ val, err = v.Description.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["description"] = val
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.MaxGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_gb"] = val
+
+ val, err = v.Memory.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["memory"] = val
+
+ val, err = v.MinGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["min_gb"] = val
+
+ val, err = v.NodeType.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["node_type"] = val
+
+ val, err = v.StorageClasses.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["storage_classes"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v FlavorsValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v FlavorsValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v FlavorsValue) String() string {
+ return "FlavorsValue"
+}
+
+func (v FlavorsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ storageClasses := types.ListValueMust(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ v.StorageClasses.Elements(),
+ )
+
+ if v.StorageClasses.IsNull() {
+ storageClasses = types.ListNull(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ if v.StorageClasses.IsUnknown() {
+ storageClasses = types.ListUnknown(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "cpu": v.Cpu,
+ "description": v.Description,
+ "id": v.Id,
+ "max_gb": v.MaxGb,
+ "memory": v.Memory,
+ "min_gb": v.MinGb,
+ "node_type": v.NodeType,
+ "storage_classes": storageClasses,
+ })
+
+ return objVal, diags
+}
+
+func (v FlavorsValue) Equal(o attr.Value) bool {
+ other, ok := o.(FlavorsValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Cpu.Equal(other.Cpu) {
+ return false
+ }
+
+ if !v.Description.Equal(other.Description) {
+ return false
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.MaxGb.Equal(other.MaxGb) {
+ return false
+ }
+
+ if !v.Memory.Equal(other.Memory) {
+ return false
+ }
+
+ if !v.MinGb.Equal(other.MinGb) {
+ return false
+ }
+
+ if !v.NodeType.Equal(other.NodeType) {
+ return false
+ }
+
+ if !v.StorageClasses.Equal(other.StorageClasses) {
+ return false
+ }
+
+ return true
+}
+
+func (v FlavorsValue) Type(ctx context.Context) attr.Type {
+ return FlavorsType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v FlavorsValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageClassesType{}
+
+type StorageClassesType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageClassesType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageClassesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageClassesType) String() string {
+ return "StorageClassesType"
+}
+
+func (t StorageClassesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return nil, diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return nil, diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueNull() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageClassesValueUnknown() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageClassesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageClassesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, a missing attribute value was detected. "+
+ "A StorageClassesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageClassesValue Attribute Type",
+ "While creating a StorageClassesValue value, an invalid attribute value was detected. "+
+ "A StorageClassesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, an extra attribute value was detected. "+
+ "A StorageClassesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageClassesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageClassesValue {
+ object, diags := NewStorageClassesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageClassesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageClassesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageClassesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageClassesValueMust(StorageClassesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageClassesType) ValueType(ctx context.Context) attr.Value {
+ return StorageClassesValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageClassesValue{}
+
+type StorageClassesValue struct {
+ Class basetypes.StringValue `tfsdk:"class"`
+ MaxIoPerSec basetypes.Int64Value `tfsdk:"max_io_per_sec"`
+ MaxThroughInMb basetypes.Int64Value `tfsdk:"max_through_in_mb"`
+ state attr.ValueState
+}
+
+func (v StorageClassesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 3)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_io_per_sec"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["max_through_in_mb"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 3)
+
+ val, err = v.Class.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["class"] = val
+
+ val, err = v.MaxIoPerSec.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_io_per_sec"] = val
+
+ val, err = v.MaxThroughInMb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_through_in_mb"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageClassesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageClassesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageClassesValue) String() string {
+ return "StorageClassesValue"
+}
+
+func (v StorageClassesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "class": v.Class,
+ "max_io_per_sec": v.MaxIoPerSec,
+ "max_through_in_mb": v.MaxThroughInMb,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageClassesValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageClassesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Class.Equal(other.Class) {
+ return false
+ }
+
+ if !v.MaxIoPerSec.Equal(other.MaxIoPerSec) {
+ return false
+ }
+
+ if !v.MaxThroughInMb.Equal(other.MaxThroughInMb) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageClassesValue) Type(ctx context.Context) attr.Type {
+ return StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageClassesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/flavor/functions.go b/stackit/internal/services/postgresflexalpha/flavor/functions.go
new file mode 100644
index 00000000..67c7f9fa
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/flavor/functions.go
@@ -0,0 +1,65 @@
+package postgresFlexAlphaFlavor
+
+import (
+ "context"
+ "fmt"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+)
+
+type flavorsClientReader interface {
+ GetFlavorsRequest(
+ ctx context.Context,
+ projectId, region string,
+ ) postgresflex.ApiGetFlavorsRequestRequest
+}
+
+func getAllFlavors(ctx context.Context, client flavorsClientReader, projectId, region string) (
+ []postgresflex.ListFlavors,
+ error,
+) {
+ getAllFilter := func(_ postgresflex.ListFlavors) bool { return true }
+ flavorList, err := getFlavorsByFilter(ctx, client, projectId, region, getAllFilter)
+ if err != nil {
+ return nil, err
+ }
+ return flavorList, nil
+}
+
+// getFlavorsByFilter is a helper function to retrieve flavors using a filtern function.
+// Hint: The API does not have a GetFlavors endpoint, only ListFlavors
+func getFlavorsByFilter(
+ ctx context.Context,
+ client flavorsClientReader,
+ projectId, region string,
+ filter func(db postgresflex.ListFlavors) bool,
+) ([]postgresflex.ListFlavors, error) {
+ if projectId == "" || region == "" {
+ return nil, fmt.Errorf("listing postgresflex flavors: projectId and region are required")
+ }
+
+ const pageSize = 25
+
+ var result = make([]postgresflex.ListFlavors, 0)
+
+ for page := int32(1); ; page++ {
+ res, err := client.GetFlavorsRequest(ctx, projectId, region).
+ Page(page).Size(pageSize).Sort(postgresflex.FLAVORSORT_ID_ASC).Execute()
+ if err != nil {
+ return nil, fmt.Errorf("requesting flavors list (page %d): %w", page, err)
+ }
+
+ // If the API returns no flavors, we have reached the end of the list.
+ if res.Flavors == nil || len(*res.Flavors) == 0 {
+ break
+ }
+
+ for _, flavor := range *res.Flavors {
+ if filter(flavor) {
+ result = append(result, flavor)
+ }
+ }
+ }
+
+ return result, nil
+}
diff --git a/stackit/internal/services/postgresflexalpha/flavor/functions_test.go b/stackit/internal/services/postgresflexalpha/flavor/functions_test.go
new file mode 100644
index 00000000..bb7180c1
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/flavor/functions_test.go
@@ -0,0 +1,135 @@
+package postgresFlexAlphaFlavor
+
+import (
+ "context"
+ "testing"
+
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+)
+
+type mockRequest struct {
+ executeFunc func() (*postgresflex.GetFlavorsResponse, error)
+}
+
+func (m *mockRequest) Page(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m }
+func (m *mockRequest) Size(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m }
+func (m *mockRequest) Sort(_ postgresflex.FlavorSort) postgresflex.ApiGetFlavorsRequestRequest {
+ return m
+}
+func (m *mockRequest) Execute() (*postgresflex.GetFlavorsResponse, error) {
+ return m.executeFunc()
+}
+
+type mockFlavorsClient struct {
+ executeRequest func() postgresflex.ApiGetFlavorsRequestRequest
+}
+
+func (m *mockFlavorsClient) GetFlavorsRequest(_ context.Context, _, _ string) postgresflex.ApiGetFlavorsRequestRequest {
+ return m.executeRequest()
+}
+
+var mockResp = func(page int64) (*postgresflex.GetFlavorsResponse, error) {
+ if page == 1 {
+ return &postgresflex.GetFlavorsResponse{
+ Flavors: &[]postgresflex.ListFlavors{
+ {Id: utils.Ptr("flavor-1"), Description: utils.Ptr("first")},
+ {Id: utils.Ptr("flavor-2"), Description: utils.Ptr("second")},
+ },
+ }, nil
+ }
+ if page == 2 {
+ return &postgresflex.GetFlavorsResponse{
+ Flavors: &[]postgresflex.ListFlavors{
+ {Id: utils.Ptr("flavor-3"), Description: utils.Ptr("three")},
+ },
+ }, nil
+ }
+
+ return &postgresflex.GetFlavorsResponse{
+ Flavors: &[]postgresflex.ListFlavors{},
+ }, nil
+}
+
+func TestGetFlavorsByFilter(t *testing.T) {
+ tests := []struct {
+ description string
+ projectId string
+ region string
+ mockErr error
+ filter func(postgresflex.ListFlavors) bool
+ wantCount int
+ wantErr bool
+ }{
+ {
+ description: "Success - Get all flavors (2 pages)",
+ projectId: "pid", region: "reg",
+ filter: func(_ postgresflex.ListFlavors) bool { return true },
+ wantCount: 3,
+ wantErr: false,
+ },
+ {
+ description: "Success - Filter flavors by description",
+ projectId: "pid", region: "reg",
+ filter: func(f postgresflex.ListFlavors) bool { return *f.Description == "first" },
+ wantCount: 1,
+ wantErr: false,
+ },
+ {
+ description: "Error - Missing parameters",
+ projectId: "", region: "reg",
+ wantErr: true,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ var currentPage int64
+ client := &mockFlavorsClient{
+ executeRequest: func() postgresflex.ApiGetFlavorsRequestRequest {
+ return &mockRequest{
+ executeFunc: func() (*postgresflex.GetFlavorsResponse, error) {
+ currentPage++
+ return mockResp(currentPage)
+ },
+ }
+ },
+ }
+ actual, err := getFlavorsByFilter(context.Background(), client, tt.projectId, tt.region, tt.filter)
+
+ if (err != nil) != tt.wantErr {
+ t.Errorf("getFlavorsByFilter() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+
+ if !tt.wantErr && len(actual) != tt.wantCount {
+ t.Errorf("getFlavorsByFilter() got %d flavors, want %d", len(actual), tt.wantCount)
+ }
+ },
+ )
+ }
+}
+
+func TestGetAllFlavors(t *testing.T) {
+ var currentPage int64
+ client := &mockFlavorsClient{
+ executeRequest: func() postgresflex.ApiGetFlavorsRequestRequest {
+ return &mockRequest{
+ executeFunc: func() (*postgresflex.GetFlavorsResponse, error) {
+ currentPage++
+ return mockResp(currentPage)
+ },
+ }
+ },
+ }
+
+ res, err := getAllFlavors(context.Background(), client, "pid", "reg")
+ if err != nil {
+ t.Errorf("getAllFlavors() unexpected error: %v", err)
+ }
+ if len(res) != 3 {
+ t.Errorf("getAllFlavors() expected 3 flavor, got %d", len(res))
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/flavors/datasource.go b/stackit/internal/services/postgresflexalpha/flavors/datasource.go
new file mode 100644
index 00000000..df8fddac
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/flavors/datasource.go
@@ -0,0 +1,82 @@
+package postgresflexalpha
+
+import (
+ "context"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ postgresflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavors/datasources_gen"
+ postgresflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/utils"
+)
+
+var (
+ _ datasource.DataSource = &flavorsDataSource{}
+ _ datasource.DataSourceWithConfigure = &flavorsDataSource{}
+)
+
+func NewFlavorsDataSource() datasource.DataSource {
+ return &flavorsDataSource{}
+}
+
+// dataSourceModel maps the data source schema data.
+type dataSourceModel = postgresflexalphaGen.FlavorsModel
+
+type flavorsDataSource struct {
+ client *postgresflexalpha.APIClient
+ providerData core.ProviderData
+}
+
+func (d *flavorsDataSource) Metadata(
+ _ context.Context,
+ req datasource.MetadataRequest,
+ resp *datasource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_postgresflexalpha_flavors"
+}
+
+func (d *flavorsDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = postgresflexalphaGen.FlavorsDataSourceSchema(ctx)
+}
+
+// Configure adds the provider configured client to the data source.
+func (d *flavorsDataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
+ var ok bool
+ d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClient := postgresflexUtils.ConfigureClient(ctx, &d.providerData, &resp.Diagnostics)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ d.client = apiClient
+ tflog.Info(ctx, "Postgres Flex version client configured")
+}
+
+func (d *flavorsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var data dataSourceModel
+
+ // Read Terraform configuration data into the model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Todo: Read API call logic
+
+ // Example data value setting
+ // data.Id = types.StringValue("example-id")
+
+ // Save data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+}
diff --git a/stackit/internal/services/postgresflexalpha/flavors/datasources_gen/flavors_data_source_gen.go b/stackit/internal/services/postgresflexalpha/flavors/datasources_gen/flavors_data_source_gen.go
new file mode 100644
index 00000000..e0b76221
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/flavors/datasources_gen/flavors_data_source_gen.go
@@ -0,0 +1,1907 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func FlavorsDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "flavors": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "cpu": schema.Int64Attribute{
+ Computed: true,
+ Description: "The cpu count of the instance.",
+ MarkdownDescription: "The cpu count of the instance.",
+ },
+ "description": schema.StringAttribute{
+ Computed: true,
+ Description: "The flavor description.",
+ MarkdownDescription: "The flavor description.",
+ },
+ "tf_original_api_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "max_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ "memory": schema.Int64Attribute{
+ Computed: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "min_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "minimum storage which is required to order in Gigabyte.",
+ MarkdownDescription: "minimum storage which is required to order in Gigabyte.",
+ },
+ "node_type": schema.StringAttribute{
+ Computed: true,
+ Description: "defines the nodeType it can be either single or replica",
+ MarkdownDescription: "defines the nodeType it can be either single or replica",
+ },
+ "storage_classes": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Computed: true,
+ },
+ "max_io_per_sec": schema.Int64Attribute{
+ Computed: true,
+ },
+ "max_through_in_mb": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: StorageClassesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ },
+ CustomType: FlavorsType{
+ ObjectType: types.ObjectType{
+ AttrTypes: FlavorsValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of flavors available for the project.",
+ MarkdownDescription: "List of flavors available for the project.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the flavors to be returned on each page.",
+ MarkdownDescription: "Sorting of the flavors to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "cpu.desc",
+ "cpu.asc",
+ "flavor_description.asc",
+ "flavor_description.desc",
+ "id.desc",
+ "id.asc",
+ "size_max.desc",
+ "size_max.asc",
+ "ram.desc",
+ "ram.asc",
+ "size_min.desc",
+ "size_min.asc",
+ "storage_class.asc",
+ "storage_class.desc",
+ "node_type.asc",
+ "node_type.desc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type FlavorsModel struct {
+ Flavors types.List `tfsdk:"flavors"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = FlavorsType{}
+
+type FlavorsType struct {
+ basetypes.ObjectType
+}
+
+func (t FlavorsType) Equal(o attr.Type) bool {
+ other, ok := o.(FlavorsType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t FlavorsType) String() string {
+ return "FlavorsType"
+}
+
+func (t FlavorsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return nil, diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return nil, diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return nil, diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return nil, diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return nil, diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueNull() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewFlavorsValueUnknown() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewFlavorsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (FlavorsValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, a missing attribute value was detected. "+
+ "A FlavorsValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid FlavorsValue Attribute Type",
+ "While creating a FlavorsValue value, an invalid attribute value was detected. "+
+ "A FlavorsValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, an extra attribute value was detected. "+
+ "A FlavorsValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra FlavorsValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) FlavorsValue {
+ object, diags := NewFlavorsValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewFlavorsValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t FlavorsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewFlavorsValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewFlavorsValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewFlavorsValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewFlavorsValueMust(FlavorsValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t FlavorsType) ValueType(ctx context.Context) attr.Value {
+ return FlavorsValue{}
+}
+
+var _ basetypes.ObjectValuable = FlavorsValue{}
+
+type FlavorsValue struct {
+ Cpu basetypes.Int64Value `tfsdk:"cpu"`
+ Description basetypes.StringValue `tfsdk:"description"`
+ Id basetypes.StringValue `tfsdk:"id"`
+ MaxGb basetypes.Int64Value `tfsdk:"max_gb"`
+ Memory basetypes.Int64Value `tfsdk:"memory"`
+ MinGb basetypes.Int64Value `tfsdk:"min_gb"`
+ NodeType basetypes.StringValue `tfsdk:"node_type"`
+ StorageClasses basetypes.ListValue `tfsdk:"storage_classes"`
+ state attr.ValueState
+}
+
+func (v FlavorsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 8)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["cpu"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["description"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["memory"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["min_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["node_type"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["storage_classes"] = basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ }.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 8)
+
+ val, err = v.Cpu.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["cpu"] = val
+
+ val, err = v.Description.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["description"] = val
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.MaxGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_gb"] = val
+
+ val, err = v.Memory.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["memory"] = val
+
+ val, err = v.MinGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["min_gb"] = val
+
+ val, err = v.NodeType.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["node_type"] = val
+
+ val, err = v.StorageClasses.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["storage_classes"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v FlavorsValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v FlavorsValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v FlavorsValue) String() string {
+ return "FlavorsValue"
+}
+
+func (v FlavorsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ storageClasses := types.ListValueMust(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ v.StorageClasses.Elements(),
+ )
+
+ if v.StorageClasses.IsNull() {
+ storageClasses = types.ListNull(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ if v.StorageClasses.IsUnknown() {
+ storageClasses = types.ListUnknown(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "cpu": v.Cpu,
+ "description": v.Description,
+ "id": v.Id,
+ "max_gb": v.MaxGb,
+ "memory": v.Memory,
+ "min_gb": v.MinGb,
+ "node_type": v.NodeType,
+ "storage_classes": storageClasses,
+ })
+
+ return objVal, diags
+}
+
+func (v FlavorsValue) Equal(o attr.Value) bool {
+ other, ok := o.(FlavorsValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Cpu.Equal(other.Cpu) {
+ return false
+ }
+
+ if !v.Description.Equal(other.Description) {
+ return false
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.MaxGb.Equal(other.MaxGb) {
+ return false
+ }
+
+ if !v.Memory.Equal(other.Memory) {
+ return false
+ }
+
+ if !v.MinGb.Equal(other.MinGb) {
+ return false
+ }
+
+ if !v.NodeType.Equal(other.NodeType) {
+ return false
+ }
+
+ if !v.StorageClasses.Equal(other.StorageClasses) {
+ return false
+ }
+
+ return true
+}
+
+func (v FlavorsValue) Type(ctx context.Context) attr.Type {
+ return FlavorsType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v FlavorsValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageClassesType{}
+
+type StorageClassesType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageClassesType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageClassesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageClassesType) String() string {
+ return "StorageClassesType"
+}
+
+func (t StorageClassesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return nil, diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return nil, diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueNull() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageClassesValueUnknown() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageClassesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageClassesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, a missing attribute value was detected. "+
+ "A StorageClassesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageClassesValue Attribute Type",
+ "While creating a StorageClassesValue value, an invalid attribute value was detected. "+
+ "A StorageClassesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, an extra attribute value was detected. "+
+ "A StorageClassesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageClassesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageClassesValue {
+ object, diags := NewStorageClassesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageClassesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageClassesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageClassesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageClassesValueMust(StorageClassesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageClassesType) ValueType(ctx context.Context) attr.Value {
+ return StorageClassesValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageClassesValue{}
+
+type StorageClassesValue struct {
+ Class basetypes.StringValue `tfsdk:"class"`
+ MaxIoPerSec basetypes.Int64Value `tfsdk:"max_io_per_sec"`
+ MaxThroughInMb basetypes.Int64Value `tfsdk:"max_through_in_mb"`
+ state attr.ValueState
+}
+
+func (v StorageClassesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 3)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_io_per_sec"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["max_through_in_mb"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 3)
+
+ val, err = v.Class.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["class"] = val
+
+ val, err = v.MaxIoPerSec.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_io_per_sec"] = val
+
+ val, err = v.MaxThroughInMb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_through_in_mb"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageClassesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageClassesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageClassesValue) String() string {
+ return "StorageClassesValue"
+}
+
+func (v StorageClassesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "class": v.Class,
+ "max_io_per_sec": v.MaxIoPerSec,
+ "max_through_in_mb": v.MaxThroughInMb,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageClassesValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageClassesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Class.Equal(other.Class) {
+ return false
+ }
+
+ if !v.MaxIoPerSec.Equal(other.MaxIoPerSec) {
+ return false
+ }
+
+ if !v.MaxThroughInMb.Equal(other.MaxThroughInMb) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageClassesValue) Type(ctx context.Context) attr.Type {
+ return StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageClassesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/instance/datasource.go b/stackit/internal/services/postgresflexalpha/instance/datasource.go
new file mode 100644
index 00000000..6a4296a4
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/instance/datasource.go
@@ -0,0 +1,130 @@
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ postgresflexalpha2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance/datasources_gen"
+ postgresflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/utils"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+// Ensure the implementation satisfies the expected interfaces.
+var (
+ _ datasource.DataSource = &instanceDataSource{}
+)
+
+// NewInstanceDataSource is a helper function to simplify the provider implementation.
+func NewInstanceDataSource() datasource.DataSource {
+ return &instanceDataSource{}
+}
+
+// dataSourceModel maps the data source schema data.
+type dataSourceModel struct {
+ postgresflexalpha2.InstanceModel
+ TerraformID types.String `tfsdk:"id"`
+}
+
+// instanceDataSource is the data source implementation.
+type instanceDataSource struct {
+ client *postgresflexalpha.APIClient
+ providerData core.ProviderData
+}
+
+// Metadata returns the data source type name.
+func (r *instanceDataSource) Metadata(
+ _ context.Context,
+ req datasource.MetadataRequest,
+ resp *datasource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_postgresflexalpha_instance"
+}
+
+// Configure adds the provider configured client to the data source.
+func (r *instanceDataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
+ var ok bool
+ r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClient := postgresflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ r.client = apiClient
+ tflog.Info(ctx, "Postgres Flex instance client configured")
+}
+
+// Schema defines the schema for the data source.
+func (r *instanceDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = postgresflexalpha2.InstanceDataSourceSchema(ctx)
+}
+
+// Read refreshes the Terraform state with the latest data.
+func (r *instanceDataSource) Read(
+ ctx context.Context,
+ req datasource.ReadRequest,
+ resp *datasource.ReadResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model dataSourceModel
+ diags := req.Config.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ region := r.providerData.GetRegionWithOverride(model.Region)
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "region", region)
+ instanceResp, err := r.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
+ if err != nil {
+ utils.LogError(
+ ctx,
+ &resp.Diagnostics,
+ err,
+ "Reading instance",
+ fmt.Sprintf("Instance with ID %q does not exist in project %q.", instanceId, projectId),
+ map[int]string{
+ http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId),
+ },
+ )
+ resp.State.RemoveResource(ctx)
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ err = mapGetDataInstanceResponseToModel(ctx, &model, instanceResp)
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Calling API: %v", err))
+ return
+ }
+
+ // Set refreshed state
+ diags = resp.State.Set(ctx, model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ tflog.Info(ctx, "Postgres Flex instance read")
+}
diff --git a/stackit/internal/services/postgresflexalpha/instance/datasource.go.bak b/stackit/internal/services/postgresflexalpha/instance/datasource.go.bak
deleted file mode 100644
index 8ca8098d..00000000
--- a/stackit/internal/services/postgresflexalpha/instance/datasource.go.bak
+++ /dev/null
@@ -1,222 +0,0 @@
-package postgresflexa
-
-import (
- "context"
- "fmt"
- "net/http"
-
- "github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- postgresflexUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflexalpha/utils"
-
- "github.com/hashicorp/terraform-plugin-framework/datasource"
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
- "github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
-
- "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha/wait"
-)
-
-// Ensure the implementation satisfies the expected interfaces.
-var (
- _ datasource.DataSource = &instanceDataSource{}
-)
-
-// NewInstanceDataSource is a helper function to simplify the provider implementation.
-func NewInstanceDataSource() datasource.DataSource {
- return &instanceDataSource{}
-}
-
-// instanceDataSource is the data source implementation.
-type instanceDataSource struct {
- client *postgresflexalpha.APIClient
- providerData core.ProviderData
-}
-
-// Metadata returns the data source type name.
-func (r *instanceDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
- resp.TypeName = req.ProviderTypeName + "_postgresflexalpha_instance"
-}
-
-// Configure adds the provider configured client to the data source.
-func (r *instanceDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
- var ok bool
- r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
- if !ok {
- return
- }
-
- apiClient := postgresflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics)
- if resp.Diagnostics.HasError() {
- return
- }
- r.client = apiClient
- tflog.Info(ctx, "Postgres Flex instance client configured")
-}
-
-// Schema defines the schema for the data source.
-func (r *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
- descriptions := map[string]string{
- "main": "Postgres Flex instance data source schema. Must have a `region` specified in the provider configuration.",
- "id": "Terraform's internal data source. ID. It is structured as \"`project_id`,`region`,`instance_id`\".",
- "instance_id": "ID of the PostgresFlex instance.",
- "project_id": "STACKIT project ID to which the instance is associated.",
- "name": "Instance name.",
- "acl": "The Access Control List (ACL) for the PostgresFlex instance.",
- "region": "The resource region. If not defined, the provider region is used.",
- }
-
- resp.Schema = schema.Schema{
- Description: descriptions["main"],
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Description: descriptions["id"],
- Computed: true,
- },
- "instance_id": schema.StringAttribute{
- Description: descriptions["instance_id"],
- Required: true,
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "project_id": schema.StringAttribute{
- Description: descriptions["project_id"],
- Required: true,
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "name": schema.StringAttribute{
- Description: descriptions["name"],
- Computed: true,
- },
- "acl": schema.ListAttribute{
- Description: descriptions["acl"],
- ElementType: types.StringType,
- Computed: true,
- },
- "backup_schedule": schema.StringAttribute{
- Computed: true,
- },
- "flavor": schema.SingleNestedAttribute{
- Computed: true,
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Computed: true,
- },
- "description": schema.StringAttribute{
- Computed: true,
- },
- "cpu": schema.Int64Attribute{
- Computed: true,
- },
- "ram": schema.Int64Attribute{
- Computed: true,
- },
- },
- },
- "replicas": schema.Int64Attribute{
- Computed: true,
- },
- "storage": schema.SingleNestedAttribute{
- Computed: true,
- Attributes: map[string]schema.Attribute{
- "class": schema.StringAttribute{
- Computed: true,
- },
- "size": schema.Int64Attribute{
- Computed: true,
- },
- },
- },
- "version": schema.StringAttribute{
- Computed: true,
- },
- "region": schema.StringAttribute{
- // the region cannot be found, so it has to be passed
- Optional: true,
- Description: descriptions["region"],
- },
- },
- }
-}
-
-// Read refreshes the Terraform state with the latest data.
-func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
- var model Model
- diags := req.Config.Get(ctx, &model)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
-
- ctx = core.InitProviderContext(ctx)
-
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- region := r.providerData.GetRegionWithOverride(model.Region)
- ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
- ctx = tflog.SetField(ctx, "region", region)
- instanceResp, err := r.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
- if err != nil {
- utils.LogError(
- ctx,
- &resp.Diagnostics,
- err,
- "Reading instance",
- fmt.Sprintf("Instance with ID %q does not exist in project %q.", instanceId, projectId),
- map[int]string{
- http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId),
- },
- )
- resp.State.RemoveResource(ctx)
- return
- }
-
- ctx = core.LogResponse(ctx)
-
- if instanceResp != nil && instanceResp.Status != nil && *instanceResp.Status == wait.InstanceStateDeleted {
- resp.State.RemoveResource(ctx)
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", "Instance was deleted successfully")
- return
- }
-
- var flavor = &flavorModel{}
- if !(model.Flavor.IsNull() || model.Flavor.IsUnknown()) {
- diags = model.Flavor.As(ctx, flavor, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
- var storage = &storageModel{}
- if !(model.Storage.IsNull() || model.Storage.IsUnknown()) {
- diags = model.Storage.As(ctx, storage, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- err = mapFields(ctx, instanceResp, &model, flavor, storage, region)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API payload: %v", err))
- return
- }
- // Set refreshed state
- diags = resp.State.Set(ctx, model)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- tflog.Info(ctx, "Postgres Flex instance read")
-}
diff --git a/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go b/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go
new file mode 100644
index 00000000..844d494e
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go
@@ -0,0 +1,2347 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func InstanceDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "acl": schema.ListAttribute{
+ ElementType: types.StringType,
+ Computed: true,
+ Description: "List of IPV4 cidr.",
+ MarkdownDescription: "List of IPV4 cidr.",
+ },
+ "backup_schedule": schema.StringAttribute{
+ Computed: true,
+ Description: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ MarkdownDescription: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ },
+ "connection_info": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "write": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "host": schema.StringAttribute{
+ Computed: true,
+ Description: "The host of the instance.",
+ MarkdownDescription: "The host of the instance.",
+ },
+ "port": schema.Int64Attribute{
+ Computed: true,
+ Description: "The port of the instance.",
+ MarkdownDescription: "The port of the instance.",
+ },
+ },
+ CustomType: WriteType{
+ ObjectType: types.ObjectType{
+ AttrTypes: WriteValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "The DNS name and port in the instance overview",
+ MarkdownDescription: "The DNS name and port in the instance overview",
+ },
+ },
+ CustomType: ConnectionInfoType{
+ ObjectType: types.ObjectType{
+ AttrTypes: ConnectionInfoValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "The connection information of the instance",
+ MarkdownDescription: "The connection information of the instance",
+ },
+ "encryption": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "kek_key_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The encryption-key key identifier",
+ MarkdownDescription: "The encryption-key key identifier",
+ },
+ "kek_key_ring_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The encryption-key keyring identifier",
+ MarkdownDescription: "The encryption-key keyring identifier",
+ },
+ "kek_key_version": schema.StringAttribute{
+ Computed: true,
+ Description: "The encryption-key version",
+ MarkdownDescription: "The encryption-key version",
+ },
+ "service_account": schema.StringAttribute{
+ Computed: true,
+ },
+ },
+ CustomType: EncryptionType{
+ ObjectType: types.ObjectType{
+ AttrTypes: EncryptionValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "The configuration for instance's volume and backup storage encryption.\n\n⚠\ufe1d **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ MarkdownDescription: "The configuration for instance's volume and backup storage encryption.\n\n⚠\ufe1d **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ },
+ "flavor_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "tf_original_api_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "is_deletable": schema.BoolAttribute{
+ Computed: true,
+ Description: "Whether the instance can be deleted or not.",
+ MarkdownDescription: "Whether the instance can be deleted or not.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the instance.",
+ MarkdownDescription: "The name of the instance.",
+ },
+ "network": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "access_scope": schema.StringAttribute{
+ Computed: true,
+ Description: "The access scope of the instance. It defines if the instance is public or airgapped.",
+ MarkdownDescription: "The access scope of the instance. It defines if the instance is public or airgapped.",
+ },
+ "acl": schema.ListAttribute{
+ ElementType: types.StringType,
+ Computed: true,
+ Description: "List of IPV4 cidr.",
+ MarkdownDescription: "List of IPV4 cidr.",
+ },
+ "instance_address": schema.StringAttribute{
+ Computed: true,
+ },
+ "router_address": schema.StringAttribute{
+ Computed: true,
+ },
+ },
+ CustomType: NetworkType{
+ ObjectType: types.ObjectType{
+ AttrTypes: NetworkValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "The access configuration of the instance",
+ MarkdownDescription: "The access configuration of the instance",
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "replicas": schema.Int64Attribute{
+ Computed: true,
+ Description: "How many replicas the instance should have.",
+ MarkdownDescription: "How many replicas the instance should have.",
+ },
+ "retention_days": schema.Int64Attribute{
+ Computed: true,
+ Description: "How long backups are retained. The value can only be between 32 and 365 days.",
+ MarkdownDescription: "How long backups are retained. The value can only be between 32 and 365 days.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ Description: "The current status of the instance.",
+ MarkdownDescription: "The current status of the instance.",
+ },
+ "storage": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "performance_class": schema.StringAttribute{
+ Computed: true,
+ Description: "The storage class for the storage.",
+ MarkdownDescription: "The storage class for the storage.",
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ Description: "The storage size in Gigabytes.",
+ MarkdownDescription: "The storage size in Gigabytes.",
+ },
+ },
+ CustomType: StorageType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "The object containing information about the storage size and class.",
+ MarkdownDescription: "The object containing information about the storage size and class.",
+ },
+ "version": schema.StringAttribute{
+ Computed: true,
+ Description: "The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters.",
+ MarkdownDescription: "The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters.",
+ },
+ },
+ }
+}
+
+type InstanceModel struct {
+ Acl types.List `tfsdk:"acl"`
+ BackupSchedule types.String `tfsdk:"backup_schedule"`
+ ConnectionInfo ConnectionInfoValue `tfsdk:"connection_info"`
+ Encryption EncryptionValue `tfsdk:"encryption"`
+ FlavorId types.String `tfsdk:"flavor_id"`
+ Id types.String `tfsdk:"tf_original_api_id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ IsDeletable types.Bool `tfsdk:"is_deletable"`
+ Name types.String `tfsdk:"name"`
+ Network NetworkValue `tfsdk:"network"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Replicas types.Int64 `tfsdk:"replicas"`
+ RetentionDays types.Int64 `tfsdk:"retention_days"`
+ Status types.String `tfsdk:"status"`
+ Storage StorageValue `tfsdk:"storage"`
+ Version types.String `tfsdk:"version"`
+}
+
+var _ basetypes.ObjectTypable = ConnectionInfoType{}
+
+type ConnectionInfoType struct {
+ basetypes.ObjectType
+}
+
+func (t ConnectionInfoType) Equal(o attr.Type) bool {
+ other, ok := o.(ConnectionInfoType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t ConnectionInfoType) String() string {
+ return "ConnectionInfoType"
+}
+
+func (t ConnectionInfoType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ writeAttribute, ok := attributes["write"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `write is missing from object`)
+
+ return nil, diags
+ }
+
+ writeVal, ok := writeAttribute.(basetypes.ObjectValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`write expected to be basetypes.ObjectValue, was: %T`, writeAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return ConnectionInfoValue{
+ Write: writeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewConnectionInfoValueNull() ConnectionInfoValue {
+ return ConnectionInfoValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewConnectionInfoValueUnknown() ConnectionInfoValue {
+ return ConnectionInfoValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewConnectionInfoValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (ConnectionInfoValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing ConnectionInfoValue Attribute Value",
+ "While creating a ConnectionInfoValue value, a missing attribute value was detected. "+
+ "A ConnectionInfoValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("ConnectionInfoValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid ConnectionInfoValue Attribute Type",
+ "While creating a ConnectionInfoValue value, an invalid attribute value was detected. "+
+ "A ConnectionInfoValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("ConnectionInfoValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("ConnectionInfoValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra ConnectionInfoValue Attribute Value",
+ "While creating a ConnectionInfoValue value, an extra attribute value was detected. "+
+ "A ConnectionInfoValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra ConnectionInfoValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewConnectionInfoValueUnknown(), diags
+ }
+
+ writeAttribute, ok := attributes["write"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `write is missing from object`)
+
+ return NewConnectionInfoValueUnknown(), diags
+ }
+
+ writeVal, ok := writeAttribute.(basetypes.ObjectValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`write expected to be basetypes.ObjectValue, was: %T`, writeAttribute))
+ }
+
+ if diags.HasError() {
+ return NewConnectionInfoValueUnknown(), diags
+ }
+
+ return ConnectionInfoValue{
+ Write: writeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewConnectionInfoValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) ConnectionInfoValue {
+ object, diags := NewConnectionInfoValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewConnectionInfoValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t ConnectionInfoType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewConnectionInfoValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewConnectionInfoValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewConnectionInfoValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewConnectionInfoValueMust(ConnectionInfoValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t ConnectionInfoType) ValueType(ctx context.Context) attr.Value {
+ return ConnectionInfoValue{}
+}
+
+var _ basetypes.ObjectValuable = ConnectionInfoValue{}
+
+type ConnectionInfoValue struct {
+ Write basetypes.ObjectValue `tfsdk:"write"`
+ state attr.ValueState
+}
+
+func (v ConnectionInfoValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 1)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["write"] = basetypes.ObjectType{
+ AttrTypes: WriteValue{}.AttributeTypes(ctx),
+ }.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 1)
+
+ val, err = v.Write.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["write"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v ConnectionInfoValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v ConnectionInfoValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v ConnectionInfoValue) String() string {
+ return "ConnectionInfoValue"
+}
+
+func (v ConnectionInfoValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ var write basetypes.ObjectValue
+
+ if v.Write.IsNull() {
+ write = types.ObjectNull(
+ WriteValue{}.AttributeTypes(ctx),
+ )
+ }
+
+ if v.Write.IsUnknown() {
+ write = types.ObjectUnknown(
+ WriteValue{}.AttributeTypes(ctx),
+ )
+ }
+
+ if !v.Write.IsNull() && !v.Write.IsUnknown() {
+ write = types.ObjectValueMust(
+ WriteValue{}.AttributeTypes(ctx),
+ v.Write.Attributes(),
+ )
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "write": basetypes.ObjectType{
+ AttrTypes: WriteValue{}.AttributeTypes(ctx),
+ },
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "write": write,
+ })
+
+ return objVal, diags
+}
+
+func (v ConnectionInfoValue) Equal(o attr.Value) bool {
+ other, ok := o.(ConnectionInfoValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Write.Equal(other.Write) {
+ return false
+ }
+
+ return true
+}
+
+func (v ConnectionInfoValue) Type(ctx context.Context) attr.Type {
+ return ConnectionInfoType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v ConnectionInfoValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "write": basetypes.ObjectType{
+ AttrTypes: WriteValue{}.AttributeTypes(ctx),
+ },
+ }
+}
+
+var _ basetypes.ObjectTypable = WriteType{}
+
+type WriteType struct {
+ basetypes.ObjectType
+}
+
+func (t WriteType) Equal(o attr.Type) bool {
+ other, ok := o.(WriteType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t WriteType) String() string {
+ return "WriteType"
+}
+
+func (t WriteType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ hostAttribute, ok := attributes["host"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `host is missing from object`)
+
+ return nil, diags
+ }
+
+ hostVal, ok := hostAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute))
+ }
+
+ portAttribute, ok := attributes["port"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `port is missing from object`)
+
+ return nil, diags
+ }
+
+ portVal, ok := portAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return WriteValue{
+ Host: hostVal,
+ Port: portVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewWriteValueNull() WriteValue {
+ return WriteValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewWriteValueUnknown() WriteValue {
+ return WriteValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewWriteValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (WriteValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing WriteValue Attribute Value",
+ "While creating a WriteValue value, a missing attribute value was detected. "+
+ "A WriteValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("WriteValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid WriteValue Attribute Type",
+ "While creating a WriteValue value, an invalid attribute value was detected. "+
+ "A WriteValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("WriteValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("WriteValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra WriteValue Attribute Value",
+ "While creating a WriteValue value, an extra attribute value was detected. "+
+ "A WriteValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra WriteValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewWriteValueUnknown(), diags
+ }
+
+ hostAttribute, ok := attributes["host"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `host is missing from object`)
+
+ return NewWriteValueUnknown(), diags
+ }
+
+ hostVal, ok := hostAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute))
+ }
+
+ portAttribute, ok := attributes["port"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `port is missing from object`)
+
+ return NewWriteValueUnknown(), diags
+ }
+
+ portVal, ok := portAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute))
+ }
+
+ if diags.HasError() {
+ return NewWriteValueUnknown(), diags
+ }
+
+ return WriteValue{
+ Host: hostVal,
+ Port: portVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewWriteValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) WriteValue {
+ object, diags := NewWriteValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewWriteValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t WriteType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewWriteValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewWriteValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewWriteValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewWriteValueMust(WriteValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t WriteType) ValueType(ctx context.Context) attr.Value {
+ return WriteValue{}
+}
+
+var _ basetypes.ObjectValuable = WriteValue{}
+
+type WriteValue struct {
+ Host basetypes.StringValue `tfsdk:"host"`
+ Port basetypes.Int64Value `tfsdk:"port"`
+ state attr.ValueState
+}
+
+func (v WriteValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 2)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["host"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["port"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 2)
+
+ val, err = v.Host.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["host"] = val
+
+ val, err = v.Port.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["port"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v WriteValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v WriteValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v WriteValue) String() string {
+ return "WriteValue"
+}
+
+func (v WriteValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "host": basetypes.StringType{},
+ "port": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "host": v.Host,
+ "port": v.Port,
+ })
+
+ return objVal, diags
+}
+
+func (v WriteValue) Equal(o attr.Value) bool {
+ other, ok := o.(WriteValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Host.Equal(other.Host) {
+ return false
+ }
+
+ if !v.Port.Equal(other.Port) {
+ return false
+ }
+
+ return true
+}
+
+func (v WriteValue) Type(ctx context.Context) attr.Type {
+ return WriteType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v WriteValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "host": basetypes.StringType{},
+ "port": basetypes.Int64Type{},
+ }
+}
+
+var _ basetypes.ObjectTypable = EncryptionType{}
+
+type EncryptionType struct {
+ basetypes.ObjectType
+}
+
+func (t EncryptionType) Equal(o attr.Type) bool {
+ other, ok := o.(EncryptionType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t EncryptionType) String() string {
+ return "EncryptionType"
+}
+
+func (t EncryptionType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return nil, diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueNull() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewEncryptionValueUnknown() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewEncryptionValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (EncryptionValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, a missing attribute value was detected. "+
+ "A EncryptionValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid EncryptionValue Attribute Type",
+ "While creating a EncryptionValue value, an invalid attribute value was detected. "+
+ "A EncryptionValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, an extra attribute value was detected. "+
+ "A EncryptionValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra EncryptionValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) EncryptionValue {
+ object, diags := NewEncryptionValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewEncryptionValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t EncryptionType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewEncryptionValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewEncryptionValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewEncryptionValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewEncryptionValueMust(EncryptionValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t EncryptionType) ValueType(ctx context.Context) attr.Value {
+ return EncryptionValue{}
+}
+
+var _ basetypes.ObjectValuable = EncryptionValue{}
+
+type EncryptionValue struct {
+ KekKeyId basetypes.StringValue `tfsdk:"kek_key_id"`
+ KekKeyRingId basetypes.StringValue `tfsdk:"kek_key_ring_id"`
+ KekKeyVersion basetypes.StringValue `tfsdk:"kek_key_version"`
+ ServiceAccount basetypes.StringValue `tfsdk:"service_account"`
+ state attr.ValueState
+}
+
+func (v EncryptionValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["kek_key_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_ring_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_version"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["service_account"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.KekKeyId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_id"] = val
+
+ val, err = v.KekKeyRingId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_ring_id"] = val
+
+ val, err = v.KekKeyVersion.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_version"] = val
+
+ val, err = v.ServiceAccount.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["service_account"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v EncryptionValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v EncryptionValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v EncryptionValue) String() string {
+ return "EncryptionValue"
+}
+
+func (v EncryptionValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "kek_key_id": v.KekKeyId,
+ "kek_key_ring_id": v.KekKeyRingId,
+ "kek_key_version": v.KekKeyVersion,
+ "service_account": v.ServiceAccount,
+ })
+
+ return objVal, diags
+}
+
+func (v EncryptionValue) Equal(o attr.Value) bool {
+ other, ok := o.(EncryptionValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.KekKeyId.Equal(other.KekKeyId) {
+ return false
+ }
+
+ if !v.KekKeyRingId.Equal(other.KekKeyRingId) {
+ return false
+ }
+
+ if !v.KekKeyVersion.Equal(other.KekKeyVersion) {
+ return false
+ }
+
+ if !v.ServiceAccount.Equal(other.ServiceAccount) {
+ return false
+ }
+
+ return true
+}
+
+func (v EncryptionValue) Type(ctx context.Context) attr.Type {
+ return EncryptionType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v EncryptionValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = NetworkType{}
+
+type NetworkType struct {
+ basetypes.ObjectType
+}
+
+func (t NetworkType) Equal(o attr.Type) bool {
+ other, ok := o.(NetworkType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t NetworkType) String() string {
+ return "NetworkType"
+}
+
+func (t NetworkType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return nil, diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return nil, diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return nil, diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return nil, diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueNull() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewNetworkValueUnknown() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewNetworkValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (NetworkValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing NetworkValue Attribute Value",
+ "While creating a NetworkValue value, a missing attribute value was detected. "+
+ "A NetworkValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid NetworkValue Attribute Type",
+ "While creating a NetworkValue value, an invalid attribute value was detected. "+
+ "A NetworkValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra NetworkValue Attribute Value",
+ "While creating a NetworkValue value, an extra attribute value was detected. "+
+ "A NetworkValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra NetworkValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) NetworkValue {
+ object, diags := NewNetworkValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewNetworkValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t NetworkType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewNetworkValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewNetworkValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewNetworkValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewNetworkValueMust(NetworkValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t NetworkType) ValueType(ctx context.Context) attr.Value {
+ return NetworkValue{}
+}
+
+var _ basetypes.ObjectValuable = NetworkValue{}
+
+type NetworkValue struct {
+ AccessScope basetypes.StringValue `tfsdk:"access_scope"`
+ Acl basetypes.ListValue `tfsdk:"acl"`
+ InstanceAddress basetypes.StringValue `tfsdk:"instance_address"`
+ RouterAddress basetypes.StringValue `tfsdk:"router_address"`
+ state attr.ValueState
+}
+
+func (v NetworkValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["access_scope"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["acl"] = basetypes.ListType{
+ ElemType: types.StringType,
+ }.TerraformType(ctx)
+ attrTypes["instance_address"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["router_address"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.AccessScope.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["access_scope"] = val
+
+ val, err = v.Acl.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["acl"] = val
+
+ val, err = v.InstanceAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["instance_address"] = val
+
+ val, err = v.RouterAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["router_address"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v NetworkValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v NetworkValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v NetworkValue) String() string {
+ return "NetworkValue"
+}
+
+func (v NetworkValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ var aclVal basetypes.ListValue
+ switch {
+ case v.Acl.IsUnknown():
+ aclVal = types.ListUnknown(types.StringType)
+ case v.Acl.IsNull():
+ aclVal = types.ListNull(types.StringType)
+ default:
+ var d diag.Diagnostics
+ aclVal, d = types.ListValue(types.StringType, v.Acl.Elements())
+ diags.Append(d...)
+ }
+
+ if diags.HasError() {
+ return types.ObjectUnknown(map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }), diags
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "access_scope": v.AccessScope,
+ "acl": aclVal,
+ "instance_address": v.InstanceAddress,
+ "router_address": v.RouterAddress,
+ })
+
+ return objVal, diags
+}
+
+func (v NetworkValue) Equal(o attr.Value) bool {
+ other, ok := o.(NetworkValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.AccessScope.Equal(other.AccessScope) {
+ return false
+ }
+
+ if !v.Acl.Equal(other.Acl) {
+ return false
+ }
+
+ if !v.InstanceAddress.Equal(other.InstanceAddress) {
+ return false
+ }
+
+ if !v.RouterAddress.Equal(other.RouterAddress) {
+ return false
+ }
+
+ return true
+}
+
+func (v NetworkValue) Type(ctx context.Context) attr.Type {
+ return NetworkType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v NetworkValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageType{}
+
+type StorageType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageType) String() string {
+ return "StorageType"
+}
+
+func (t StorageType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ performanceClassAttribute, ok := attributes["performance_class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `performance_class is missing from object`)
+
+ return nil, diags
+ }
+
+ performanceClassVal, ok := performanceClassAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`performance_class expected to be basetypes.StringValue, was: %T`, performanceClassAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageValue{
+ PerformanceClass: performanceClassVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueNull() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageValueUnknown() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageValue Attribute Value",
+ "While creating a StorageValue value, a missing attribute value was detected. "+
+ "A StorageValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageValue Attribute Type",
+ "While creating a StorageValue value, an invalid attribute value was detected. "+
+ "A StorageValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageValue Attribute Value",
+ "While creating a StorageValue value, an extra attribute value was detected. "+
+ "A StorageValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ performanceClassAttribute, ok := attributes["performance_class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `performance_class is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ performanceClassVal, ok := performanceClassAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`performance_class expected to be basetypes.StringValue, was: %T`, performanceClassAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ return StorageValue{
+ PerformanceClass: performanceClassVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageValue {
+ object, diags := NewStorageValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageValueMust(StorageValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageType) ValueType(ctx context.Context) attr.Value {
+ return StorageValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageValue{}
+
+type StorageValue struct {
+ PerformanceClass basetypes.StringValue `tfsdk:"performance_class"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ state attr.ValueState
+}
+
+func (v StorageValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 2)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["performance_class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 2)
+
+ val, err = v.PerformanceClass.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["performance_class"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageValue) String() string {
+ return "StorageValue"
+}
+
+func (v StorageValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "performance_class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "performance_class": v.PerformanceClass,
+ "size": v.Size,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.PerformanceClass.Equal(other.PerformanceClass) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageValue) Type(ctx context.Context) attr.Type {
+ return StorageType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "performance_class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instances_data_source_gen.go b/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instances_data_source_gen.go
new file mode 100644
index 00000000..0407c13f
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instances_data_source_gen.go
@@ -0,0 +1,1172 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func InstancesDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "instances": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "is_deletable": schema.BoolAttribute{
+ Computed: true,
+ Description: "Whether the instance can be deleted or not.",
+ MarkdownDescription: "Whether the instance can be deleted or not.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the instance.",
+ MarkdownDescription: "The name of the instance.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ Description: "The current status of the instance.",
+ MarkdownDescription: "The current status of the instance.",
+ },
+ },
+ CustomType: InstancesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: InstancesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of owned instances and their current status.",
+ MarkdownDescription: "List of owned instances and their current status.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the items to be returned on each page.",
+ MarkdownDescription: "Sorting of the items to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "id.desc",
+ "id.asc",
+ "is_deletable.desc",
+ "is_deletable.asc",
+ "name.asc",
+ "name.desc",
+ "status.asc",
+ "status.desc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type InstancesModel struct {
+ Instances types.List `tfsdk:"instances"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = InstancesType{}
+
+type InstancesType struct {
+ basetypes.ObjectType
+}
+
+func (t InstancesType) Equal(o attr.Type) bool {
+ other, ok := o.(InstancesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t InstancesType) String() string {
+ return "InstancesType"
+}
+
+func (t InstancesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ isDeletableAttribute, ok := attributes["is_deletable"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `is_deletable is missing from object`)
+
+ return nil, diags
+ }
+
+ isDeletableVal, ok := isDeletableAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`is_deletable expected to be basetypes.BoolValue, was: %T`, isDeletableAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return nil, diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return nil, diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return InstancesValue{
+ Id: idVal,
+ IsDeletable: isDeletableVal,
+ Name: nameVal,
+ Status: statusVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewInstancesValueNull() InstancesValue {
+ return InstancesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewInstancesValueUnknown() InstancesValue {
+ return InstancesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewInstancesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (InstancesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing InstancesValue Attribute Value",
+ "While creating a InstancesValue value, a missing attribute value was detected. "+
+ "A InstancesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("InstancesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid InstancesValue Attribute Type",
+ "While creating a InstancesValue value, an invalid attribute value was detected. "+
+ "A InstancesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("InstancesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("InstancesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra InstancesValue Attribute Value",
+ "While creating a InstancesValue value, an extra attribute value was detected. "+
+ "A InstancesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra InstancesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewInstancesValueUnknown(), diags
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ isDeletableAttribute, ok := attributes["is_deletable"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `is_deletable is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ isDeletableVal, ok := isDeletableAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`is_deletable expected to be basetypes.BoolValue, was: %T`, isDeletableAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ if diags.HasError() {
+ return NewInstancesValueUnknown(), diags
+ }
+
+ return InstancesValue{
+ Id: idVal,
+ IsDeletable: isDeletableVal,
+ Name: nameVal,
+ Status: statusVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewInstancesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) InstancesValue {
+ object, diags := NewInstancesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewInstancesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t InstancesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewInstancesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewInstancesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewInstancesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewInstancesValueMust(InstancesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t InstancesType) ValueType(ctx context.Context) attr.Value {
+ return InstancesValue{}
+}
+
+var _ basetypes.ObjectValuable = InstancesValue{}
+
+type InstancesValue struct {
+ Id basetypes.StringValue `tfsdk:"id"`
+ IsDeletable basetypes.BoolValue `tfsdk:"is_deletable"`
+ Name basetypes.StringValue `tfsdk:"name"`
+ Status basetypes.StringValue `tfsdk:"status"`
+ state attr.ValueState
+}
+
+func (v InstancesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["is_deletable"] = basetypes.BoolType{}.TerraformType(ctx)
+ attrTypes["name"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["status"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.IsDeletable.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["is_deletable"] = val
+
+ val, err = v.Name.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["name"] = val
+
+ val, err = v.Status.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["status"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v InstancesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v InstancesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v InstancesValue) String() string {
+ return "InstancesValue"
+}
+
+func (v InstancesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "id": basetypes.StringType{},
+ "is_deletable": basetypes.BoolType{},
+ "name": basetypes.StringType{},
+ "status": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "id": v.Id,
+ "is_deletable": v.IsDeletable,
+ "name": v.Name,
+ "status": v.Status,
+ })
+
+ return objVal, diags
+}
+
+func (v InstancesValue) Equal(o attr.Value) bool {
+ other, ok := o.(InstancesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.IsDeletable.Equal(other.IsDeletable) {
+ return false
+ }
+
+ if !v.Name.Equal(other.Name) {
+ return false
+ }
+
+ if !v.Status.Equal(other.Status) {
+ return false
+ }
+
+ return true
+}
+
+func (v InstancesValue) Type(ctx context.Context) attr.Type {
+ return InstancesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v InstancesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "id": basetypes.StringType{},
+ "is_deletable": basetypes.BoolType{},
+ "name": basetypes.StringType{},
+ "status": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/instance/functions.go b/stackit/internal/services/postgresflexalpha/instance/functions.go
new file mode 100644
index 00000000..e9c9c9c2
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/instance/functions.go
@@ -0,0 +1,243 @@
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ postgresflexalphadatasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance/datasources_gen"
+ postgresflexalpharesource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance/resources_gen"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+func mapGetInstanceResponseToModel(
+ ctx context.Context,
+ m *postgresflexalpharesource.InstanceModel,
+ resp *postgresflex.GetInstanceResponse,
+) error {
+ m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
+ m.Encryption = postgresflexalpharesource.NewEncryptionValueNull()
+ if resp.HasEncryption() {
+ m.Encryption = postgresflexalpharesource.NewEncryptionValueMust(
+ m.Encryption.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "kek_key_id": types.StringValue(resp.Encryption.GetKekKeyId()),
+ "kek_key_ring_id": types.StringValue(resp.Encryption.GetKekKeyRingId()),
+ "kek_key_version": types.StringValue(resp.Encryption.GetKekKeyVersion()),
+ "service_account": types.StringValue(resp.Encryption.GetServiceAccount()),
+ },
+ )
+ }
+
+ isConnectionInfoIncomplete := resp.ConnectionInfo == nil || resp.ConnectionInfo.Write == nil ||
+ resp.ConnectionInfo.Write.Host == nil || *resp.ConnectionInfo.Write.Host == "" ||
+ resp.ConnectionInfo.Write.Port == nil || *resp.ConnectionInfo.Write.Port == 0
+
+ if isConnectionInfoIncomplete {
+ m.ConnectionInfo = postgresflexalpharesource.NewConnectionInfoValueNull()
+ } else {
+ m.ConnectionInfo = postgresflexalpharesource.NewConnectionInfoValueMust(
+ postgresflexalpharesource.ConnectionInfoValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "write": postgresflexalpharesource.NewWriteValueMust(
+ postgresflexalpharesource.WriteValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "host": types.StringPointerValue(resp.ConnectionInfo.Write.Host),
+ "port": types.Int64PointerValue(resp.ConnectionInfo.Write.Port),
+ },
+ ),
+ },
+ )
+ }
+
+ m.FlavorId = types.StringValue(resp.GetFlavorId())
+ if m.Id.IsNull() || m.Id.IsUnknown() {
+ m.Id = utils.BuildInternalTerraformId(
+ m.ProjectId.ValueString(),
+ m.Region.ValueString(),
+ m.InstanceId.ValueString(),
+ )
+ }
+ m.InstanceId = types.StringPointerValue(resp.Id)
+
+ m.IsDeletable = types.BoolValue(resp.GetIsDeletable())
+
+ netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
+ if diags.HasError() {
+ return fmt.Errorf("failed converting network acl from response")
+ }
+
+ m.Acl = netAcl
+
+ netInstAdd := types.StringValue("")
+ if instAdd, ok := resp.Network.GetInstanceAddressOk(); ok {
+ netInstAdd = types.StringValue(instAdd)
+ }
+
+ netRtrAdd := types.StringValue("")
+ if rtrAdd, ok := resp.Network.GetRouterAddressOk(); ok {
+ netRtrAdd = types.StringValue(rtrAdd)
+ }
+
+ net, diags := postgresflexalpharesource.NewNetworkValue(
+ postgresflexalpharesource.NetworkValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "access_scope": basetypes.NewStringValue(string(resp.Network.GetAccessScope())),
+ "acl": netAcl,
+ "instance_address": netInstAdd,
+ "router_address": netRtrAdd,
+ },
+ )
+ if diags.HasError() {
+ return fmt.Errorf("failed converting network from response")
+ }
+
+ m.Network = net
+ m.Replicas = types.Int64Value(int64(resp.GetReplicas()))
+ m.RetentionDays = types.Int64Value(resp.GetRetentionDays())
+
+ m.Name = types.StringValue(resp.GetName())
+
+ m.Status = types.StringValue(string(resp.GetStatus()))
+
+ storage, diags := postgresflexalpharesource.NewStorageValue(
+ postgresflexalpharesource.StorageValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "performance_class": types.StringValue(resp.Storage.GetPerformanceClass()),
+ "size": types.Int64Value(resp.Storage.GetSize()),
+ },
+ )
+ if diags.HasError() {
+ return fmt.Errorf("failed converting storage from response")
+ }
+ m.Storage = storage
+
+ m.Version = types.StringValue(resp.GetVersion())
+ return nil
+}
+
+func mapGetDataInstanceResponseToModel(
+ ctx context.Context,
+ m *dataSourceModel,
+ resp *postgresflex.GetInstanceResponse,
+) error {
+ m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
+ handleEncryption(m, resp)
+ handleConnectionInfo(ctx, m, resp)
+
+ m.FlavorId = types.StringValue(resp.GetFlavorId())
+ m.Id = utils.BuildInternalTerraformId(m.ProjectId.ValueString(), m.Region.ValueString(), m.InstanceId.ValueString())
+ m.InstanceId = types.StringPointerValue(resp.Id)
+ m.IsDeletable = types.BoolValue(resp.GetIsDeletable())
+ m.Name = types.StringValue(resp.GetName())
+
+ err := handleNetwork(ctx, m, resp)
+ if err != nil {
+ return err
+ }
+
+ m.Replicas = types.Int64Value(int64(resp.GetReplicas()))
+ m.RetentionDays = types.Int64Value(resp.GetRetentionDays())
+ m.Status = types.StringValue(string(resp.GetStatus()))
+ storage, diags := postgresflexalphadatasource.NewStorageValue(
+ postgresflexalphadatasource.StorageValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "performance_class": types.StringValue(resp.Storage.GetPerformanceClass()),
+ "size": types.Int64Value(resp.Storage.GetSize()),
+ },
+ )
+ if diags.HasError() {
+ return fmt.Errorf("failed converting storage from response")
+ }
+ m.Storage = storage
+ m.Version = types.StringValue(resp.GetVersion())
+ return nil
+}
+
+func handleConnectionInfo(ctx context.Context, m *dataSourceModel, resp *postgresflex.GetInstanceResponse) {
+ isConnectionInfoIncomplete := resp.ConnectionInfo == nil || resp.ConnectionInfo.Write == nil ||
+ resp.ConnectionInfo.Write.Host == nil || *resp.ConnectionInfo.Write.Host == "" ||
+ resp.ConnectionInfo.Write.Port == nil || *resp.ConnectionInfo.Write.Port == 0
+
+ if isConnectionInfoIncomplete {
+ m.ConnectionInfo = postgresflexalphadatasource.NewConnectionInfoValueNull()
+ } else {
+ m.ConnectionInfo = postgresflexalphadatasource.NewConnectionInfoValueMust(
+ postgresflexalphadatasource.ConnectionInfoValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "write": postgresflexalphadatasource.NewWriteValueMust(
+ postgresflexalphadatasource.WriteValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "host": types.StringPointerValue(resp.ConnectionInfo.Write.Host),
+ "port": types.Int64PointerValue(resp.ConnectionInfo.Write.Port),
+ },
+ ),
+ },
+ )
+ }
+}
+
+func handleNetwork(ctx context.Context, m *dataSourceModel, resp *postgresflex.GetInstanceResponse) error {
+ netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
+ if diags.HasError() {
+ return fmt.Errorf("failed converting network acl from response")
+ }
+
+ instAddr := ""
+ if iA, ok := resp.Network.GetInstanceAddressOk(); ok {
+ instAddr = iA
+ }
+
+ rtrAddr := ""
+ if rA, ok := resp.Network.GetRouterAddressOk(); ok {
+ rtrAddr = rA
+ }
+
+ net, diags := postgresflexalphadatasource.NewNetworkValue(
+ postgresflexalphadatasource.NetworkValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "access_scope": types.StringValue(string(resp.Network.GetAccessScope())),
+ "acl": netAcl,
+ "instance_address": types.StringValue(instAddr),
+ "router_address": types.StringValue(rtrAddr),
+ },
+ )
+ if diags.HasError() {
+ return fmt.Errorf("failed converting network from response")
+ }
+ m.Network = net
+ return nil
+}
+
+func handleEncryption(m *dataSourceModel, resp *postgresflex.GetInstanceResponse) {
+ keyId := ""
+ if keyIdVal, ok := resp.Encryption.GetKekKeyIdOk(); ok {
+ keyId = keyIdVal
+ }
+
+ keyRingId := ""
+ if keyRingIdVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok {
+ keyRingId = keyRingIdVal
+ }
+
+ keyVersion := ""
+ if keyVersionVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok {
+ keyVersion = keyVersionVal
+ }
+
+ svcAcc := ""
+ if svcAccVal, ok := resp.Encryption.GetServiceAccountOk(); ok {
+ svcAcc = svcAccVal
+ }
+
+ m.Encryption = postgresflexalphadatasource.EncryptionValue{
+ KekKeyId: types.StringValue(keyId),
+ KekKeyRingId: types.StringValue(keyRingId),
+ KekKeyVersion: types.StringValue(keyVersion),
+ ServiceAccount: types.StringValue(svcAcc),
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/instance/functions_test.go b/stackit/internal/services/postgresflexalpha/instance/functions_test.go
new file mode 100644
index 00000000..ae2e55e3
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/instance/functions_test.go
@@ -0,0 +1,746 @@
+package postgresflexalpha
+
+import (
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+)
+
+//nolint:unused // TODO: remove when used
+type testFlavor struct {
+ Cpu int64
+ Description string
+ Id string
+ MaxGB int64
+ Memory int64
+ MinGB int64
+ NodeType string
+ StorageClasses []testFlavorStorageClass
+}
+
+//nolint:unused // TODO: remove when used
+type testFlavorStorageClass struct {
+ Class string
+ MaxIoPerSec int64
+ MaxThroughInMb int64
+}
+
+//nolint:unused // TODO: remove when used
+var responseList = []testFlavor{
+ {
+ Cpu: 1,
+ Description: "flavor 1.1",
+ Id: "flv1.1",
+ MaxGB: 500,
+ Memory: 1,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.2",
+ Id: "flv1.2",
+ MaxGB: 500,
+ Memory: 2,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.3",
+ Id: "flv1.3",
+ MaxGB: 500,
+ Memory: 3,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.4",
+ Id: "flv1.4",
+ MaxGB: 500,
+ Memory: 4,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.5",
+ Id: "flv1.5",
+ MaxGB: 500,
+ Memory: 5,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.6",
+ Id: "flv1.6",
+ MaxGB: 500,
+ Memory: 6,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.7",
+ Id: "flv1.7",
+ MaxGB: 500,
+ Memory: 7,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.8",
+ Id: "flv1.8",
+ MaxGB: 500,
+ Memory: 8,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.9",
+ Id: "flv1.9",
+ MaxGB: 500,
+ Memory: 9,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ /* ......................................................... */
+ {
+ Cpu: 2,
+ Description: "flavor 2.1",
+ Id: "flv2.1",
+ MaxGB: 500,
+ Memory: 1,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 2,
+ Description: "flavor 2.2",
+ Id: "flv2.2",
+ MaxGB: 500,
+ Memory: 2,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 2,
+ Description: "flavor 2.3",
+ Id: "flv2.3",
+ MaxGB: 500,
+ Memory: 3,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 2,
+ Description: "flavor 2.4",
+ Id: "flv2.4",
+ MaxGB: 500,
+ Memory: 4,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 2,
+ Description: "flavor 2.5",
+ Id: "flv2.5",
+ MaxGB: 500,
+ Memory: 5,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 2,
+ Description: "flavor 2.6",
+ Id: "flv2.6",
+ MaxGB: 500,
+ Memory: 6,
+ MinGB: 5,
+ NodeType: "single",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ /* ......................................................... */
+ {
+ Cpu: 1,
+ Description: "flavor 1.1 replica",
+ Id: "flv1.1r",
+ MaxGB: 500,
+ Memory: 1,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.2 replica",
+ Id: "flv1.2r",
+ MaxGB: 500,
+ Memory: 2,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.3 replica",
+ Id: "flv1.3r",
+ MaxGB: 500,
+ Memory: 3,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.4 replica",
+ Id: "flv1.4r",
+ MaxGB: 500,
+ Memory: 4,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.5 replica",
+ Id: "flv1.5r",
+ MaxGB: 500,
+ Memory: 5,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 1,
+ Description: "flavor 1.6 replica",
+ Id: "flv1.6r",
+ MaxGB: 500,
+ Memory: 6,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ /* ......................................................... */
+ {
+ Cpu: 2,
+ Description: "flavor 2.1 replica",
+ Id: "flv2.1r",
+ MaxGB: 500,
+ Memory: 1,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 2,
+ Description: "flavor 2.2 replica",
+ Id: "flv2.2r",
+ MaxGB: 500,
+ Memory: 2,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 2,
+ Description: "flavor 2.3 replica",
+ Id: "flv2.3r",
+ MaxGB: 500,
+ Memory: 3,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 2,
+ Description: "flavor 2.4 replica",
+ Id: "flv2.4r",
+ MaxGB: 500,
+ Memory: 4,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 2,
+ Description: "flavor 2.5 replica",
+ Id: "flv2.5r",
+ MaxGB: 500,
+ Memory: 5,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ {
+ Cpu: 2,
+ Description: "flavor 2.6 replica",
+ Id: "flv2.6r",
+ MaxGB: 500,
+ Memory: 6,
+ MinGB: 5,
+ NodeType: "Replica",
+ StorageClasses: []testFlavorStorageClass{
+ {Class: "sc1", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc2", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ {Class: "sc3", MaxIoPerSec: 0, MaxThroughInMb: 0},
+ },
+ },
+ /* ......................................................... */
+}
+
+//nolint:unused // TODO: remove when used
+func testFlavorListToResponseFlavorList(f []testFlavor) []postgresflex.ListFlavors {
+ result := make([]postgresflex.ListFlavors, len(f))
+ for i, flavor := range f {
+ result[i] = testFlavorToResponseFlavor(flavor)
+ }
+ return result
+}
+
+//nolint:unused // TODO: remove when used
+func testFlavorToResponseFlavor(f testFlavor) postgresflex.ListFlavors {
+ var scList []postgresflex.FlavorStorageClassesStorageClass
+ for _, fl := range f.StorageClasses {
+ scList = append(
+ scList, postgresflex.FlavorStorageClassesStorageClass{
+ Class: utils.Ptr(fl.Class),
+ MaxIoPerSec: utils.Ptr(fl.MaxIoPerSec),
+ MaxThroughInMb: utils.Ptr(fl.MaxThroughInMb),
+ },
+ )
+ }
+ return postgresflex.ListFlavors{
+ Cpu: utils.Ptr(f.Cpu),
+ Description: utils.Ptr(f.Description),
+ Id: utils.Ptr(f.Id),
+ MaxGB: utils.Ptr(f.MaxGB),
+ Memory: utils.Ptr(f.Memory),
+ MinGB: utils.Ptr(f.MinGB),
+ NodeType: utils.Ptr(f.NodeType),
+ StorageClasses: &scList,
+ }
+}
+
+// func Test_getAllFlavors(t *testing.T) {
+// type args struct {
+// projectId string
+// region string
+// }
+// tests := []struct {
+// name string
+// args args
+// firstItem int
+// lastItem int
+// want []postgresflex.ListFlavors
+// wantErr bool
+// }{
+// {
+// name: "find exactly one flavor",
+// args: args{
+// projectId: "project",
+// region: "region",
+// },
+// firstItem: 0,
+// lastItem: 0,
+// want: []postgresflex.ListFlavors{
+// testFlavorToResponseFlavor(responseList[0]),
+// },
+// wantErr: false,
+// },
+// {
+// name: "get exactly 1 page flavors",
+// args: args{
+// projectId: "project",
+// region: "region",
+// },
+// firstItem: 0,
+// lastItem: 9,
+// want: testFlavorListToResponseFlavorList(responseList[0:10]),
+// wantErr: false,
+// },
+// {
+// name: "get exactly 20 flavors",
+// args: args{
+// projectId: "project",
+// region: "region",
+// },
+// firstItem: 0,
+// lastItem: 20,
+// // 0 indexed therefore we want :21
+// want: testFlavorListToResponseFlavorList(responseList[0:21]),
+// wantErr: false,
+// },
+// {
+// name: "get all flavors",
+// args: args{
+// projectId: "project",
+// region: "region",
+// },
+// firstItem: 0,
+// lastItem: len(responseList),
+// want: testFlavorListToResponseFlavorList(responseList),
+// wantErr: false,
+// },
+// }
+// for _, tt := range tests {
+// t.Run(tt.name, func(t *testing.T) {
+// first := tt.firstItem
+// if first > len(responseList)-1 {
+// first = len(responseList) - 1
+// }
+// last := tt.lastItem
+// if last > len(responseList)-1 {
+// last = len(responseList) - 1
+// }
+// mockClient := postgresFlexClientMocked{
+// returnError: tt.wantErr,
+// firstItem: first,
+// lastItem: last,
+// }
+// got, err := getAllFlavors(context.TODO(), mockClient, tt.args.projectId, tt.args.region)
+// if (err != nil) != tt.wantErr {
+// t.Errorf("getAllFlavors() error = %v, wantErr %v", err, tt.wantErr)
+// return
+// }
+//
+// if diff := cmp.Diff(tt.want, got); diff != "" {
+// t.Errorf("mismatch (-want +got):\n%s", diff)
+// }
+//
+// if !reflect.DeepEqual(got, tt.want) {
+// t.Errorf("getAllFlavors() got = %v, want %v", got, tt.want)
+// }
+// })
+// }
+//}
+
+// func Test_loadFlavorId(t *testing.T) {
+// type args struct {
+// ctx context.Context
+// model *Model
+// storage *storageModel
+// }
+// tests := []struct {
+// name string
+// args args
+// firstItem int
+// lastItem int
+// want []postgresflex.ListFlavors
+// wantErr bool
+// }{
+// {
+// name: "find a single flavor",
+// args: args{
+// ctx: context.Background(),
+// model: &Model{
+// ProjectId: basetypes.NewStringValue("project"),
+// Region: basetypes.NewStringValue("region"),
+// },
+// storage: &storageModel{
+// Class: basetypes.NewStringValue("sc1"),
+// Size: basetypes.NewInt64Value(100),
+// },
+// },
+// firstItem: 0,
+// lastItem: 3,
+// want: []postgresflex.ListFlavors{
+// testFlavorToResponseFlavor(responseList[0]),
+// },
+// wantErr: false,
+// },
+// {
+// name: "find a single flavor by replicas option",
+// args: args{
+// ctx: context.Background(),
+// model: &Model{
+// ProjectId: basetypes.NewStringValue("project"),
+// Region: basetypes.NewStringValue("region"),
+// Replicas: basetypes.NewInt64Value(1),
+// },
+// storage: &storageModel{
+// Class: basetypes.NewStringValue("sc1"),
+// Size: basetypes.NewInt64Value(100),
+// },
+// },
+// firstItem: 0,
+// lastItem: 3,
+// want: []postgresflex.ListFlavors{
+// testFlavorToResponseFlavor(responseList[0]),
+// },
+// wantErr: false,
+// },
+// {
+// name: "fail finding find a single flavor by replicas option",
+// args: args{
+// ctx: context.Background(),
+// model: &Model{
+// ProjectId: basetypes.NewStringValue("project"),
+// Region: basetypes.NewStringValue("region"),
+// Replicas: basetypes.NewInt64Value(1),
+// },
+// storage: &storageModel{
+// Class: basetypes.NewStringValue("sc1"),
+// Size: basetypes.NewInt64Value(100),
+// },
+// },
+// firstItem: 13,
+// lastItem: 23,
+// want: []postgresflex.ListFlavors{},
+// wantErr: true,
+// },
+// {
+// name: "find a replicas flavor lower case",
+// args: args{
+// ctx: context.Background(),
+// model: &Model{
+// ProjectId: basetypes.NewStringValue("project"),
+// Region: basetypes.NewStringValue("region"),
+// },
+// storage: &storageModel{
+// Class: basetypes.NewStringValue("sc1"),
+// Size: basetypes.NewInt64Value(100),
+// },
+// },
+// firstItem: 0,
+// lastItem: len(responseList) - 1,
+// want: []postgresflex.ListFlavors{
+// testFlavorToResponseFlavor(responseList[16]),
+// },
+// wantErr: false,
+// },
+// {
+// name: "find a replicas flavor CamelCase",
+// args: args{
+// ctx: context.Background(),
+// model: &Model{
+// ProjectId: basetypes.NewStringValue("project"),
+// Region: basetypes.NewStringValue("region"),
+// },
+// storage: &storageModel{
+// Class: basetypes.NewStringValue("sc1"),
+// Size: basetypes.NewInt64Value(100),
+// },
+// },
+// firstItem: 0,
+// lastItem: len(responseList) - 1,
+// want: []postgresflex.ListFlavors{
+// testFlavorToResponseFlavor(responseList[16]),
+// },
+// wantErr: false,
+// },
+// {
+// name: "find a replicas flavor by replicas option",
+// args: args{
+// ctx: context.Background(),
+// model: &Model{
+// ProjectId: basetypes.NewStringValue("project"),
+// Region: basetypes.NewStringValue("region"),
+// Replicas: basetypes.NewInt64Value(3),
+// },
+// flavor: &flavorModel{
+// CPU: basetypes.NewInt64Value(1),
+// RAM: basetypes.NewInt64Value(1),
+// },
+// storage: &storageModel{
+// Class: basetypes.NewStringValue("sc1"),
+// Size: basetypes.NewInt64Value(100),
+// },
+// },
+// firstItem: 0,
+// lastItem: len(responseList) - 1,
+// want: []postgresflex.ListFlavors{
+// testFlavorToResponseFlavor(responseList[16]),
+// },
+// wantErr: false,
+// },
+// {
+// name: "fail finding a replica flavor",
+// args: args{
+// ctx: context.Background(),
+// model: &Model{
+// ProjectId: basetypes.NewStringValue("project"),
+// Region: basetypes.NewStringValue("region"),
+// Replicas: basetypes.NewInt64Value(3),
+// },
+// flavor: &flavorModel{
+// CPU: basetypes.NewInt64Value(1),
+// RAM: basetypes.NewInt64Value(1),
+// },
+// storage: &storageModel{
+// Class: basetypes.NewStringValue("sc1"),
+// Size: basetypes.NewInt64Value(100),
+// },
+// },
+// firstItem: 0,
+// lastItem: 10,
+// want: []postgresflex.ListFlavors{},
+// wantErr: true,
+// },
+// {
+// name: "no flavor found error",
+// args: args{
+// ctx: context.Background(),
+// model: &Model{
+// ProjectId: basetypes.NewStringValue("project"),
+// Region: basetypes.NewStringValue("region"),
+// },
+// flavor: &flavorModel{
+// CPU: basetypes.NewInt64Value(10),
+// RAM: basetypes.NewInt64Value(1000),
+// NodeType: basetypes.NewStringValue("Single"),
+// },
+// storage: &storageModel{
+// Class: basetypes.NewStringValue("sc1"),
+// Size: basetypes.NewInt64Value(100),
+// },
+// },
+// firstItem: 0,
+// lastItem: 3,
+// want: []postgresflex.ListFlavors{},
+// wantErr: true,
+// },
+// }
+// for _, tt := range tests {
+// t.Run(tt.name, func(t *testing.T) {
+// first := tt.firstItem
+// if first > len(responseList)-1 {
+// first = len(responseList) - 1
+// }
+// last := tt.lastItem
+// if last > len(responseList)-1 {
+// last = len(responseList) - 1
+// }
+// mockClient := postgresFlexClientMocked{
+// returnError: tt.wantErr,
+// firstItem: first,
+// lastItem: last,
+// }
+// if err := loadFlavorId(tt.args.ctx, mockClient, tt.args.model, tt.args.flavor, tt.args.storage); (err != nil) != tt.wantErr {
+// t.Errorf("loadFlavorId() error = %v, wantErr %v", err, tt.wantErr)
+// }
+// })
+// }
+//}
diff --git a/stackit/internal/services/postgresflexalpha/instance/planModifiers.yaml b/stackit/internal/services/postgresflexalpha/instance/planModifiers.yaml
new file mode 100644
index 00000000..71c2f17b
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/instance/planModifiers.yaml
@@ -0,0 +1,120 @@
+fields:
+ - name: 'backup_schedule'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'connection_info.host'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'connection_info.port'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'encryption.kek_key_id'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'encryption.kek_key_ring_id'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'encryption.kek_key_version'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'encryption.service_account'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'flavor_id'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'id'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'instance_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'is_deletable'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'name'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'network.access_scope'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'network.acl'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'network.instance_address'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'network.router_address'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'project_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'region'
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'replicas'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'retention_days'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'status'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'storage'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'storage.performance_class'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'storage.size'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'version'
+ modifiers:
+ - 'UseStateForUnknown'
diff --git a/stackit/internal/services/postgresflexalpha/instance/resource.go b/stackit/internal/services/postgresflexalpha/instance/resource.go
index 2c5d6e08..d4049fb5 100644
--- a/stackit/internal/services/postgresflexalpha/instance/resource.go
+++ b/stackit/internal/services/postgresflexalpha/instance/resource.go
@@ -1,126 +1,89 @@
-package postgresflex
+package postgresflexalpha
import (
"context"
+ _ "embed"
"fmt"
+ "math"
"net/http"
- "regexp"
"strings"
- "time"
-
- "github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha"
- "github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha/wait"
- postgresflexUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflexalpha/utils"
-
- "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
- "github.com/hashicorp/terraform-plugin-framework/attr"
- "github.com/hashicorp/terraform-plugin-framework/diag"
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
- "github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
"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/planmodifier"
- "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
+ "github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ postgresflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance/resources_gen"
+ postgresflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/utils"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+ wait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/postgresflexalpha"
)
// Ensure the implementation satisfies the expected interfaces.
var (
- _ resource.Resource = &instanceResource{}
- _ resource.ResourceWithConfigure = &instanceResource{}
- _ resource.ResourceWithImportState = &instanceResource{}
- _ resource.ResourceWithModifyPlan = &instanceResource{}
+ _ resource.Resource = &instanceResource{}
+ _ resource.ResourceWithConfigure = &instanceResource{}
+ _ resource.ResourceWithImportState = &instanceResource{}
+ _ resource.ResourceWithModifyPlan = &instanceResource{}
+ _ resource.ResourceWithValidateConfig = &instanceResource{}
+ _ resource.ResourceWithIdentity = &instanceResource{}
)
-type Model struct {
- Id types.String `tfsdk:"id"` // needed by TF
- InstanceId types.String `tfsdk:"instance_id"`
- ProjectId types.String `tfsdk:"project_id"`
- Name types.String `tfsdk:"name"`
- ACL types.List `tfsdk:"acl"`
- BackupSchedule types.String `tfsdk:"backup_schedule"`
- Flavor types.Object `tfsdk:"flavor"`
- Replicas types.Int64 `tfsdk:"replicas"`
- Storage types.Object `tfsdk:"storage"`
- Version types.String `tfsdk:"version"`
- Region types.String `tfsdk:"region"`
- Encryption types.Object `tfsdk:"encryption"`
- Network types.Object `tfsdk:"network"`
-}
-
-type encryptionModel struct {
- KeyRingId types.String `tfsdk:"keyring_id"`
- KeyId types.String `tfsdk:"key_id"`
- KeyVersion types.String `tfsdk:"key_version"`
- ServiceAccount types.String `tfsdk:"service_account"`
-}
-
-var encryptionTypes = map[string]attr.Type{
- "keyring_id": basetypes.StringType{},
- "key_id": basetypes.StringType{},
- "key_version": basetypes.StringType{},
- "service_account": basetypes.StringType{},
-}
-
-type networkModel struct {
- AccessScope types.String `tfsdk:"access_scope"`
-}
-
-var networkTypes = map[string]attr.Type{
- "access_scope": basetypes.StringType{},
-}
-
-// Struct corresponding to Model.Flavor
-type flavorModel struct {
- Id types.String `tfsdk:"id"`
- Description types.String `tfsdk:"description"`
- CPU types.Int64 `tfsdk:"cpu"`
- RAM types.Int64 `tfsdk:"ram"`
-}
-
-// Types corresponding to flavorModel
-var flavorTypes = map[string]attr.Type{
- "id": basetypes.StringType{},
- "description": basetypes.StringType{},
- "cpu": basetypes.Int64Type{},
- "ram": basetypes.Int64Type{},
-}
-
-// Struct corresponding to Model.Storage
-type storageModel struct {
- Class types.String `tfsdk:"class"`
- Size types.Int64 `tfsdk:"size"`
-}
-
-// Types corresponding to storageModel
-var storageTypes = map[string]attr.Type{
- "class": basetypes.StringType{},
- "size": basetypes.Int64Type{},
-}
-
// NewInstanceResource is a helper function to simplify the provider implementation.
func NewInstanceResource() resource.Resource {
return &instanceResource{}
}
+// resourceModel describes the resource data model.
+type resourceModel = postgresflexalpha.InstanceModel
+
+type InstanceResourceIdentityModel struct {
+ ProjectID types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ InstanceID types.String `tfsdk:"instance_id"`
+}
+
// instanceResource is the resource implementation.
type instanceResource struct {
- client *postgresflexalpha.APIClient
+ client *postgresflex.APIClient
providerData core.ProviderData
}
+func (r *instanceResource) ValidateConfig(
+ ctx context.Context,
+ req resource.ValidateConfigRequest,
+ resp *resource.ValidateConfigResponse,
+) {
+ var data resourceModel
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ if data.Replicas.IsNull() || data.Replicas.IsUnknown() {
+ resp.Diagnostics.AddAttributeWarning(
+ path.Root("replicas"),
+ "Missing Attribute Configuration",
+ "Expected replicas to be configured. "+
+ "The resource may return unexpected results.",
+ )
+ }
+}
+
// ModifyPlan implements resource.ResourceWithModifyPlan.
// Use the modifier to set the effective region in the current plan.
-func (r *instanceResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { // nolint:gocritic // function signature required by Terraform
- var configModel Model
+func (r *instanceResource) ModifyPlan(
+ ctx context.Context,
+ req resource.ModifyPlanRequest,
+ resp *resource.ModifyPlanResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var configModel resourceModel
// skip initial empty configuration to avoid follow-up errors
if req.Config.Raw.IsNull() {
return
@@ -130,7 +93,7 @@ func (r *instanceResource) ModifyPlan(ctx context.Context, req resource.ModifyPl
return
}
- var planModel Model
+ var planModel resourceModel
resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...)
if resp.Diagnostics.HasError() {
return
@@ -153,7 +116,11 @@ func (r *instanceResource) Metadata(_ context.Context, req resource.MetadataRequ
}
// Configure adds the provider configured client to the resource.
-func (r *instanceResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
+func (r *instanceResource) Configure(
+ ctx context.Context,
+ req resource.ConfigureRequest,
+ resp *resource.ConfigureResponse,
+) {
var ok bool
r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
if !ok {
@@ -168,206 +135,58 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
tflog.Info(ctx, "Postgres Flex instance client configured")
}
+/*
+ until tfplugingen framework can handle plan modifiers, we use a function to add them
+*/
+
+//go:embed planModifiers.yaml
+var modifiersFileByte []byte
+
// Schema defines the schema for the resource.
-func (r *instanceResource) Schema(_ context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
- descriptions := map[string]string{
- "main": "Postgres Flex instance resource schema. Must have a `region` specified in the provider configuration.",
- "id": "Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`\".",
- "instance_id": "ID of the PostgresFlex instance.",
- "project_id": "STACKIT project ID to which the instance is associated.",
- "name": "Instance name.",
- "acl": "The Access Control List (ACL) for the PostgresFlex instance.",
- "region": "The resource region. If not defined, the provider region is used.",
- "encryption": "The encryption block.",
- "key_id": "Key ID of the encryption key.",
+func (r *instanceResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
+ schema := postgresflexalpha.InstanceResourceSchema(ctx)
+ fields, err := utils.ReadModifiersConfig(modifiersFileByte)
+ if err != nil {
+ resp.Diagnostics.AddError("error during read modifiers config file", err.Error())
+ return
}
- resp.Schema = schema.Schema{
- Description: descriptions["main"],
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Description: descriptions["id"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
+ err = utils.AddPlanModifiersToResourceSchema(fields, &schema)
+ if err != nil {
+ resp.Diagnostics.AddError("error adding plan modifiers", err.Error())
+ return
+ }
+ resp.Schema = schema
+}
+
+func (r *instanceResource) IdentitySchema(
+ _ context.Context,
+ _ resource.IdentitySchemaRequest,
+ resp *resource.IdentitySchemaResponse,
+) {
+ resp.IdentitySchema = identityschema.Schema{
+ Attributes: map[string]identityschema.Attribute{
+ "project_id": identityschema.StringAttribute{
+ RequiredForImport: true, // must be set during import by the practitioner
},
- "instance_id": schema.StringAttribute{
- Description: descriptions["instance_id"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
+ "region": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
},
- "project_id": schema.StringAttribute{
- Description: descriptions["project_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "name": schema.StringAttribute{
- Description: descriptions["name"],
- Required: true,
- Validators: []validator.String{
- stringvalidator.LengthAtLeast(1),
- stringvalidator.RegexMatches(
- regexp.MustCompile("^[a-z]([-a-z0-9]*[a-z0-9])?$"),
- "must start with a letter, must have lower case letters, numbers or hyphens, and no hyphen at the end",
- ),
- },
- },
- "acl": schema.ListAttribute{
- Description: descriptions["acl"],
- ElementType: types.StringType,
- Required: true,
- },
- "backup_schedule": schema.StringAttribute{
- Required: true,
- },
- "flavor": schema.SingleNestedAttribute{
- Required: true,
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Computed: true,
- PlanModifiers: []planmodifier.String{
- UseStateForUnknownIfFlavorUnchanged(req),
- },
- },
- "description": schema.StringAttribute{
- Computed: true,
- PlanModifiers: []planmodifier.String{
- UseStateForUnknownIfFlavorUnchanged(req),
- },
- },
- "cpu": schema.Int64Attribute{
- Required: true,
- },
- "ram": schema.Int64Attribute{
- Required: true,
- },
- },
- },
- "replicas": schema.Int64Attribute{
- Required: true,
- },
- "storage": schema.SingleNestedAttribute{
- Required: true,
- Attributes: map[string]schema.Attribute{
- "class": schema.StringAttribute{
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- },
- "size": schema.Int64Attribute{
- Required: true,
- },
- },
- },
- "version": schema.StringAttribute{
- Required: true,
- },
- "region": schema.StringAttribute{
- Optional: true,
- // must be computed to allow for storing the override value from the provider
- Computed: true,
- Description: descriptions["region"],
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- },
- "encryption": schema.SingleNestedAttribute{
- Required: true,
- Attributes: map[string]schema.Attribute{
- "key_id": schema.StringAttribute{
- Description: descriptions["key_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- "key_version": schema.StringAttribute{
- Description: descriptions["key_version"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- "key_ring_id": schema.StringAttribute{
- Description: descriptions["key_ring_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- "service_account": schema.StringAttribute{
- Description: descriptions["service_account"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- },
- //Blocks: nil,
- //CustomType: nil,
- Description: descriptions["encryption"],
- //MarkdownDescription: "",
- //DeprecationMessage: "",
- //Validators: nil,
- PlanModifiers: []planmodifier.Object{},
- },
- "network": schema.SingleNestedAttribute{
- Required: true,
- Attributes: map[string]schema.Attribute{
- "access_scope": schema.StringAttribute{
- Description: descriptions["access_scope"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- },
- //Blocks: nil,
- //CustomType: nil,
- Description: descriptions["network"],
- //MarkdownDescription: "",
- //DeprecationMessage: "",
- //Validators: nil,
- PlanModifiers: []planmodifier.Object{},
+ "instance_id": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
},
},
}
}
// Create creates the resource and sets the initial Terraform state.
-func (r *instanceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
- // Retrieve values from plan
- var model Model
+func (r *instanceResource) Create(
+ ctx context.Context,
+ req resource.CreateRequest,
+ resp *resource.CreateResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
+
diags := req.Plan.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -381,83 +200,72 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "region", region)
- var acl []string
- if !(model.ACL.IsNull() || model.ACL.IsUnknown()) {
- diags = model.ACL.ElementsAs(ctx, &acl, false)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
- var flavor = &flavorModel{}
- if !(model.Flavor.IsNull() || model.Flavor.IsUnknown()) {
- diags = model.Flavor.As(ctx, flavor, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- err := loadFlavorId(ctx, r.client, &model, flavor)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Loading flavor ID: %v", err))
- return
- }
- }
- var storage = &storageModel{}
- if !(model.Storage.IsNull() || model.Storage.IsUnknown()) {
- diags = model.Storage.As(ctx, storage, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var encryption = &encryptionModel{}
- if !(model.Encryption.IsNull() || model.Encryption.IsUnknown()) {
- diags = model.Encryption.As(ctx, encryption, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var network = &networkModel{}
- if !(model.Network.IsNull() || model.Network.IsUnknown()) {
- diags = model.Network.As(ctx, network, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- // Generate API request body from model
- payload, err := toCreatePayload(&model, acl, flavor, storage, encryption, network)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Creating API payload: %v", err))
+ var netAcl []string
+ diag := model.Network.Acl.ElementsAs(ctx, &netAcl, false)
+ resp.Diagnostics.Append(diags...)
+ if diag.HasError() {
return
}
+
+ if model.Replicas.ValueInt64() > math.MaxInt32 {
+ resp.Diagnostics.AddError("invalid int32 value", "provided int64 value does not fit into int32")
+ return
+ }
+ replVal := int32(model.Replicas.ValueInt64()) // nolint:gosec // check is performed above
+ payload := modelToCreateInstancePayload(netAcl, model, replVal)
+
// Create new instance
- createResp, err := r.client.CreateInstanceRequest(ctx, projectId, region).CreateInstanceRequestPayload(*payload).Execute()
+ createResp, err := r.client.CreateInstanceRequest(
+ ctx,
+ projectId,
+ region,
+ ).CreateInstanceRequestPayload(payload).Execute()
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Calling API: %v", err))
+ core.LogAndAddError(ctx, &resp.Diagnostics, "error creating instance", fmt.Sprintf("Calling API: %v", err))
return
}
ctx = core.LogResponse(ctx)
-
- instanceId := *createResp.Id
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
- waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).WaitWithContext(ctx)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Instance creation waiting: %v", err))
+ instanceId, ok := createResp.GetIdOk()
+ if !ok {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "error creating instance", "could not find instance id in response")
return
}
- // Map response body to schema
- err = mapFields(ctx, waitResp, &model, flavor, storage, region)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Processing API payload: %v", err))
+ // Set data returned by API in identity
+ identity := InstanceResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
return
}
+
+ waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).
+ WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating instance",
+ fmt.Sprintf("Wait handler error: %v", err),
+ )
+ return
+ }
+
+ err = mapGetInstanceResponseToModel(ctx, &model, waitResp)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating instance",
+ fmt.Sprintf("Error creating model: %v", err),
+ )
+ return
+ }
+
// Set state to fully populated data
diags = resp.State.Set(ctx, model)
resp.Diagnostics.Append(diags...)
@@ -467,9 +275,51 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
tflog.Info(ctx, "Postgres Flex instance created")
}
+func modelToCreateInstancePayload(
+ netAcl []string,
+ model postgresflexalpha.InstanceModel,
+ replVal int32,
+) postgresflex.CreateInstanceRequestPayload {
+ var enc *postgresflex.InstanceEncryption
+ if !model.Encryption.IsNull() && !model.Encryption.IsUnknown() {
+ enc = &postgresflex.InstanceEncryption{
+ KekKeyId: model.Encryption.KekKeyId.ValueStringPointer(),
+ KekKeyRingId: model.Encryption.KekKeyRingId.ValueStringPointer(),
+ KekKeyVersion: model.Encryption.KekKeyVersion.ValueStringPointer(),
+ ServiceAccount: model.Encryption.ServiceAccount.ValueStringPointer(),
+ }
+ }
+ payload := postgresflex.CreateInstanceRequestPayload{
+ BackupSchedule: model.BackupSchedule.ValueStringPointer(),
+ Encryption: enc,
+ FlavorId: model.FlavorId.ValueStringPointer(),
+ Name: model.Name.ValueStringPointer(),
+ Network: &postgresflex.InstanceNetworkCreate{
+ AccessScope: postgresflex.InstanceNetworkGetAccessScopeAttributeType(
+ model.Network.AccessScope.ValueStringPointer(),
+ ),
+ Acl: &netAcl,
+ },
+ Replicas: postgresflex.CreateInstanceRequestPayloadGetReplicasAttributeType(&replVal),
+ RetentionDays: model.RetentionDays.ValueInt64Pointer(),
+ Storage: &postgresflex.StorageCreate{
+ PerformanceClass: model.Storage.PerformanceClass.ValueStringPointer(),
+ Size: model.Storage.Size.ValueInt64Pointer(),
+ },
+ Version: model.Version.ValueStringPointer(),
+ }
+ return payload
+}
+
// Read refreshes the Terraform state with the latest data.
-func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
- var model Model
+func (r *instanceResource) Read(
+ ctx context.Context,
+ req resource.ReadRequest,
+ resp *resource.ReadResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ functionErrorSummary := "read instance failed"
+
+ var model resourceModel
diags := req.State.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -478,30 +328,25 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
ctx = core.InitProviderContext(ctx)
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- region := r.providerData.GetRegionWithOverride(model.Region)
+ var projectId string
+ if !model.ProjectId.IsNull() && !model.ProjectId.IsUnknown() {
+ projectId = model.ProjectId.ValueString()
+ }
+
+ var region string
+ if !model.Region.IsNull() && !model.Region.IsUnknown() {
+ region = r.providerData.GetRegionWithOverride(model.Region)
+ }
+
+ var instanceId string
+ if !model.InstanceId.IsNull() && !model.InstanceId.IsUnknown() {
+ instanceId = model.InstanceId.ValueString()
+ }
+
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "instance_id", instanceId)
ctx = tflog.SetField(ctx, "region", region)
- var flavor = &flavorModel{}
- if !(model.Flavor.IsNull() || model.Flavor.IsUnknown()) {
- diags = model.Flavor.As(ctx, flavor, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
- var storage = &storageModel{}
- if !(model.Storage.IsNull() || model.Storage.IsUnknown()) {
- diags = model.Storage.As(ctx, storage, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
instanceResp, err := r.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
if err != nil {
oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
@@ -509,36 +354,68 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
resp.State.RemoveResource(ctx)
return
}
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", err.Error())
+ core.LogAndAddError(ctx, &resp.Diagnostics, functionErrorSummary, err.Error())
return
}
ctx = core.LogResponse(ctx)
- if instanceResp != nil && instanceResp.Status != nil && *instanceResp.Status == wait.InstanceStateDeleted {
- resp.State.RemoveResource(ctx)
+ respInstanceID, ok := instanceResp.GetIdOk()
+ if !ok {
+ core.LogAndAddError(ctx, &resp.Diagnostics, functionErrorSummary, "response provided no ID")
+ return
+ }
+ if !model.InstanceId.IsUnknown() && !model.InstanceId.IsNull() {
+ if respInstanceID != instanceId {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ functionErrorSummary,
+ "ID in response did not match ID in state",
+ )
+ return
+ }
+ }
+
+ err = mapGetInstanceResponseToModel(ctx, &model, instanceResp)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ functionErrorSummary,
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
return
}
- // Map response body to schema
- err = mapFields(ctx, instanceResp, &model, flavor, storage, region)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API payload: %v", err))
- return
- }
// Set refreshed state
- diags = resp.State.Set(ctx, model)
- resp.Diagnostics.Append(diags...)
+ resp.Diagnostics.Append(resp.State.Set(ctx, model)...)
if resp.Diagnostics.HasError() {
return
}
+
+ // Set data returned by API in identity
+ identity := InstanceResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
tflog.Info(ctx, "Postgres Flex instance read")
}
// Update updates the resource and sets the updated Terraform state on success.
-func (r *instanceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
- // Retrieve values from plan
- var model Model
+func (r *instanceResource) Update(
+ ctx context.Context,
+ req resource.UpdateRequest,
+ resp *resource.UpdateResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
+
diags := req.Plan.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -547,51 +424,55 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
ctx = core.InitProviderContext(ctx)
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
+ // Read identity data
+ var identityData InstanceResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ projectId := identityData.ProjectID.ValueString()
+ instanceId := identityData.InstanceID.ValueString()
region := model.Region.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "instance_id", instanceId)
ctx = tflog.SetField(ctx, "region", region)
- var acl []string
- if !(model.ACL.IsNull() || model.ACL.IsUnknown()) {
- diags = model.ACL.ElementsAs(ctx, &acl, false)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
- var flavor = &flavorModel{}
- if !(model.Flavor.IsNull() || model.Flavor.IsUnknown()) {
- diags = model.Flavor.As(ctx, flavor, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- err := loadFlavorId(ctx, r.client, &model, flavor)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Loading flavor ID: %v", err))
- return
- }
- }
- var storage = &storageModel{}
- if !(model.Storage.IsNull() || model.Storage.IsUnknown()) {
- diags = model.Storage.As(ctx, storage, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- // Generate API request body from model
- payload, err := toUpdatePayload(&model, acl, flavor, storage)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Creating API payload: %v", err))
+ var netAcl []string
+ diag := model.Network.Acl.ElementsAs(ctx, &netAcl, false)
+ resp.Diagnostics.Append(diags...)
+ if diag.HasError() {
return
}
+
+ if model.Replicas.ValueInt64() > math.MaxInt32 {
+ resp.Diagnostics.AddError("invalid int32 value", "provided int64 value does not fit into int32")
+ return
+ }
+ replInt32 := int32(model.Replicas.ValueInt64()) // nolint:gosec // check is performed above
+
+ payload := postgresflex.UpdateInstanceRequestPayload{
+ BackupSchedule: model.BackupSchedule.ValueStringPointer(),
+ FlavorId: model.FlavorId.ValueStringPointer(),
+ Name: model.Name.ValueStringPointer(),
+ Network: &postgresflex.InstanceNetworkUpdate{
+ Acl: &netAcl,
+ },
+ Replicas: postgresflex.UpdateInstanceRequestPayloadGetReplicasAttributeType(&replInt32),
+ RetentionDays: model.RetentionDays.ValueInt64Pointer(),
+ Storage: &postgresflex.StorageUpdate{
+ Size: model.Storage.Size.ValueInt64Pointer(),
+ },
+ Version: model.Version.ValueStringPointer(),
+ }
+
// Update existing instance
- err = r.client.UpdateInstancePartiallyRequest(ctx, projectId, region, instanceId).UpdateInstancePartiallyRequestPayload(*payload).Execute()
+ err := r.client.UpdateInstanceRequest(
+ ctx,
+ projectId,
+ region,
+ instanceId,
+ ).UpdateInstanceRequestPayload(payload).Execute()
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", err.Error())
return
@@ -599,18 +480,34 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
ctx = core.LogResponse(ctx)
- waitResp, err := wait.PartialUpdateInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).WaitWithContext(ctx)
+ waitResp, err := wait.PartialUpdateInstanceWaitHandler(
+ ctx,
+ r.client,
+ projectId,
+ region,
+ instanceId,
+ ).WaitWithContext(ctx)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error updating instance",
+ fmt.Sprintf("Instance update waiting: %v", err),
+ )
return
}
- // Map response body to schema
- err = mapFields(ctx, waitResp, &model, flavor, storage, region)
+ err = mapGetInstanceResponseToModel(ctx, &model, waitResp)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Processing API payload: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error updating instance",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
return
}
+
diags = resp.State.Set(ctx, model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -620,9 +517,13 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
}
// Delete deletes the resource and removes the Terraform state on success.
-func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
- // Retrieve values from state
- var model Model
+func (r *instanceResource) Delete(
+ ctx context.Context,
+ req resource.DeleteRequest,
+ resp *resource.DeleteResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
+
diags := req.State.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -647,247 +548,63 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
ctx = core.LogResponse(ctx)
- _, err = wait.DeleteInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).SetTimeout(45 * time.Minute).WaitWithContext(ctx)
+ _, err = r.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Instance deletion waiting: %v", err))
- return
+ oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
+ if ok && oapiErr.StatusCode != http.StatusNotFound {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", err.Error())
+ return
+ }
}
+
+ resp.State.RemoveResource(ctx)
tflog.Info(ctx, "Postgres Flex instance deleted")
}
// ImportState imports a resource into the Terraform state on success.
-// The expected format of the resource import identifier is: project_id,instance_id
-func (r *instanceResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
- idParts := strings.Split(req.ID, core.Separator)
+// The expected format of the resource import identifier is: project_id,region,instance_id
+func (r *instanceResource) ImportState(
+ ctx context.Context,
+ req resource.ImportStateRequest,
+ resp *resource.ImportStateResponse,
+) {
+ ctx = core.InitProviderContext(ctx)
- if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
- core.LogAndAddError(ctx, &resp.Diagnostics,
- "Error importing instance",
- fmt.Sprintf("Expected import identifier with format: [project_id],[region],[instance_id] Got: %q", req.ID),
- )
+ if req.ID != "" {
+ idParts := strings.Split(req.ID, core.Separator)
+
+ if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
+ core.LogAndAddError(
+ ctx, &resp.Diagnostics,
+ "Error importing instance",
+ fmt.Sprintf(
+ "Expected import identifier with format [project_id],[region],[instance_id] Got: %q",
+ req.ID,
+ ),
+ )
+ return
+ }
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
return
}
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
+ // If no ID is provided, attempt to read identity attributes from the import configuration
+ var identityData InstanceResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ instanceId := identityData.InstanceID.ValueString()
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), projectId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), region)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), instanceId)...)
+
tflog.Info(ctx, "Postgres Flex instance state imported")
}
-
-func mapFields(ctx context.Context, resp *postgresflexalpha.GetInstanceResponse, model *Model, flavor *flavorModel, storage *storageModel, region string) error {
- if resp == nil {
- return fmt.Errorf("response input is nil")
- }
- if model == nil {
- return fmt.Errorf("model input is nil")
- }
- instance := resp
-
- var instanceId string
- if model.InstanceId.ValueString() != "" {
- instanceId = model.InstanceId.ValueString()
- } else if instance.Id != nil {
- instanceId = *instance.Id
- } else {
- return fmt.Errorf("instance id not present")
- }
-
- var aclList basetypes.ListValue
- var diags diag.Diagnostics
- if instance.Acl == nil {
- aclList = types.ListNull(types.StringType)
- } else {
- respACL := *instance.Acl
- modelACL, err := utils.ListValuetoStringSlice(model.ACL)
- if err != nil {
- return err
- }
-
- reconciledACL := utils.ReconcileStringSlices(modelACL, respACL)
-
- aclList, diags = types.ListValueFrom(ctx, types.StringType, reconciledACL)
- if diags.HasError() {
- return fmt.Errorf("mapping ACL: %w", core.DiagsToError(diags))
- }
- }
-
- var flavorValues map[string]attr.Value
- if instance.FlavorId == nil {
- flavorValues = map[string]attr.Value{
- "id": flavor.Id,
- "description": flavor.Description,
- "cpu": flavor.CPU,
- "ram": flavor.RAM,
- }
- } else {
- // TODO
- //flavorValues = map[string]attr.Value{
- // "id": types.StringValue(*instance.FlavorId),
- // "description": types.StringValue(*instance.Flavor.Description),
- // "cpu": types.Int64PointerValue(instance.Flavor.Cpu),
- // "ram": types.Int64PointerValue(instance.Flavor.Memory),
- //}
- }
- flavorObject, diags := types.ObjectValue(flavorTypes, flavorValues)
- if diags.HasError() {
- return fmt.Errorf("creating flavor: %w", core.DiagsToError(diags))
- }
-
- var storageValues map[string]attr.Value
- if instance.Storage == nil {
- storageValues = map[string]attr.Value{
- "class": storage.Class,
- "size": storage.Size,
- }
- } else {
- storageValues = map[string]attr.Value{
- "class": types.StringValue(*instance.Storage.PerformanceClass),
- "size": types.Int64PointerValue(instance.Storage.Size),
- }
- }
- storageObject, diags := types.ObjectValue(storageTypes, storageValues)
- if diags.HasError() {
- return fmt.Errorf("creating storage: %w", core.DiagsToError(diags))
- }
-
- model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), region, instanceId)
- model.InstanceId = types.StringValue(instanceId)
- model.Name = types.StringPointerValue(instance.Name)
- model.ACL = aclList
- model.BackupSchedule = types.StringPointerValue(instance.BackupSchedule)
- model.Flavor = flavorObject
- // TODO - verify working
- model.Replicas = types.Int64Value(int64(*instance.Replicas))
- model.Storage = storageObject
- model.Version = types.StringPointerValue(instance.Version)
- model.Region = types.StringValue(region)
- //model.Encryption = types.ObjectValue()
- //model.Network = networkModel
- return nil
-}
-
-func toCreatePayload(model *Model, acl []string, flavor *flavorModel, storage *storageModel, enc *encryptionModel, net *networkModel) (*postgresflexalpha.CreateInstanceRequestPayload, error) {
- if model == nil {
- return nil, fmt.Errorf("nil model")
- }
- if acl == nil {
- return nil, fmt.Errorf("nil acl")
- }
- if flavor == nil {
- return nil, fmt.Errorf("nil flavor")
- }
- if storage == nil {
- return nil, fmt.Errorf("nil storage")
- }
-
- replVal := int32(model.Replicas.ValueInt64())
- return &postgresflexalpha.CreateInstanceRequestPayload{
- // TODO - verify working
- Acl: &[]string{
- strings.Join(acl, ","),
- },
- BackupSchedule: conversion.StringValueToPointer(model.BackupSchedule),
- FlavorId: conversion.StringValueToPointer(flavor.Id),
- Name: conversion.StringValueToPointer(model.Name),
- // TODO - verify working
- Replicas: postgresflexalpha.CreateInstanceRequestPayloadGetReplicasAttributeType(&replVal),
- // TODO - verify working
- Storage: postgresflexalpha.CreateInstanceRequestPayloadGetStorageAttributeType(&postgresflexalpha.Storage{
- PerformanceClass: conversion.StringValueToPointer(storage.Class),
- Size: conversion.Int64ValueToPointer(storage.Size),
- }),
- Version: conversion.StringValueToPointer(model.Version),
- // TODO - verify working
- Encryption: postgresflexalpha.CreateInstanceRequestPayloadGetEncryptionAttributeType(
- &postgresflexalpha.InstanceEncryption{
- KekKeyId: conversion.StringValueToPointer(enc.KeyId), // model.Encryption.Attributes(),
- KekKeyRingId: conversion.StringValueToPointer(enc.KeyRingId),
- KekKeyVersion: conversion.StringValueToPointer(enc.KeyVersion),
- ServiceAccount: conversion.StringValueToPointer(enc.ServiceAccount),
- },
- ),
- Network: &postgresflexalpha.InstanceNetwork{
- AccessScope: postgresflexalpha.InstanceNetworkGetAccessScopeAttributeType(
- conversion.StringValueToPointer(net.AccessScope),
- ),
- },
- }, nil
-}
-
-func toUpdatePayload(model *Model, acl []string, flavor *flavorModel, storage *storageModel) (*postgresflexalpha.UpdateInstancePartiallyRequestPayload, error) {
- if model == nil {
- return nil, fmt.Errorf("nil model")
- }
- if acl == nil {
- return nil, fmt.Errorf("nil acl")
- }
- if flavor == nil {
- return nil, fmt.Errorf("nil flavor")
- }
- if storage == nil {
- return nil, fmt.Errorf("nil storage")
- }
-
- return &postgresflexalpha.UpdateInstancePartiallyRequestPayload{
- //Acl: postgresflexalpha.UpdateInstancePartiallyRequestPayloadGetAclAttributeType{
- // Items: &acl,
- //},
- BackupSchedule: conversion.StringValueToPointer(model.BackupSchedule),
- FlavorId: conversion.StringValueToPointer(flavor.Id),
- Name: conversion.StringValueToPointer(model.Name),
- //Replicas: conversion.Int64ValueToPointer(model.Replicas),
- Storage: &postgresflexalpha.StorageUpdate{
- Size: conversion.Int64ValueToPointer(storage.Size),
- },
- Version: conversion.StringValueToPointer(model.Version),
- }, nil
-}
-
-type postgresflexClient interface {
- GetFlavorsRequestExecute(ctx context.Context, projectId string, region string) (*postgresflexalpha.GetFlavorsResponse, error)
-}
-
-func loadFlavorId(ctx context.Context, client postgresflexClient, model *Model, flavor *flavorModel) error {
- if model == nil {
- return fmt.Errorf("nil model")
- }
- if flavor == nil {
- return fmt.Errorf("nil flavor")
- }
- cpu := conversion.Int64ValueToPointer(flavor.CPU)
- if cpu == nil {
- return fmt.Errorf("nil CPU")
- }
- ram := conversion.Int64ValueToPointer(flavor.RAM)
- if ram == nil {
- return fmt.Errorf("nil RAM")
- }
-
- projectId := model.ProjectId.ValueString()
- region := model.Region.ValueString()
- res, err := client.GetFlavorsRequestExecute(ctx, projectId, region)
- if err != nil {
- return fmt.Errorf("listing postgresflex flavors: %w", err)
- }
-
- avl := ""
- if res.Flavors == nil {
- return fmt.Errorf("finding flavors for project %s", projectId)
- }
- for _, f := range *res.Flavors {
- if f.Id == nil || f.Cpu == nil || f.Memory == nil {
- continue
- }
- if *f.Cpu == *cpu && *f.Memory == *ram {
- flavor.Id = types.StringValue(*f.Id)
- flavor.Description = types.StringValue(*f.Description)
- break
- }
- avl = fmt.Sprintf("%s\n- %d CPU, %d GB RAM", avl, *f.Cpu, *f.Memory)
- }
- if flavor.Id.ValueString() == "" {
- return fmt.Errorf("couldn't find flavor, available specs are:%s", avl)
- }
-
- return nil
-}
diff --git a/stackit/internal/services/postgresflexalpha/instance/resource_test.go b/stackit/internal/services/postgresflexalpha/instance/resource_test.go
deleted file mode 100644
index f0d37367..00000000
--- a/stackit/internal/services/postgresflexalpha/instance/resource_test.go
+++ /dev/null
@@ -1,768 +0,0 @@
-// Copyright (c) STACKIT
-
-package postgresflex
-
-import (
- "context"
- "fmt"
- "testing"
-
- "github.com/google/go-cmp/cmp"
- "github.com/hashicorp/terraform-plugin-framework/attr"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/stackit-sdk-go/core/utils"
- postgresflex "github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha"
-)
-
-type postgresFlexClientMocked struct {
- returnError bool
- getFlavorsResp *postgresflex.GetFlavorsResponse
-}
-
-func (c *postgresFlexClientMocked) ListFlavorsExecute(_ context.Context, _, _ string) (*postgresflex.GetFlavorsResponse, error) {
- if c.returnError {
- return nil, fmt.Errorf("get flavors failed")
- }
-
- return c.getFlavorsResp, nil
-}
-
-func TestMapFields(t *testing.T) {
- const testRegion = "region"
- tests := []struct {
- description string
- state Model
- input *postgresflex.GetInstanceResponse
- flavor *flavorModel
- storage *storageModel
- region string
- expected Model
- isValid bool
- }{
- {
- "default_values",
- Model{
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- },
- &postgresflex.GetInstanceResponse{},
- &flavorModel{},
- &storageModel{},
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Name: types.StringNull(),
- ACL: types.ListNull(types.StringType),
- BackupSchedule: types.StringNull(),
- Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
- "id": types.StringNull(),
- "description": types.StringNull(),
- "cpu": types.Int64Null(),
- "ram": types.Int64Null(),
- }),
- Replicas: types.Int64Null(),
- Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
- "class": types.StringNull(),
- "size": types.Int64Null(),
- }),
- Version: types.StringNull(),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "simple_values",
- Model{
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- },
- &postgresflex.GetInstanceResponse{
- Acl: &[]string{
- "ip1",
- "ip2",
- "",
- },
- BackupSchedule: utils.Ptr("schedule"),
- //Flavor: &postgresflex.Flavor{
- // Cpu: utils.Ptr(int64(12)),
- // Description: utils.Ptr("description"),
- // Id: utils.Ptr("flavor_id"),
- // Memory: utils.Ptr(int64(34)),
- //},
- Id: utils.Ptr("iid"),
- Name: utils.Ptr("name"),
- Replicas: postgresflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
- Status: postgresflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
- Storage: &postgresflex.Storage{
- PerformanceClass: utils.Ptr("class"),
- Size: utils.Ptr(int64(78)),
- },
- Version: utils.Ptr("version"),
- },
- &flavorModel{},
- &storageModel{},
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Name: types.StringValue("name"),
- ACL: types.ListValueMust(types.StringType, []attr.Value{
- types.StringValue("ip1"),
- types.StringValue("ip2"),
- types.StringValue(""),
- }),
- BackupSchedule: types.StringValue("schedule"),
- Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
- "id": types.StringValue("flavor_id"),
- "description": types.StringValue("description"),
- "cpu": types.Int64Value(12),
- "ram": types.Int64Value(34),
- }),
- Replicas: types.Int64Value(56),
- Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
- "class": types.StringValue("class"),
- "size": types.Int64Value(78),
- }),
- Version: types.StringValue("version"),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "simple_values_no_flavor_and_storage",
- Model{
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- },
- &postgresflex.GetInstanceResponse{
- Acl: &[]string{
- "ip1",
- "ip2",
- "",
- },
- BackupSchedule: utils.Ptr("schedule"),
- FlavorId: nil,
- Id: utils.Ptr("iid"),
- Name: utils.Ptr("name"),
- Replicas: postgresflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
- Status: postgresflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
- Storage: nil,
- Version: utils.Ptr("version"),
- },
- &flavorModel{
- CPU: types.Int64Value(12),
- RAM: types.Int64Value(34),
- },
- &storageModel{
- Class: types.StringValue("class"),
- Size: types.Int64Value(78),
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Name: types.StringValue("name"),
- ACL: types.ListValueMust(types.StringType, []attr.Value{
- types.StringValue("ip1"),
- types.StringValue("ip2"),
- types.StringValue(""),
- }),
- BackupSchedule: types.StringValue("schedule"),
- Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
- "id": types.StringNull(),
- "description": types.StringNull(),
- "cpu": types.Int64Value(12),
- "ram": types.Int64Value(34),
- }),
- Replicas: types.Int64Value(56),
- Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
- "class": types.StringValue("class"),
- "size": types.Int64Value(78),
- }),
- Version: types.StringValue("version"),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "acl_unordered",
- Model{
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- ACL: types.ListValueMust(types.StringType, []attr.Value{
- types.StringValue("ip2"),
- types.StringValue(""),
- types.StringValue("ip1"),
- }),
- },
- &postgresflex.GetInstanceResponse{
- Acl: &[]string{
- "",
- "ip1",
- "ip2",
- },
- BackupSchedule: utils.Ptr("schedule"),
- FlavorId: nil,
- Id: utils.Ptr("iid"),
- Name: utils.Ptr("name"),
- Replicas: postgresflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
- Status: postgresflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
- Storage: nil,
- Version: utils.Ptr("version"),
- },
- &flavorModel{
- CPU: types.Int64Value(12),
- RAM: types.Int64Value(34),
- },
- &storageModel{
- Class: types.StringValue("class"),
- Size: types.Int64Value(78),
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Name: types.StringValue("name"),
- ACL: types.ListValueMust(types.StringType, []attr.Value{
- types.StringValue("ip2"),
- types.StringValue(""),
- types.StringValue("ip1"),
- }),
- BackupSchedule: types.StringValue("schedule"),
- Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
- "id": types.StringNull(),
- "description": types.StringNull(),
- "cpu": types.Int64Value(12),
- "ram": types.Int64Value(34),
- }),
- Replicas: types.Int64Value(56),
- Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
- "class": types.StringValue("class"),
- "size": types.Int64Value(78),
- }),
- Version: types.StringValue("version"),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "nil_response",
- Model{
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- },
- nil,
- &flavorModel{},
- &storageModel{},
- testRegion,
- Model{},
- false,
- },
- {
- "no_resource_id",
- Model{
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- },
- &postgresflex.GetInstanceResponse{},
- &flavorModel{},
- &storageModel{},
- testRegion,
- Model{},
- false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.description, func(t *testing.T) {
- err := mapFields(context.Background(), tt.input, &tt.state, tt.flavor, tt.storage, tt.region)
- if !tt.isValid && err == nil {
- t.Fatalf("Should have failed")
- }
- if tt.isValid && err != nil {
- t.Fatalf("Should not have failed: %v", err)
- }
- if tt.isValid {
- diff := cmp.Diff(tt.state, tt.expected)
- if diff != "" {
- t.Fatalf("Data does not match: %s", diff)
- }
- }
- })
- }
-}
-
-func TestToCreatePayload(t *testing.T) {
- tests := []struct {
- description string
- input *Model
- inputAcl []string
- inputFlavor *flavorModel
- inputStorage *storageModel
- inputEncryption *encryptionModel
- inputNetwork *networkModel
- expected *postgresflex.CreateInstanceRequestPayload
- isValid bool
- }{
- {
- "default_values",
- &Model{},
- []string{},
- &flavorModel{},
- &storageModel{},
- &encryptionModel{},
- &networkModel{},
- &postgresflex.CreateInstanceRequestPayload{
- Acl: &[]string{},
- Storage: postgresflex.CreateInstanceRequestPayloadGetStorageAttributeType(&postgresflex.Storage{}),
- },
- true,
- },
- {
- "simple_values",
- &Model{
- BackupSchedule: types.StringValue("schedule"),
- Name: types.StringValue("name"),
- Replicas: types.Int64Value(12),
- Version: types.StringValue("version"),
- },
- []string{
- "ip_1",
- "ip_2",
- },
- &flavorModel{
- Id: types.StringValue("flavor_id"),
- },
- &storageModel{
- Class: types.StringValue("class"),
- Size: types.Int64Value(34),
- },
- &encryptionModel{},
- &networkModel{},
- &postgresflex.CreateInstanceRequestPayload{
- Acl: &[]string{
- "ip_1",
- "ip_2",
- },
- BackupSchedule: utils.Ptr("schedule"),
- FlavorId: utils.Ptr("flavor_id"),
- Name: utils.Ptr("name"),
- Replicas: postgresflex.CreateInstanceRequestPayloadGetReplicasAttributeType(utils.Ptr(int32(56))),
- Storage: postgresflex.CreateInstanceRequestPayloadGetStorageAttributeType(&postgresflex.Storage{
- PerformanceClass: utils.Ptr("class"),
- Size: utils.Ptr(int64(34)),
- }),
- Version: utils.Ptr("version"),
- },
- true,
- },
- {
- "null_fields_and_int_conversions",
- &Model{
- BackupSchedule: types.StringNull(),
- Name: types.StringNull(),
- Replicas: types.Int64Value(2123456789),
- Version: types.StringNull(),
- },
- []string{
- "",
- },
- &flavorModel{
- Id: types.StringNull(),
- },
- &storageModel{
- Class: types.StringNull(),
- Size: types.Int64Null(),
- },
- &encryptionModel{},
- &networkModel{},
- &postgresflex.CreateInstanceRequestPayload{
- Acl: &[]string{
- "",
- },
- BackupSchedule: nil,
- FlavorId: nil,
- Name: nil,
- Replicas: postgresflex.CreateInstanceRequestPayloadGetReplicasAttributeType(utils.Ptr(int32(2123456789))),
- Storage: postgresflex.CreateInstanceRequestPayloadGetStorageAttributeType(&postgresflex.Storage{
- PerformanceClass: nil,
- Size: nil,
- }),
- Version: nil,
- },
- true,
- },
- {
- "nil_model",
- nil,
- []string{},
- &flavorModel{},
- &storageModel{},
- &encryptionModel{},
- &networkModel{},
- nil,
- false,
- },
- {
- "nil_acl",
- &Model{},
- nil,
- &flavorModel{},
- &storageModel{},
- &encryptionModel{},
- &networkModel{},
- nil,
- false,
- },
- {
- "nil_flavor",
- &Model{},
- []string{},
- nil,
- &storageModel{},
- &encryptionModel{},
- &networkModel{},
- nil,
- false,
- },
- {
- "nil_storage",
- &Model{},
- []string{},
- &flavorModel{},
- nil,
- &encryptionModel{},
- &networkModel{},
- nil,
- false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.description, func(t *testing.T) {
- output, err := toCreatePayload(tt.input, tt.inputAcl, tt.inputFlavor, tt.inputStorage, tt.inputEncryption, tt.inputNetwork)
- if !tt.isValid && err == nil {
- t.Fatalf("Should have failed")
- }
- if tt.isValid && err != nil {
- t.Fatalf("Should not have failed: %v", err)
- }
- if tt.isValid {
- diff := cmp.Diff(output, tt.expected)
- if diff != "" {
- t.Fatalf("Data does not match: %s", diff)
- }
- }
- })
- }
-}
-
-//func TestToUpdatePayload(t *testing.T) {
-// tests := []struct {
-// description string
-// input *Model
-// inputAcl []string
-// inputFlavor *flavorModel
-// inputStorage *storageModel
-// expected *postgresflex.PartialUpdateInstancePayload
-// isValid bool
-// }{
-// {
-// "default_values",
-// &Model{},
-// []string{},
-// &flavorModel{},
-// &storageModel{},
-// &postgresflex.PartialUpdateInstancePayload{
-// Acl: &postgresflex.ACL{
-// Items: &[]string{},
-// },
-// Storage: &postgresflex.Storage{},
-// },
-// true,
-// },
-// {
-// "simple_values",
-// &Model{
-// BackupSchedule: types.StringValue("schedule"),
-// Name: types.StringValue("name"),
-// Replicas: types.Int64Value(12),
-// Version: types.StringValue("version"),
-// },
-// []string{
-// "ip_1",
-// "ip_2",
-// },
-// &flavorModel{
-// Id: types.StringValue("flavor_id"),
-// },
-// &storageModel{
-// Class: types.StringValue("class"),
-// Size: types.Int64Value(34),
-// },
-// &postgresflex.PartialUpdateInstancePayload{
-// Acl: &postgresflex.ACL{
-// Items: &[]string{
-// "ip_1",
-// "ip_2",
-// },
-// },
-// BackupSchedule: utils.Ptr("schedule"),
-// FlavorId: utils.Ptr("flavor_id"),
-// Name: utils.Ptr("name"),
-// Replicas: utils.Ptr(int64(12)),
-// Storage: &postgresflex.Storage{
-// Class: utils.Ptr("class"),
-// Size: utils.Ptr(int64(34)),
-// },
-// Version: utils.Ptr("version"),
-// },
-// true,
-// },
-// {
-// "null_fields_and_int_conversions",
-// &Model{
-// BackupSchedule: types.StringNull(),
-// Name: types.StringNull(),
-// Replicas: types.Int64Value(2123456789),
-// Version: types.StringNull(),
-// },
-// []string{
-// "",
-// },
-// &flavorModel{
-// Id: types.StringNull(),
-// },
-// &storageModel{
-// Class: types.StringNull(),
-// Size: types.Int64Null(),
-// },
-// &postgresflex.PartialUpdateInstancePayload{
-// Acl: &postgresflex.ACL{
-// Items: &[]string{
-// "",
-// },
-// },
-// BackupSchedule: nil,
-// FlavorId: nil,
-// Name: nil,
-// Replicas: utils.Ptr(int64(2123456789)),
-// Storage: &postgresflex.Storage{
-// Class: nil,
-// Size: nil,
-// },
-// Version: nil,
-// },
-// true,
-// },
-// {
-// "nil_model",
-// nil,
-// []string{},
-// &flavorModel{},
-// &storageModel{},
-// nil,
-// false,
-// },
-// {
-// "nil_acl",
-// &Model{},
-// nil,
-// &flavorModel{},
-// &storageModel{},
-// nil,
-// false,
-// },
-// {
-// "nil_flavor",
-// &Model{},
-// []string{},
-// nil,
-// &storageModel{},
-// nil,
-// false,
-// },
-// {
-// "nil_storage",
-// &Model{},
-// []string{},
-// &flavorModel{},
-// nil,
-// nil,
-// false,
-// },
-// }
-// for _, tt := range tests {
-// t.Run(tt.description, func(t *testing.T) {
-// output, err := toUpdatePayload(tt.input, tt.inputAcl, tt.inputFlavor, tt.inputStorage)
-// if !tt.isValid && err == nil {
-// t.Fatalf("Should have failed")
-// }
-// if tt.isValid && err != nil {
-// t.Fatalf("Should not have failed: %v", err)
-// }
-// if tt.isValid {
-// diff := cmp.Diff(output, tt.expected)
-// if diff != "" {
-// t.Fatalf("Data does not match: %s", diff)
-// }
-// }
-// })
-// }
-//}
-//
-//func TestLoadFlavorId(t *testing.T) {
-// tests := []struct {
-// description string
-// inputFlavor *flavorModel
-// mockedResp *postgresflex.ListFlavorsResponse
-// expected *flavorModel
-// getFlavorsFails bool
-// isValid bool
-// }{
-// {
-// "ok_flavor",
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// &postgresflex.ListFlavorsResponse{
-// Flavors: &[]postgresflex.Flavor{
-// {
-// Id: utils.Ptr("fid-1"),
-// Cpu: utils.Ptr(int64(2)),
-// Description: utils.Ptr("description"),
-// Memory: utils.Ptr(int64(8)),
-// },
-// },
-// },
-// &flavorModel{
-// Id: types.StringValue("fid-1"),
-// Description: types.StringValue("description"),
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// false,
-// true,
-// },
-// {
-// "ok_flavor_2",
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// &postgresflex.ListFlavorsResponse{
-// Flavors: &[]postgresflex.Flavor{
-// {
-// Id: utils.Ptr("fid-1"),
-// Cpu: utils.Ptr(int64(2)),
-// Description: utils.Ptr("description"),
-// Memory: utils.Ptr(int64(8)),
-// },
-// {
-// Id: utils.Ptr("fid-2"),
-// Cpu: utils.Ptr(int64(1)),
-// Description: utils.Ptr("description"),
-// Memory: utils.Ptr(int64(4)),
-// },
-// },
-// },
-// &flavorModel{
-// Id: types.StringValue("fid-1"),
-// Description: types.StringValue("description"),
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// false,
-// true,
-// },
-// {
-// "no_matching_flavor",
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// &postgresflex.ListFlavorsResponse{
-// Flavors: &[]postgresflex.Flavor{
-// {
-// Id: utils.Ptr("fid-1"),
-// Cpu: utils.Ptr(int64(1)),
-// Description: utils.Ptr("description"),
-// Memory: utils.Ptr(int64(8)),
-// },
-// {
-// Id: utils.Ptr("fid-2"),
-// Cpu: utils.Ptr(int64(1)),
-// Description: utils.Ptr("description"),
-// Memory: utils.Ptr(int64(4)),
-// },
-// },
-// },
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// false,
-// false,
-// },
-// {
-// "nil_response",
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// &postgresflex.ListFlavorsResponse{},
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// false,
-// false,
-// },
-// {
-// "error_response",
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// &postgresflex.ListFlavorsResponse{},
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// true,
-// false,
-// },
-// }
-// for _, tt := range tests {
-// t.Run(tt.description, func(t *testing.T) {
-// client := &postgresFlexClientMocked{
-// returnError: tt.getFlavorsFails,
-// getFlavorsResp: tt.mockedResp,
-// }
-// model := &Model{
-// ProjectId: types.StringValue("pid"),
-// }
-// flavorModel := &flavorModel{
-// CPU: tt.inputFlavor.CPU,
-// RAM: tt.inputFlavor.RAM,
-// }
-// err := loadFlavorId(context.Background(), client, model, flavorModel)
-// if !tt.isValid && err == nil {
-// t.Fatalf("Should have failed")
-// }
-// if tt.isValid && err != nil {
-// t.Fatalf("Should not have failed: %v", err)
-// }
-// if tt.isValid {
-// diff := cmp.Diff(flavorModel, tt.expected)
-// if diff != "" {
-// t.Fatalf("Data does not match: %s", diff)
-// }
-// }
-// })
-// }
-//}
diff --git a/stackit/internal/services/postgresflexalpha/instance/resources_gen/instance_resource_gen.go b/stackit/internal/services/postgresflexalpha/instance/resources_gen/instance_resource_gen.go
new file mode 100644
index 00000000..25ad092b
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/instance/resources_gen/instance_resource_gen.go
@@ -0,0 +1,2367 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+)
+
+func InstanceResourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "acl": schema.ListAttribute{
+ ElementType: types.StringType,
+ Computed: true,
+ Description: "List of IPV4 cidr.",
+ MarkdownDescription: "List of IPV4 cidr.",
+ },
+ "backup_schedule": schema.StringAttribute{
+ Required: true,
+ Description: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ MarkdownDescription: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ },
+ "connection_info": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "write": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "host": schema.StringAttribute{
+ Computed: true,
+ Description: "The host of the instance.",
+ MarkdownDescription: "The host of the instance.",
+ },
+ "port": schema.Int64Attribute{
+ Computed: true,
+ Description: "The port of the instance.",
+ MarkdownDescription: "The port of the instance.",
+ },
+ },
+ CustomType: WriteType{
+ ObjectType: types.ObjectType{
+ AttrTypes: WriteValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "The DNS name and port in the instance overview",
+ MarkdownDescription: "The DNS name and port in the instance overview",
+ },
+ },
+ CustomType: ConnectionInfoType{
+ ObjectType: types.ObjectType{
+ AttrTypes: ConnectionInfoValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "The connection information of the instance",
+ MarkdownDescription: "The connection information of the instance",
+ },
+ "encryption": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "kek_key_id": schema.StringAttribute{
+ Required: true,
+ Description: "The encryption-key key identifier",
+ MarkdownDescription: "The encryption-key key identifier",
+ },
+ "kek_key_ring_id": schema.StringAttribute{
+ Required: true,
+ Description: "The encryption-key keyring identifier",
+ MarkdownDescription: "The encryption-key keyring identifier",
+ },
+ "kek_key_version": schema.StringAttribute{
+ Required: true,
+ Description: "The encryption-key version",
+ MarkdownDescription: "The encryption-key version",
+ },
+ "service_account": schema.StringAttribute{
+ Required: true,
+ },
+ },
+ CustomType: EncryptionType{
+ ObjectType: types.ObjectType{
+ AttrTypes: EncryptionValue{}.AttributeTypes(ctx),
+ },
+ },
+ Optional: true,
+ Computed: true,
+ Description: "The configuration for instance's volume and backup storage encryption.\n\n⚠\ufe1d **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ MarkdownDescription: "The configuration for instance's volume and backup storage encryption.\n\n⚠\ufe1d **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ },
+ "flavor_id": schema.StringAttribute{
+ Required: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "instance_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "is_deletable": schema.BoolAttribute{
+ Computed: true,
+ Description: "Whether the instance can be deleted or not.",
+ MarkdownDescription: "Whether the instance can be deleted or not.",
+ },
+ "name": schema.StringAttribute{
+ Required: true,
+ Description: "The name of the instance.",
+ MarkdownDescription: "The name of the instance.",
+ },
+ "network": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "access_scope": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The access scope of the instance. It defines if the instance is public or airgapped.",
+ MarkdownDescription: "The access scope of the instance. It defines if the instance is public or airgapped.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "PUBLIC",
+ "SNA",
+ ),
+ },
+ Default: stringdefault.StaticString("PUBLIC"),
+ },
+ "acl": schema.ListAttribute{
+ ElementType: types.StringType,
+ Required: true,
+ Description: "List of IPV4 cidr.",
+ MarkdownDescription: "List of IPV4 cidr.",
+ },
+ "instance_address": schema.StringAttribute{
+ Computed: true,
+ },
+ "router_address": schema.StringAttribute{
+ Computed: true,
+ },
+ },
+ CustomType: NetworkType{
+ ObjectType: types.ObjectType{
+ AttrTypes: NetworkValue{}.AttributeTypes(ctx),
+ },
+ },
+ Required: true,
+ Description: "The access configuration of the instance",
+ MarkdownDescription: "The access configuration of the instance",
+ },
+ "project_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "replicas": schema.Int64Attribute{
+ Required: true,
+ Description: "How many replicas the instance should have.",
+ MarkdownDescription: "How many replicas the instance should have.",
+ Validators: []validator.Int64{
+ int64validator.OneOf(
+ 1,
+ 3,
+ ),
+ },
+ },
+ "retention_days": schema.Int64Attribute{
+ Required: true,
+ Description: "How long backups are retained. The value can only be between 32 and 365 days.",
+ MarkdownDescription: "How long backups are retained. The value can only be between 32 and 365 days.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ Description: "The current status of the instance.",
+ MarkdownDescription: "The current status of the instance.",
+ },
+ "storage": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "performance_class": schema.StringAttribute{
+ Required: true,
+ Description: "The storage class for the storage.",
+ MarkdownDescription: "The storage class for the storage.",
+ },
+ "size": schema.Int64Attribute{
+ Required: true,
+ Description: "The storage size in Gigabytes.",
+ MarkdownDescription: "The storage size in Gigabytes.",
+ },
+ },
+ CustomType: StorageType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageValue{}.AttributeTypes(ctx),
+ },
+ },
+ Required: true,
+ Description: "The object containing information about the storage size and class.",
+ MarkdownDescription: "The object containing information about the storage size and class.",
+ },
+ "version": schema.StringAttribute{
+ Required: true,
+ Description: "The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters.",
+ MarkdownDescription: "The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters.",
+ },
+ },
+ }
+}
+
+type InstanceModel struct {
+ Acl types.List `tfsdk:"acl"`
+ BackupSchedule types.String `tfsdk:"backup_schedule"`
+ ConnectionInfo ConnectionInfoValue `tfsdk:"connection_info"`
+ Encryption EncryptionValue `tfsdk:"encryption"`
+ FlavorId types.String `tfsdk:"flavor_id"`
+ Id types.String `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ IsDeletable types.Bool `tfsdk:"is_deletable"`
+ Name types.String `tfsdk:"name"`
+ Network NetworkValue `tfsdk:"network"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Replicas types.Int64 `tfsdk:"replicas"`
+ RetentionDays types.Int64 `tfsdk:"retention_days"`
+ Status types.String `tfsdk:"status"`
+ Storage StorageValue `tfsdk:"storage"`
+ Version types.String `tfsdk:"version"`
+}
+
+var _ basetypes.ObjectTypable = ConnectionInfoType{}
+
+type ConnectionInfoType struct {
+ basetypes.ObjectType
+}
+
+func (t ConnectionInfoType) Equal(o attr.Type) bool {
+ other, ok := o.(ConnectionInfoType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t ConnectionInfoType) String() string {
+ return "ConnectionInfoType"
+}
+
+func (t ConnectionInfoType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ writeAttribute, ok := attributes["write"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `write is missing from object`)
+
+ return nil, diags
+ }
+
+ writeVal, ok := writeAttribute.(basetypes.ObjectValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`write expected to be basetypes.ObjectValue, was: %T`, writeAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return ConnectionInfoValue{
+ Write: writeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewConnectionInfoValueNull() ConnectionInfoValue {
+ return ConnectionInfoValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewConnectionInfoValueUnknown() ConnectionInfoValue {
+ return ConnectionInfoValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewConnectionInfoValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (ConnectionInfoValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing ConnectionInfoValue Attribute Value",
+ "While creating a ConnectionInfoValue value, a missing attribute value was detected. "+
+ "A ConnectionInfoValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("ConnectionInfoValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid ConnectionInfoValue Attribute Type",
+ "While creating a ConnectionInfoValue value, an invalid attribute value was detected. "+
+ "A ConnectionInfoValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("ConnectionInfoValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("ConnectionInfoValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra ConnectionInfoValue Attribute Value",
+ "While creating a ConnectionInfoValue value, an extra attribute value was detected. "+
+ "A ConnectionInfoValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra ConnectionInfoValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewConnectionInfoValueUnknown(), diags
+ }
+
+ writeAttribute, ok := attributes["write"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `write is missing from object`)
+
+ return NewConnectionInfoValueUnknown(), diags
+ }
+
+ writeVal, ok := writeAttribute.(basetypes.ObjectValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`write expected to be basetypes.ObjectValue, was: %T`, writeAttribute))
+ }
+
+ if diags.HasError() {
+ return NewConnectionInfoValueUnknown(), diags
+ }
+
+ return ConnectionInfoValue{
+ Write: writeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewConnectionInfoValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) ConnectionInfoValue {
+ object, diags := NewConnectionInfoValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewConnectionInfoValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t ConnectionInfoType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewConnectionInfoValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewConnectionInfoValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewConnectionInfoValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewConnectionInfoValueMust(ConnectionInfoValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t ConnectionInfoType) ValueType(ctx context.Context) attr.Value {
+ return ConnectionInfoValue{}
+}
+
+var _ basetypes.ObjectValuable = ConnectionInfoValue{}
+
+type ConnectionInfoValue struct {
+ Write basetypes.ObjectValue `tfsdk:"write"`
+ state attr.ValueState
+}
+
+func (v ConnectionInfoValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 1)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["write"] = basetypes.ObjectType{
+ AttrTypes: WriteValue{}.AttributeTypes(ctx),
+ }.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 1)
+
+ val, err = v.Write.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["write"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v ConnectionInfoValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v ConnectionInfoValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v ConnectionInfoValue) String() string {
+ return "ConnectionInfoValue"
+}
+
+func (v ConnectionInfoValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ var write basetypes.ObjectValue
+
+ if v.Write.IsNull() {
+ write = types.ObjectNull(
+ WriteValue{}.AttributeTypes(ctx),
+ )
+ }
+
+ if v.Write.IsUnknown() {
+ write = types.ObjectUnknown(
+ WriteValue{}.AttributeTypes(ctx),
+ )
+ }
+
+ if !v.Write.IsNull() && !v.Write.IsUnknown() {
+ write = types.ObjectValueMust(
+ WriteValue{}.AttributeTypes(ctx),
+ v.Write.Attributes(),
+ )
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "write": basetypes.ObjectType{
+ AttrTypes: WriteValue{}.AttributeTypes(ctx),
+ },
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "write": write,
+ })
+
+ return objVal, diags
+}
+
+func (v ConnectionInfoValue) Equal(o attr.Value) bool {
+ other, ok := o.(ConnectionInfoValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Write.Equal(other.Write) {
+ return false
+ }
+
+ return true
+}
+
+func (v ConnectionInfoValue) Type(ctx context.Context) attr.Type {
+ return ConnectionInfoType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v ConnectionInfoValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "write": basetypes.ObjectType{
+ AttrTypes: WriteValue{}.AttributeTypes(ctx),
+ },
+ }
+}
+
+var _ basetypes.ObjectTypable = WriteType{}
+
+type WriteType struct {
+ basetypes.ObjectType
+}
+
+func (t WriteType) Equal(o attr.Type) bool {
+ other, ok := o.(WriteType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t WriteType) String() string {
+ return "WriteType"
+}
+
+func (t WriteType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ hostAttribute, ok := attributes["host"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `host is missing from object`)
+
+ return nil, diags
+ }
+
+ hostVal, ok := hostAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute))
+ }
+
+ portAttribute, ok := attributes["port"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `port is missing from object`)
+
+ return nil, diags
+ }
+
+ portVal, ok := portAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return WriteValue{
+ Host: hostVal,
+ Port: portVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewWriteValueNull() WriteValue {
+ return WriteValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewWriteValueUnknown() WriteValue {
+ return WriteValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewWriteValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (WriteValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing WriteValue Attribute Value",
+ "While creating a WriteValue value, a missing attribute value was detected. "+
+ "A WriteValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("WriteValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid WriteValue Attribute Type",
+ "While creating a WriteValue value, an invalid attribute value was detected. "+
+ "A WriteValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("WriteValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("WriteValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra WriteValue Attribute Value",
+ "While creating a WriteValue value, an extra attribute value was detected. "+
+ "A WriteValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra WriteValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewWriteValueUnknown(), diags
+ }
+
+ hostAttribute, ok := attributes["host"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `host is missing from object`)
+
+ return NewWriteValueUnknown(), diags
+ }
+
+ hostVal, ok := hostAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute))
+ }
+
+ portAttribute, ok := attributes["port"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `port is missing from object`)
+
+ return NewWriteValueUnknown(), diags
+ }
+
+ portVal, ok := portAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute))
+ }
+
+ if diags.HasError() {
+ return NewWriteValueUnknown(), diags
+ }
+
+ return WriteValue{
+ Host: hostVal,
+ Port: portVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewWriteValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) WriteValue {
+ object, diags := NewWriteValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewWriteValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t WriteType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewWriteValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewWriteValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewWriteValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewWriteValueMust(WriteValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t WriteType) ValueType(ctx context.Context) attr.Value {
+ return WriteValue{}
+}
+
+var _ basetypes.ObjectValuable = WriteValue{}
+
+type WriteValue struct {
+ Host basetypes.StringValue `tfsdk:"host"`
+ Port basetypes.Int64Value `tfsdk:"port"`
+ state attr.ValueState
+}
+
+func (v WriteValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 2)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["host"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["port"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 2)
+
+ val, err = v.Host.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["host"] = val
+
+ val, err = v.Port.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["port"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v WriteValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v WriteValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v WriteValue) String() string {
+ return "WriteValue"
+}
+
+func (v WriteValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "host": basetypes.StringType{},
+ "port": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "host": v.Host,
+ "port": v.Port,
+ })
+
+ return objVal, diags
+}
+
+func (v WriteValue) Equal(o attr.Value) bool {
+ other, ok := o.(WriteValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Host.Equal(other.Host) {
+ return false
+ }
+
+ if !v.Port.Equal(other.Port) {
+ return false
+ }
+
+ return true
+}
+
+func (v WriteValue) Type(ctx context.Context) attr.Type {
+ return WriteType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v WriteValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "host": basetypes.StringType{},
+ "port": basetypes.Int64Type{},
+ }
+}
+
+var _ basetypes.ObjectTypable = EncryptionType{}
+
+type EncryptionType struct {
+ basetypes.ObjectType
+}
+
+func (t EncryptionType) Equal(o attr.Type) bool {
+ other, ok := o.(EncryptionType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t EncryptionType) String() string {
+ return "EncryptionType"
+}
+
+func (t EncryptionType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return nil, diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueNull() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewEncryptionValueUnknown() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewEncryptionValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (EncryptionValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, a missing attribute value was detected. "+
+ "A EncryptionValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid EncryptionValue Attribute Type",
+ "While creating a EncryptionValue value, an invalid attribute value was detected. "+
+ "A EncryptionValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, an extra attribute value was detected. "+
+ "A EncryptionValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra EncryptionValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) EncryptionValue {
+ object, diags := NewEncryptionValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewEncryptionValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t EncryptionType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewEncryptionValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewEncryptionValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewEncryptionValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewEncryptionValueMust(EncryptionValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t EncryptionType) ValueType(ctx context.Context) attr.Value {
+ return EncryptionValue{}
+}
+
+var _ basetypes.ObjectValuable = EncryptionValue{}
+
+type EncryptionValue struct {
+ KekKeyId basetypes.StringValue `tfsdk:"kek_key_id"`
+ KekKeyRingId basetypes.StringValue `tfsdk:"kek_key_ring_id"`
+ KekKeyVersion basetypes.StringValue `tfsdk:"kek_key_version"`
+ ServiceAccount basetypes.StringValue `tfsdk:"service_account"`
+ state attr.ValueState
+}
+
+func (v EncryptionValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["kek_key_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_ring_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_version"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["service_account"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.KekKeyId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_id"] = val
+
+ val, err = v.KekKeyRingId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_ring_id"] = val
+
+ val, err = v.KekKeyVersion.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_version"] = val
+
+ val, err = v.ServiceAccount.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["service_account"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v EncryptionValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v EncryptionValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v EncryptionValue) String() string {
+ return "EncryptionValue"
+}
+
+func (v EncryptionValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "kek_key_id": v.KekKeyId,
+ "kek_key_ring_id": v.KekKeyRingId,
+ "kek_key_version": v.KekKeyVersion,
+ "service_account": v.ServiceAccount,
+ })
+
+ return objVal, diags
+}
+
+func (v EncryptionValue) Equal(o attr.Value) bool {
+ other, ok := o.(EncryptionValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.KekKeyId.Equal(other.KekKeyId) {
+ return false
+ }
+
+ if !v.KekKeyRingId.Equal(other.KekKeyRingId) {
+ return false
+ }
+
+ if !v.KekKeyVersion.Equal(other.KekKeyVersion) {
+ return false
+ }
+
+ if !v.ServiceAccount.Equal(other.ServiceAccount) {
+ return false
+ }
+
+ return true
+}
+
+func (v EncryptionValue) Type(ctx context.Context) attr.Type {
+ return EncryptionType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v EncryptionValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = NetworkType{}
+
+type NetworkType struct {
+ basetypes.ObjectType
+}
+
+func (t NetworkType) Equal(o attr.Type) bool {
+ other, ok := o.(NetworkType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t NetworkType) String() string {
+ return "NetworkType"
+}
+
+func (t NetworkType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return nil, diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return nil, diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return nil, diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return nil, diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueNull() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewNetworkValueUnknown() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewNetworkValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (NetworkValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing NetworkValue Attribute Value",
+ "While creating a NetworkValue value, a missing attribute value was detected. "+
+ "A NetworkValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid NetworkValue Attribute Type",
+ "While creating a NetworkValue value, an invalid attribute value was detected. "+
+ "A NetworkValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra NetworkValue Attribute Value",
+ "While creating a NetworkValue value, an extra attribute value was detected. "+
+ "A NetworkValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra NetworkValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) NetworkValue {
+ object, diags := NewNetworkValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewNetworkValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t NetworkType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewNetworkValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewNetworkValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewNetworkValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewNetworkValueMust(NetworkValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t NetworkType) ValueType(ctx context.Context) attr.Value {
+ return NetworkValue{}
+}
+
+var _ basetypes.ObjectValuable = NetworkValue{}
+
+type NetworkValue struct {
+ AccessScope basetypes.StringValue `tfsdk:"access_scope"`
+ Acl basetypes.ListValue `tfsdk:"acl"`
+ InstanceAddress basetypes.StringValue `tfsdk:"instance_address"`
+ RouterAddress basetypes.StringValue `tfsdk:"router_address"`
+ state attr.ValueState
+}
+
+func (v NetworkValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["access_scope"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["acl"] = basetypes.ListType{
+ ElemType: types.StringType,
+ }.TerraformType(ctx)
+ attrTypes["instance_address"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["router_address"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.AccessScope.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["access_scope"] = val
+
+ val, err = v.Acl.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["acl"] = val
+
+ val, err = v.InstanceAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["instance_address"] = val
+
+ val, err = v.RouterAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["router_address"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v NetworkValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v NetworkValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v NetworkValue) String() string {
+ return "NetworkValue"
+}
+
+func (v NetworkValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ var aclVal basetypes.ListValue
+ switch {
+ case v.Acl.IsUnknown():
+ aclVal = types.ListUnknown(types.StringType)
+ case v.Acl.IsNull():
+ aclVal = types.ListNull(types.StringType)
+ default:
+ var d diag.Diagnostics
+ aclVal, d = types.ListValue(types.StringType, v.Acl.Elements())
+ diags.Append(d...)
+ }
+
+ if diags.HasError() {
+ return types.ObjectUnknown(map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }), diags
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "access_scope": v.AccessScope,
+ "acl": aclVal,
+ "instance_address": v.InstanceAddress,
+ "router_address": v.RouterAddress,
+ })
+
+ return objVal, diags
+}
+
+func (v NetworkValue) Equal(o attr.Value) bool {
+ other, ok := o.(NetworkValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.AccessScope.Equal(other.AccessScope) {
+ return false
+ }
+
+ if !v.Acl.Equal(other.Acl) {
+ return false
+ }
+
+ if !v.InstanceAddress.Equal(other.InstanceAddress) {
+ return false
+ }
+
+ if !v.RouterAddress.Equal(other.RouterAddress) {
+ return false
+ }
+
+ return true
+}
+
+func (v NetworkValue) Type(ctx context.Context) attr.Type {
+ return NetworkType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v NetworkValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageType{}
+
+type StorageType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageType) String() string {
+ return "StorageType"
+}
+
+func (t StorageType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ performanceClassAttribute, ok := attributes["performance_class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `performance_class is missing from object`)
+
+ return nil, diags
+ }
+
+ performanceClassVal, ok := performanceClassAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`performance_class expected to be basetypes.StringValue, was: %T`, performanceClassAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageValue{
+ PerformanceClass: performanceClassVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueNull() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageValueUnknown() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageValue Attribute Value",
+ "While creating a StorageValue value, a missing attribute value was detected. "+
+ "A StorageValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageValue Attribute Type",
+ "While creating a StorageValue value, an invalid attribute value was detected. "+
+ "A StorageValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageValue Attribute Value",
+ "While creating a StorageValue value, an extra attribute value was detected. "+
+ "A StorageValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ performanceClassAttribute, ok := attributes["performance_class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `performance_class is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ performanceClassVal, ok := performanceClassAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`performance_class expected to be basetypes.StringValue, was: %T`, performanceClassAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ return StorageValue{
+ PerformanceClass: performanceClassVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageValue {
+ object, diags := NewStorageValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageValueMust(StorageValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageType) ValueType(ctx context.Context) attr.Value {
+ return StorageValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageValue{}
+
+type StorageValue struct {
+ PerformanceClass basetypes.StringValue `tfsdk:"performance_class"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ state attr.ValueState
+}
+
+func (v StorageValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 2)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["performance_class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 2)
+
+ val, err = v.PerformanceClass.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["performance_class"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageValue) String() string {
+ return "StorageValue"
+}
+
+func (v StorageValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "performance_class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "performance_class": v.PerformanceClass,
+ "size": v.Size,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.PerformanceClass.Equal(other.PerformanceClass) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageValue) Type(ctx context.Context) attr.Type {
+ return StorageType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "performance_class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/instance/use_state_for_unknown_if_flavor_unchanged_modifier.go b/stackit/internal/services/postgresflexalpha/instance/use_state_for_unknown_if_flavor_unchanged_modifier.go
deleted file mode 100644
index f6dce5ab..00000000
--- a/stackit/internal/services/postgresflexalpha/instance/use_state_for_unknown_if_flavor_unchanged_modifier.go
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) STACKIT
-
-package postgresflex
-
-import (
- "context"
-
- "github.com/hashicorp/terraform-plugin-framework/resource"
- "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
- "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
-)
-
-type useStateForUnknownIfFlavorUnchangedModifier struct {
- Req resource.SchemaRequest
-}
-
-// UseStateForUnknownIfFlavorUnchanged returns a plan modifier similar to UseStateForUnknown
-// if the RAM and CPU values are not changed in the plan. Otherwise, the plan modifier does nothing.
-func UseStateForUnknownIfFlavorUnchanged(req resource.SchemaRequest) planmodifier.String {
- return useStateForUnknownIfFlavorUnchangedModifier{
- Req: req,
- }
-}
-
-func (m useStateForUnknownIfFlavorUnchangedModifier) Description(context.Context) string {
- return "UseStateForUnknownIfFlavorUnchanged returns a plan modifier similar to UseStateForUnknown if the RAM and CPU values are not changed in the plan. Otherwise, the plan modifier does nothing."
-}
-
-func (m useStateForUnknownIfFlavorUnchangedModifier) MarkdownDescription(ctx context.Context) string {
- return m.Description(ctx)
-}
-
-func (m useStateForUnknownIfFlavorUnchangedModifier) PlanModifyString(ctx context.Context, req planmodifier.StringRequest, resp *planmodifier.StringResponse) { // nolint:gocritic // function signature required by Terraform
- // Do nothing if there is no state value.
- if req.StateValue.IsNull() {
- return
- }
-
- // Do nothing if there is a known planned value.
- if !req.PlanValue.IsUnknown() {
- return
- }
-
- // Do nothing if there is an unknown configuration value, otherwise interpolation gets messed up.
- if req.ConfigValue.IsUnknown() {
- return
- }
-
- // The above checks are taken from the UseStateForUnknown plan modifier implementation
- // (https://github.com/hashicorp/terraform-plugin-framework/blob/main/resource/schema/stringplanmodifier/use_state_for_unknown.go#L38)
-
- var stateModel Model
- diags := req.State.Get(ctx, &stateModel)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
-
- var stateFlavor = &flavorModel{}
- if !(stateModel.Flavor.IsNull() || stateModel.Flavor.IsUnknown()) {
- diags = stateModel.Flavor.As(ctx, stateFlavor, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var planModel Model
- diags = req.Plan.Get(ctx, &planModel)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
-
- var planFlavor = &flavorModel{}
- if !(planModel.Flavor.IsNull() || planModel.Flavor.IsUnknown()) {
- diags = planModel.Flavor.As(ctx, planFlavor, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- if planFlavor.CPU == stateFlavor.CPU && planFlavor.RAM == stateFlavor.RAM {
- resp.PlanValue = req.StateValue
- }
-}
diff --git a/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go b/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go
index 4601ed11..d5ffd00c 100644
--- a/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go
+++ b/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go
@@ -1,371 +1,1030 @@
-// Copyright (c) STACKIT
-
-package postgresflex_test
+package postgresflexalpha_test
import (
"context"
+ _ "embed"
"fmt"
+ "log"
+ "os"
+ "strconv"
"strings"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
- "github.com/hashicorp/terraform-plugin-testing/terraform"
- "github.com/stackitcloud/stackit-sdk-go/core/utils"
-
"github.com/stackitcloud/stackit-sdk-go/core/config"
- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/wait"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/testutil"
+
+ postgresflexalpha2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ postgresflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils"
+ // The fwresource import alias is so there is no collision
+ // with the more typical acceptance testing import:
+ // "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ fwresource "github.com/hashicorp/terraform-plugin-framework/resource"
)
-// Instance resource data
-var instanceResource = map[string]string{
- "project_id": testutil.ProjectId,
- "name": fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlphaNum)),
- "acl": "192.168.0.0/16",
- "backup_schedule": "00 16 * * *",
- "backup_schedule_updated": "00 12 * * *",
- "flavor_cpu": "2",
- "flavor_ram": "4",
- "flavor_description": "Small, Compute optimized",
- "replicas": "1",
- "storage_class": "premium-perf12-stackit",
- "storage_size": "5",
- "version": "14",
- "flavor_id": "2.4",
-}
+const pfx = "stackitprivatepreview_postgresflexalpha"
-// User resource data
-var userResource = map[string]string{
- "username": fmt.Sprintf("tfaccuser%s", acctest.RandStringFromCharSet(4, acctest.CharSetAlpha)),
- "role": "createdb",
- "project_id": instanceResource["project_id"],
-}
+var testInstances []string
-// Database resource data
-var databaseResource = map[string]string{
- "name": fmt.Sprintf("tfaccdb%s", acctest.RandStringFromCharSet(4, acctest.CharSetAlphaNum)),
-}
+func init() {
+ sweeperName := fmt.Sprintf("%s_%s", pfx, "sweeper")
+ resource.AddTestSweepers(
+ sweeperName, &resource.Sweeper{
+ Name: sweeperName,
+ F: func(_ string) error { // region is passed by the testing framework
+ ctx := context.Background()
+ apiClientConfigOptions := []config.ConfigurationOption{}
+ apiClient, err := postgresflexalpha2.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ log.Fatalln(err)
+ }
-func configResources(backupSchedule string, region *string) string {
- var regionConfig string
- if region != nil {
- regionConfig = fmt.Sprintf(`region = %q`, *region)
- }
- return fmt.Sprintf(`
- %s
+ instances, err := apiClient.ListInstancesRequest(ctx, testutils.ProjectId, testutils.Region).
+ Size(100).
+ Execute()
+ if err != nil {
+ log.Fatalln(err)
+ }
- resource "stackit_postgresflex_instance" "instance" {
- project_id = "%s"
- name = "%s"
- acl = ["%s"]
- backup_schedule = "%s"
- flavor = {
- cpu = %s
- ram = %s
+ for _, inst := range instances.GetInstances() {
+ if strings.HasPrefix(inst.GetName(), "tf-acc-") {
+ for _, item := range testInstances {
+ if inst.GetName() == item {
+ delErr := apiClient.DeleteInstanceRequestExecute(
+ ctx,
+ testutils.ProjectId,
+ testutils.Region,
+ inst.GetId(),
+ )
+ if delErr != nil {
+ // TODO: maybe just warn?
+ log.Fatalln(delErr)
+ }
+ }
+ }
}
- replicas = %s
- storage = {
- class = "%s"
- size = %s
- }
- version = "%s"
- %s
}
-
- resource "stackit_postgresflex_user" "user" {
- project_id = stackit_postgresflex_instance.instance.project_id
- instance_id = stackit_postgresflex_instance.instance.instance_id
- username = "%s"
- roles = ["%s"]
- }
-
- resource "stackit_postgresflex_database" "database" {
- project_id = stackit_postgresflex_instance.instance.project_id
- instance_id = stackit_postgresflex_instance.instance.instance_id
- name = "%s"
- owner = stackit_postgresflex_user.user.username
- }
- `,
- testutil.PostgresFlexProviderConfig(),
- instanceResource["project_id"],
- instanceResource["name"],
- instanceResource["acl"],
- backupSchedule,
- instanceResource["flavor_cpu"],
- instanceResource["flavor_ram"],
- instanceResource["replicas"],
- instanceResource["storage_class"],
- instanceResource["storage_size"],
- instanceResource["version"],
- regionConfig,
- userResource["username"],
- userResource["role"],
- databaseResource["name"],
+ return nil
+ },
+ },
)
}
-func TestAccPostgresFlexFlexResource(t *testing.T) {
- resource.Test(t, resource.TestCase{
- ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories,
- CheckDestroy: testAccCheckPostgresFlexDestroy,
- Steps: []resource.TestStep{
- // Creation
- {
- Config: configResources(instanceResource["backup_schedule"], &testutil.Region),
- Check: resource.ComposeAggregateTestCheckFunc(
- // Instance
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "project_id", instanceResource["project_id"]),
- resource.TestCheckResourceAttrSet("stackit_postgresflex_instance.instance", "instance_id"),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "name", instanceResource["name"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "acl.#", "1"),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "acl.0", instanceResource["acl"]),
- resource.TestCheckResourceAttrSet("stackit_postgresflex_instance.instance", "flavor.id"),
- resource.TestCheckResourceAttrSet("stackit_postgresflex_instance.instance", "flavor.description"),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "backup_schedule", instanceResource["backup_schedule"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "flavor.cpu", instanceResource["flavor_cpu"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "flavor.ram", instanceResource["flavor_ram"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "replicas", instanceResource["replicas"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "storage.class", instanceResource["storage_class"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "storage.size", instanceResource["storage_size"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "version", instanceResource["version"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "region", testutil.Region),
+func TestInstanceResourceSchema(t *testing.T) {
+ t.Parallel()
- // User
- resource.TestCheckResourceAttrPair(
- "stackit_postgresflex_user.user", "project_id",
- "stackit_postgresflex_instance.instance", "project_id",
- ),
- resource.TestCheckResourceAttrPair(
- "stackit_postgresflex_user.user", "instance_id",
- "stackit_postgresflex_instance.instance", "instance_id",
- ),
- resource.TestCheckResourceAttrSet("stackit_postgresflex_user.user", "user_id"),
- resource.TestCheckResourceAttrSet("stackit_postgresflex_user.user", "password"),
-
- // Database
- resource.TestCheckResourceAttrPair(
- "stackit_postgresflex_database.database", "project_id",
- "stackit_postgresflex_instance.instance", "project_id",
- ),
- resource.TestCheckResourceAttrPair(
- "stackit_postgresflex_database.database", "instance_id",
- "stackit_postgresflex_instance.instance", "instance_id",
- ),
- resource.TestCheckResourceAttr("stackit_postgresflex_database.database", "name", databaseResource["name"]),
- resource.TestCheckResourceAttrPair(
- "stackit_postgresflex_database.database", "owner",
- "stackit_postgresflex_user.user", "username",
- ),
- ),
- },
- // data source
- {
- Config: fmt.Sprintf(`
- %s
-
- data "stackit_postgresflex_instance" "instance" {
- project_id = stackit_postgresflex_instance.instance.project_id
- instance_id = stackit_postgresflex_instance.instance.instance_id
- }
-
- data "stackit_postgresflex_user" "user" {
- project_id = stackit_postgresflex_instance.instance.project_id
- instance_id = stackit_postgresflex_instance.instance.instance_id
- user_id = stackit_postgresflex_user.user.user_id
- }
-
- data "stackit_postgresflex_database" "database" {
- project_id = stackit_postgresflex_instance.instance.project_id
- instance_id = stackit_postgresflex_instance.instance.instance_id
- database_id = stackit_postgresflex_database.database.database_id
- }
- `,
- configResources(instanceResource["backup_schedule"], nil),
- ),
- Check: resource.ComposeAggregateTestCheckFunc(
- // Instance data
- resource.TestCheckResourceAttr("data.stackit_postgresflex_instance.instance", "project_id", instanceResource["project_id"]),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_instance.instance", "name", instanceResource["name"]),
- resource.TestCheckResourceAttrPair(
- "data.stackit_postgresflex_instance.instance", "project_id",
- "stackit_postgresflex_instance.instance", "project_id",
- ),
- resource.TestCheckResourceAttrPair(
- "data.stackit_postgresflex_instance.instance", "instance_id",
- "stackit_postgresflex_instance.instance", "instance_id",
- ),
- resource.TestCheckResourceAttrPair(
- "data.stackit_postgresflex_user.user", "instance_id",
- "stackit_postgresflex_user.user", "instance_id",
- ),
-
- resource.TestCheckResourceAttr("data.stackit_postgresflex_instance.instance", "acl.#", "1"),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_instance.instance", "acl.0", instanceResource["acl"]),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_instance.instance", "backup_schedule", instanceResource["backup_schedule"]),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_instance.instance", "flavor.id", instanceResource["flavor_id"]),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_instance.instance", "flavor.description", instanceResource["flavor_description"]),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_instance.instance", "flavor.cpu", instanceResource["flavor_cpu"]),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_instance.instance", "flavor.ram", instanceResource["flavor_ram"]),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_instance.instance", "replicas", instanceResource["replicas"]),
-
- // User data
- resource.TestCheckResourceAttr("data.stackit_postgresflex_user.user", "project_id", userResource["project_id"]),
- resource.TestCheckResourceAttrSet("data.stackit_postgresflex_user.user", "user_id"),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_user.user", "username", userResource["username"]),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_user.user", "roles.#", "1"),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_user.user", "roles.0", userResource["role"]),
- resource.TestCheckResourceAttrSet("data.stackit_postgresflex_user.user", "host"),
- resource.TestCheckResourceAttrSet("data.stackit_postgresflex_user.user", "port"),
-
- // Database data
- resource.TestCheckResourceAttr("data.stackit_postgresflex_database.database", "project_id", instanceResource["project_id"]),
- resource.TestCheckResourceAttr("data.stackit_postgresflex_database.database", "name", databaseResource["name"]),
- resource.TestCheckResourceAttrPair(
- "data.stackit_postgresflex_database.database", "instance_id",
- "stackit_postgresflex_instance.instance", "instance_id",
- ),
- resource.TestCheckResourceAttrPair(
- "data.stackit_postgresflex_database.database", "owner",
- "data.stackit_postgresflex_user.user", "username",
- ),
- ),
- },
- // Import
- {
- ResourceName: "stackit_postgresflex_instance.instance",
- ImportStateIdFunc: func(s *terraform.State) (string, error) {
- r, ok := s.RootModule().Resources["stackit_postgresflex_instance.instance"]
- if !ok {
- return "", fmt.Errorf("couldn't find resource stackit_postgresflex_instance.instance")
- }
- instanceId, ok := r.Primary.Attributes["instance_id"]
- if !ok {
- return "", fmt.Errorf("couldn't find attribute instance_id")
- }
-
- return fmt.Sprintf("%s,%s,%s", testutil.ProjectId, testutil.Region, instanceId), nil
- },
- ImportState: true,
- ImportStateVerify: true,
- ImportStateVerifyIgnore: []string{"password"},
- },
- {
- ResourceName: "stackit_postgresflex_user.user",
- ImportStateIdFunc: func(s *terraform.State) (string, error) {
- r, ok := s.RootModule().Resources["stackit_postgresflex_user.user"]
- if !ok {
- return "", fmt.Errorf("couldn't find resource stackit_postgresflex_user.user")
- }
- instanceId, ok := r.Primary.Attributes["instance_id"]
- if !ok {
- return "", fmt.Errorf("couldn't find attribute instance_id")
- }
- userId, ok := r.Primary.Attributes["user_id"]
- if !ok {
- return "", fmt.Errorf("couldn't find attribute user_id")
- }
-
- return fmt.Sprintf("%s,%s,%s,%s", testutil.ProjectId, testutil.Region, instanceId, userId), nil
- },
- ImportState: true,
- ImportStateVerify: true,
- ImportStateVerifyIgnore: []string{"password", "uri"},
- },
- {
- ResourceName: "stackit_postgresflex_database.database",
- ImportStateIdFunc: func(s *terraform.State) (string, error) {
- r, ok := s.RootModule().Resources["stackit_postgresflex_database.database"]
- if !ok {
- return "", fmt.Errorf("couldn't find resource stackit_postgresflex_database.database")
- }
- instanceId, ok := r.Primary.Attributes["instance_id"]
- if !ok {
- return "", fmt.Errorf("couldn't find attribute instance_id")
- }
- databaseId, ok := r.Primary.Attributes["database_id"]
- if !ok {
- return "", fmt.Errorf("couldn't find attribute database_id")
- }
-
- return fmt.Sprintf("%s,%s,%s,%s", testutil.ProjectId, testutil.Region, instanceId, databaseId), nil
- },
- ImportState: true,
- ImportStateVerify: true,
- },
- // Update
- {
- Config: configResources(instanceResource["backup_schedule_updated"], nil),
- Check: resource.ComposeAggregateTestCheckFunc(
- // Instance data
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "project_id", instanceResource["project_id"]),
- resource.TestCheckResourceAttrSet("stackit_postgresflex_instance.instance", "instance_id"),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "name", instanceResource["name"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "acl.#", "1"),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "acl.0", instanceResource["acl"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "backup_schedule", instanceResource["backup_schedule_updated"]),
- resource.TestCheckResourceAttrSet("stackit_postgresflex_instance.instance", "flavor.id"),
- resource.TestCheckResourceAttrSet("stackit_postgresflex_instance.instance", "flavor.description"),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "flavor.cpu", instanceResource["flavor_cpu"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "flavor.ram", instanceResource["flavor_ram"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "replicas", instanceResource["replicas"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "storage.class", instanceResource["storage_class"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "storage.size", instanceResource["storage_size"]),
- resource.TestCheckResourceAttr("stackit_postgresflex_instance.instance", "version", instanceResource["version"]),
- ),
- },
- // Deletion is done by the framework implicitly
- },
- })
-}
-
-func testAccCheckPostgresFlexDestroy(s *terraform.State) error {
ctx := context.Background()
- var client *postgresflex.APIClient
- var err error
- if testutil.PostgresFlexCustomEndpoint == "" {
- client, err = postgresflex.NewAPIClient()
- } else {
- client, err = postgresflex.NewAPIClient(
- config.WithEndpoint(testutil.PostgresFlexCustomEndpoint),
- )
- }
- if err != nil {
- return fmt.Errorf("creating client: %w", err)
+ schemaRequest := fwresource.SchemaRequest{}
+ schemaResponse := &fwresource.SchemaResponse{}
+
+ // Instantiate the resource.Resource and call its Schema method
+ postgresflexalpha.NewInstanceResource().Schema(ctx, schemaRequest, schemaResponse)
+
+ if schemaResponse.Diagnostics.HasError() {
+ t.Fatalf("Schema method diagnostics: %+v", schemaResponse.Diagnostics)
}
- instancesToDestroy := []string{}
- for _, rs := range s.RootModule().Resources {
- if rs.Type != "stackit_postgresflex_instance" {
- continue
- }
- // instance terraform ID: = "[project_id],[region],[instance_id]"
- instanceId := strings.Split(rs.Primary.ID, core.Separator)[2]
- instancesToDestroy = append(instancesToDestroy, instanceId)
- }
+ // Validate the schema
+ diagnostics := schemaResponse.Schema.ValidateImplementation(ctx)
- instancesResp, err := client.ListInstances(ctx, testutil.ProjectId, testutil.Region).Execute()
- if err != nil {
- return fmt.Errorf("getting instancesResp: %w", err)
+ if diagnostics.HasError() {
+ t.Fatalf("Schema validation diagnostics: %+v", diagnostics)
}
-
- items := *instancesResp.Items
- for i := range items {
- if items[i].Id == nil {
- continue
- }
- if utils.Contains(instancesToDestroy, *items[i].Id) {
- err := client.ForceDeleteInstanceExecute(ctx, testutil.ProjectId, testutil.Region, *items[i].Id)
- if err != nil {
- return fmt.Errorf("deleting instance %s during CheckDestroy: %w", *items[i].Id, err)
- }
- _, err = wait.DeleteInstanceWaitHandler(ctx, client, testutil.ProjectId, testutil.Region, *items[i].Id).WaitWithContext(ctx)
- if err != nil {
- return fmt.Errorf("deleting instance %s during CheckDestroy: waiting for deletion %w", *items[i].Id, err)
- }
- }
- }
- return nil
}
+
+var (
+ //go:embed testdata/resource-no-enc.tf
+ resourceConfigNoEnc string //nolint:unused // needs implementation
+
+ //go:embed testdata/resource-enc.tf
+ resourceConfigEnc string //nolint:unused // needs implementation
+)
+
+func TestMain(m *testing.M) {
+ testutils.Setup()
+ code := m.Run()
+ // shutdown()
+ os.Exit(code)
+}
+
+func testAccPreCheck(t *testing.T) {
+ if _, ok := os.LookupEnv("TF_ACC_PROJECT_ID"); !ok {
+ t.Fatalf("could not find env var TF_ACC_PROJECT_ID")
+ }
+}
+
+// func TestAccResourceExample_parallel(t *testing.T) {
+// t.Parallel()
+//
+// exData := resData{
+// Region: "eu01",
+// ServiceAccountFilePath: sa_file,
+// ProjectID: project_id,
+// Name: acctest.RandomWithPrefix("tf-acc"),
+// }
+//
+// resource.Test(t, resource.TestCase{
+// ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+// Steps: []resource.TestStep{
+// {
+// Config: testAccResourceEncryptionExampleConfig(exData),
+// Check: resource.TestCheckResourceAttrSet("example_resource.test", "id"),
+// },
+// },
+// })
+//}
+
+type resData struct {
+ ServiceAccountFilePath string
+ ProjectId string
+ Region string
+ Name string
+ TfName string
+ FlavorId string
+ BackupSchedule string
+ UseEncryption bool
+ KekKeyId string
+ KekKeyRingId string
+ KekKeyVersion uint8
+ KekServiceAccount string
+ PerformanceClass string
+ Replicas uint32
+ Size uint32
+ AclString string
+ AccessScope string
+ RetentionDays uint32
+ Version string
+ Users []User
+ Databases []Database
+}
+
+type User struct {
+ Name string
+ ProjectId string
+ Roles []string
+}
+
+type Database struct {
+ Name string
+ ProjectId string
+ Owner string
+}
+
+func getExample() resData {
+ name := acctest.RandomWithPrefix("tf-acc")
+ return resData{
+ Region: os.Getenv("TF_ACC_REGION"),
+ ServiceAccountFilePath: os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE"),
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Name: name,
+ TfName: name,
+ FlavorId: "2.4",
+ BackupSchedule: "0 0 * * *",
+ UseEncryption: false,
+ RetentionDays: 33,
+ Replicas: 1,
+ PerformanceClass: "premium-perf2-stackit",
+ Size: 10,
+ AclString: "0.0.0.0/0",
+ AccessScope: "PUBLIC",
+ Version: "17",
+ }
+}
+
+func TestAccInstance(t *testing.T) {
+ exData := getExample()
+
+ updNameData := exData
+ updNameData.Name = "name-updated"
+
+ updSizeData := exData
+ updSizeData.Size = 25
+
+ resource.ParallelTest(
+ t, resource.TestCase{
+ PreCheck: func() {
+ testAccPreCheck(t)
+ t.Logf(" ... working on instance %s", exData.TfName)
+ testInstances = append(testInstances, exData.TfName)
+ },
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ exData,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr(
+ testutils.ResStr(pfx, "instance", exData.TfName),
+ "name",
+ exData.Name,
+ ),
+ resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "instance", exData.TfName), "id"),
+ ),
+ },
+ // Update name and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ updNameData,
+ ),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr(
+ testutils.ResStr(pfx, "instance", exData.TfName),
+ "name",
+ updNameData.Name,
+ ),
+ ),
+ },
+ // Update size and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ updSizeData,
+ ),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr(
+ testutils.ResStr(pfx, "instance", exData.TfName),
+ "storage.size",
+ strconv.Itoa(int(updSizeData.Size)),
+ ),
+ ),
+ },
+ //// Import test
+ //{
+ // ResourceName: "example_resource.test",
+ // ImportState: true,
+ // ImportStateVerify: true,
+ // },
+ },
+ },
+ )
+}
+
+func TestAccInstanceWithUsers(t *testing.T) {
+ data := getExample()
+
+ userName := "testUser"
+ data.Users = []User{
+ {
+ Name: userName,
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Roles: []string{"login"},
+ },
+ }
+
+ resource.ParallelTest(
+ t, resource.TestCase{
+ PreCheck: func() {
+ testAccPreCheck(t)
+ t.Logf(" ... working on instance %s", data.TfName)
+ testInstances = append(testInstances, data.TfName)
+ },
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ data,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr(
+ testutils.ResStr(pfx, "instance", data.TfName),
+ "name",
+ data.Name,
+ ),
+ resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "instance", data.TfName), "id"),
+ resource.TestCheckResourceAttr(testutils.ResStr(pfx, "user", userName), "name", userName),
+ resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "user", userName), "id"),
+ ),
+ },
+ },
+ },
+ )
+}
+
+func TestAccInstanceWithDatabases(t *testing.T) {
+ data := getExample()
+
+ dbName := "testdb"
+ userName := "testUser"
+ data.Users = []User{
+ {
+ Name: userName,
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Roles: []string{"login"},
+ },
+ }
+
+ data.Databases = []Database{
+ {
+ Name: dbName,
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Owner: userName,
+ },
+ }
+
+ resource.ParallelTest(
+ t, resource.TestCase{
+ PreCheck: func() {
+ testAccPreCheck(t)
+ t.Logf(" ... working on instance %s", data.TfName)
+ testInstances = append(testInstances, data.TfName)
+ },
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ data,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr(
+ testutils.ResStr(pfx, "instance", data.TfName),
+ "name",
+ data.Name,
+ ),
+ resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "instance", data.TfName), "id"),
+ resource.TestCheckResourceAttr(testutils.ResStr(pfx, "user", userName), "name", userName),
+ resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "user", userName), "id"),
+ resource.TestCheckResourceAttr(testutils.ResStr(pfx, "database", dbName), "name", dbName),
+ resource.TestCheckResourceAttr(testutils.ResStr(pfx, "database", dbName), "owner", userName),
+ resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "database", dbName), "id"),
+ ),
+ },
+ },
+ },
+ )
+}
+
+// func setupMockServer() *httptest.Server {
+// mux := http.NewServeMux()
+//
+// mux.HandleFunc("/api/resources", func(w http.ResponseWriter, r *http.Request) {
+// switch r.Method {
+// case http.MethodPost:
+// w.WriteHeader(http.StatusCreated)
+// err := json.NewEncoder(w).Encode(map[string]string{
+// "id": "mock-id-123",
+// "name": "test-resource",
+// })
+// if err != nil {
+// log.Fatalln(err)
+// }
+// case http.MethodGet:
+// w.WriteHeader(http.StatusOK)
+// err := json.NewEncoder(w).Encode([]map[string]string{})
+// if err != nil {
+// log.Fatalln(err)
+// }
+// }
+// })
+//
+// return httptest.NewServer(mux)
+//}
+//
+// func TestUnitResourceCreate(t *testing.T) {
+// server := setupMockServer()
+// defer server.Close()
+//
+// // Configure provider to use mock server URL
+// err := os.Setenv("API_ENDPOINT", server.URL)
+// if err != nil {
+// log.Fatalln(err)
+// }
+//
+// // Run unit tests against mock
+//}
+
+// type postgresFlexClientMocked struct {
+// returnError bool
+// getFlavorsResp *postgresflex.GetFlavorsResponse
+// }
+//
+// func (c *postgresFlexClientMocked) ListFlavorsExecute(_ context.Context, _, _ string) (*postgresflex.GetFlavorsResponse, error) {
+// if c.returnError {
+// return nil, fmt.Errorf("get flavors failed")
+// }
+//
+// return c.getFlavorsResp, nil
+// }
+
+// func TestNewInstanceResource(t *testing.T) {
+// exData := resData{
+// Region: "eu01",
+// ServiceAccountFilePath: sa_file,
+// ProjectID: project_id,
+// Name: "testRes",
+// }
+// resource.ParallelTest(t, resource.TestCase{
+// ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+// Steps: []resource.TestStep{
+// {
+// Config: testAccResourceEncryptionExampleConfig(exData),
+// Check: resource.ComposeAggregateTestCheckFunc(
+// resource.TestCheckResourceAttr("example_resource.test", "name", exData.Name),
+// resource.TestCheckResourceAttrSet("example_resource.test", "id"),
+// ),
+// },
+// },
+// })
+//
+// //tests := []struct {
+// // name string
+// // want resource.Resource
+// //}{
+// // {
+// // name: "create empty instance resource",
+// // want: &instanceResource{},
+// // },
+// //}
+// //for _, tt := range tests {
+// // t.Run(tt.name, func(t *testing.T) {
+// // if got := NewInstanceResource(); !reflect.DeepEqual(got, tt.want) {
+// // t.Errorf("NewInstanceResource() = %v, want %v", got, tt.want)
+// // }
+// // })
+// //}
+//}
+
+//// Instance resource data
+// var instanceResource = map[string]string{
+// "project_id": testutils.ProjectId,
+// "region": "eu01",
+// "name": fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlphaNum)),
+// "acl": "192.168.0.0/16",
+// "backup_schedule": "00 16 * * *",
+// "backup_schedule_updated": "00 12 * * *",
+// "retention_days": "33",
+// "flavor_cpu": "2",
+// "flavor_ram": "4",
+// "flavor_description": "Small, Compute optimized",
+// "replicas": "1",
+// "storage_class": "premium-perf12-stackit",
+// "storage_size": "5",
+// "version": "14",
+// "flavor_id": "2.4",
+// "kek_key_id": "UUID1",
+// "kek_key_ring_id": "UUID2",
+// "kek_key_version": "1",
+// "service_account": "service@account.com",
+// "access_scope": "SNA",
+//}
+//
+//// User resource data
+// var userResource = map[string]string{
+// "username": fmt.Sprintf("tfaccuser%s", acctest.RandStringFromCharSet(4, acctest.CharSetAlpha)),
+// "role": "createdb",
+// "project_id": testutils.ProjectId,
+//}
+//
+//// Database resource data
+// var databaseResource = map[string]string{
+// "name": fmt.Sprintf("tfaccdb%s", acctest.RandStringFromCharSet(4, acctest.CharSetAlphaNum)),
+// "project_id": testutils.ProjectId,
+//}
+//
+// func configResources(backupSchedule string, _ *string) string {
+// return fmt.Sprintf(
+// `
+// %s
+//
+//
+// resource "stackitprivatepreview_postgresflexalpha_instance" "instance" {
+// project_id = "%s"
+// region = "%s"
+// name = "%s"
+// backup_schedule = "%s"
+// retention_days = %s
+// flavor_id = %s
+// replicas = %s
+// storage = {
+// performance_class = "%s"
+// size = %s
+// }
+// encryption = {
+// kek_key_id = "%s"
+// kek_key_ring_id = "%s"
+// kek_key_version = "%s"
+// service_account = "%s"
+// }
+// network = {
+// acl = ["%s"]
+// access_scope = "%s"
+// }
+// version = %s
+// }
+//
+// resource "stackitprivatepreview_postgresflexalpha_user" "user" {
+// project_id = "%s"
+// instance_id = stackitprivatepreview_postgresflexalpha_instance.instance.instance_id
+// username = "%s"
+// roles = ["%s"]
+// }
+//
+// resource "stackitprivatepreview_postgresflexalpha_database" "database" {
+// project_id = "%s"
+// instance_id = stackitprivatepreview_postgresflexalpha_instance.instance.instance_id
+// name = "%s"
+// owner = stackitprivatepreview_postgresflexalpha_user.user.username
+// }
+// `,
+// testutils.PostgresFlexProviderConfig(
+// utils.GetEnvOrDefault("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_FILE", "~/service-account.json"),
+// ),
+// instanceResource["project_id"],
+// instanceResource["region"],
+// instanceResource["name"],
+// backupSchedule,
+// instanceResource["retention_days"],
+// instanceResource["flavor_id"],
+// instanceResource["replicas"],
+// instanceResource["storage_class"],
+// instanceResource["storage_size"],
+// instanceResource["kek_key_id"],
+// instanceResource["kek_key_ring_id"],
+// instanceResource["kek_key_version"],
+// instanceResource["service_account"],
+// instanceResource["acl"],
+// instanceResource["access_scope"],
+// instanceResource["version"],
+//
+// userResource["project_id"],
+// userResource["username"],
+// userResource["role"],
+//
+// databaseResource["project_id"],
+// databaseResource["name"],
+// )
+//}
+//
+// func TestAccPostgresFlexFlexResource(t *testing.T) {
+// resource.ParallelTest(
+// t, resource.TestCase{
+// ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+// CheckDestroy: testAccCheckPostgresFlexDestroy,
+// Steps: []resource.TestStep{
+// // Creation
+// {
+// // testdata/
+// // ConfigDirectory: config.TestNameDirectory(),
+//
+// // testdata//
+// // ConfigDirectory: config.TestStepDirectory(),
+// Config: configResources(instanceResource["backup_schedule"], &testutils.Region),
+// Check: resource.ComposeAggregateTestCheckFunc(
+// // Instance
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "project_id",
+// instanceResource["project_id"],
+// ),
+// resource.TestCheckResourceAttrSet(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "instance_id",
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "name",
+// instanceResource["name"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "acl.#",
+// "1",
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "acl.0",
+// instanceResource["acl"],
+// ),
+// resource.TestCheckResourceAttrSet(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.id",
+// ),
+// resource.TestCheckResourceAttrSet(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.description",
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "backup_schedule",
+// instanceResource["backup_schedule"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.cpu",
+// instanceResource["flavor_cpu"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.ram",
+// instanceResource["flavor_ram"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "replicas",
+// instanceResource["replicas"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "storage.class",
+// instanceResource["storage_class"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "storage.size",
+// instanceResource["storage_size"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "version",
+// instanceResource["version"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "region",
+// testutils.Region,
+// ),
+//
+// // User
+// resource.TestCheckResourceAttrPair(
+// "stackitprivatepreview_postgresflexalpha_user.user", "project_id",
+// "stackitprivatepreview_postgresflexalpha_instance.instance", "project_id",
+// ),
+// resource.TestCheckResourceAttrPair(
+// "stackitprivatepreview_postgresflexalpha_user.user", "instance_id",
+// "stackitprivatepreview_postgresflexalpha_instance.instance", "instance_id",
+// ),
+// resource.TestCheckResourceAttrSet("stackitprivatepreview_postgresflexalpha_user.user", "user_id"),
+// resource.TestCheckResourceAttrSet("stackitprivatepreview_postgresflexalpha_user.user", "password"),
+//
+// // Database
+// resource.TestCheckResourceAttrPair(
+// "stackitprivatepreview_postgresflexalpha_database.database", "project_id",
+// "stackitprivatepreview_postgresflexalpha_instance.instance", "project_id",
+// ),
+// resource.TestCheckResourceAttrPair(
+// "stackitprivatepreview_postgresflexalpha_database.database", "instance_id",
+// "stackitprivatepreview_postgresflexalpha_instance.instance", "instance_id",
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_database.database",
+// "name",
+// databaseResource["name"],
+// ),
+// resource.TestCheckResourceAttrPair(
+// "stackitprivatepreview_postgresflexalpha_database.database", "owner",
+// "stackitprivatepreview_postgresflexalpha_user.user", "username",
+// ),
+// ),
+// },
+// // data source
+// {
+// Config: fmt.Sprintf(
+// `
+// %s
+//
+// data "stackitprivatepreview_postgresflexalpha_instance" "instance" {
+// project_id = stackitprivatepreview_postgresflexalpha_instance.instance.project_id
+// instance_id = stackitprivatepreview_postgresflexalpha_instance.instance.instance_id
+// }
+//
+// data "stackitprivatepreview_postgresflexalpha_user" "user" {
+// project_id = stackitprivatepreview_postgresflexalpha_instance.instance.project_id
+// instance_id = stackitprivatepreview_postgresflexalpha_instance.instance.instance_id
+// user_id = stackitprivatepreview_postgresflexalpha_user.user.user_id
+// }
+//
+// data "stackitprivatepreview_postgresflexalpha_database" "database" {
+// project_id = stackitprivatepreview_postgresflexalpha_instance.instance.project_id
+// instance_id = stackitprivatepreview_postgresflexalpha_instance.instance.instance_id
+// database_id = stackitprivatepreview_postgresflexalpha_database.database.database_id
+// }
+// `,
+// configResources(instanceResource["backup_schedule"], nil),
+// ),
+// Check: resource.ComposeAggregateTestCheckFunc(
+// // Instance data
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance",
+// "project_id",
+// instanceResource["project_id"],
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance",
+// "name",
+// instanceResource["name"],
+// ),
+// resource.TestCheckResourceAttrPair(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance", "project_id",
+// "stackitprivatepreview_postgresflexalpha_instance.instance", "project_id",
+// ),
+// resource.TestCheckResourceAttrPair(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance", "instance_id",
+// "stackitprivatepreview_postgresflexalpha_instance.instance", "instance_id",
+// ),
+// resource.TestCheckResourceAttrPair(
+// "data.stackitprivatepreview_postgresflexalpha_user.user", "instance_id",
+// "stackitprivatepreview_postgresflexalpha_user.user", "instance_id",
+// ),
+//
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance",
+// "acl.#",
+// "1",
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance",
+// "acl.0",
+// instanceResource["acl"],
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance",
+// "backup_schedule",
+// instanceResource["backup_schedule"],
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.id",
+// instanceResource["flavor_id"],
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.description",
+// instanceResource["flavor_description"],
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.cpu",
+// instanceResource["flavor_cpu"],
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.ram",
+// instanceResource["flavor_ram"],
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_instance.instance",
+// "replicas",
+// instanceResource["replicas"],
+// ),
+//
+// // User data
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_user.user",
+// "project_id",
+// userResource["project_id"],
+// ),
+// resource.TestCheckResourceAttrSet(
+// "data.stackitprivatepreview_postgresflexalpha_user.user",
+// "user_id",
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_user.user",
+// "username",
+// userResource["username"],
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_user.user",
+// "roles.#",
+// "1",
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_user.user",
+// "roles.0",
+// userResource["role"],
+// ),
+// resource.TestCheckResourceAttrSet(
+// "data.stackitprivatepreview_postgresflexalpha_user.user",
+// "host",
+// ),
+// resource.TestCheckResourceAttrSet(
+// "data.stackitprivatepreview_postgresflexalpha_user.user",
+// "port",
+// ),
+//
+// // Database data
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_database.database",
+// "project_id",
+// instanceResource["project_id"],
+// ),
+// resource.TestCheckResourceAttr(
+// "data.stackitprivatepreview_postgresflexalpha_database.database",
+// "name",
+// databaseResource["name"],
+// ),
+// resource.TestCheckResourceAttrPair(
+// "data.stackitprivatepreview_postgresflexalpha_database.database",
+// "instance_id",
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "instance_id",
+// ),
+// resource.TestCheckResourceAttrPair(
+// "data.stackitprivatepreview_postgresflexalpha_database.database",
+// "owner",
+// "data.stackitprivatepreview_postgresflexalpha_user.user",
+// "username",
+// ),
+// ),
+// },
+// // Import
+// {
+// ResourceName: "stackitprivatepreview_postgresflexalpha_instance.instance",
+// ImportStateIdFunc: func(s *terraform.State) (string, error) {
+// r, ok := s.RootModule().Resources["stackitprivatepreview_postgresflexalpha_instance.instance"]
+// if !ok {
+// return "", fmt.Errorf("couldn't find resource stackitprivatepreview_postgresflexalpha_instance.instance")
+// }
+// instanceId, ok := r.Primary.Attributes["instance_id"]
+// if !ok {
+// return "", fmt.Errorf("couldn't find attribute instance_id")
+// }
+//
+// return fmt.Sprintf("%s,%s,%s", testutils.ProjectId, testutils.Region, instanceId), nil
+// },
+// ImportState: true,
+// ImportStateVerify: true,
+// ImportStateVerifyIgnore: []string{"password"},
+// },
+// {
+// ResourceName: "stackitprivatepreview_postgresflexalpha_user.user",
+// ImportStateIdFunc: func(s *terraform.State) (string, error) {
+// r, ok := s.RootModule().Resources["stackitprivatepreview_postgresflexalpha_user.user"]
+// if !ok {
+// return "", fmt.Errorf("couldn't find resource stackitprivatepreview_postgresflexalpha_user.user")
+// }
+// instanceId, ok := r.Primary.Attributes["instance_id"]
+// if !ok {
+// return "", fmt.Errorf("couldn't find attribute instance_id")
+// }
+// userId, ok := r.Primary.Attributes["user_id"]
+// if !ok {
+// return "", fmt.Errorf("couldn't find attribute user_id")
+// }
+//
+// return fmt.Sprintf("%s,%s,%s,%s", testutils.ProjectId, testutils.Region, instanceId, userId), nil
+// },
+// ImportState: true,
+// ImportStateVerify: true,
+// ImportStateVerifyIgnore: []string{"password", "uri"},
+// },
+// {
+// ResourceName: "stackitprivatepreview_postgresflexalpha_database.database",
+// ImportStateIdFunc: func(s *terraform.State) (string, error) {
+// r, ok := s.RootModule().Resources["stackitprivatepreview_postgresflexalpha_database.database"]
+// if !ok {
+// return "", fmt.Errorf("couldn't find resource stackitprivatepreview_postgresflexalpha_database.database")
+// }
+// instanceId, ok := r.Primary.Attributes["instance_id"]
+// if !ok {
+// return "", fmt.Errorf("couldn't find attribute instance_id")
+// }
+// databaseId, ok := r.Primary.Attributes["database_id"]
+// if !ok {
+// return "", fmt.Errorf("couldn't find attribute database_id")
+// }
+//
+// return fmt.Sprintf(
+// "%s,%s,%s,%s",
+// testutils.ProjectId,
+// testutils.Region,
+// instanceId,
+// databaseId,
+// ), nil
+// },
+// ImportState: true,
+// ImportStateVerify: true,
+// },
+// // Update
+// {
+// Config: configResources(instanceResource["backup_schedule_updated"], nil),
+// Check: resource.ComposeAggregateTestCheckFunc(
+// // Instance data
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "project_id",
+// instanceResource["project_id"],
+// ),
+// resource.TestCheckResourceAttrSet(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "instance_id",
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "name",
+// instanceResource["name"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "acl.#",
+// "1",
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "acl.0",
+// instanceResource["acl"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "backup_schedule",
+// instanceResource["backup_schedule_updated"],
+// ),
+// resource.TestCheckResourceAttrSet(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.id",
+// ),
+// resource.TestCheckResourceAttrSet(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.description",
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.cpu",
+// instanceResource["flavor_cpu"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "flavor.ram",
+// instanceResource["flavor_ram"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "replicas",
+// instanceResource["replicas"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "storage.class",
+// instanceResource["storage_class"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "storage.size",
+// instanceResource["storage_size"],
+// ),
+// resource.TestCheckResourceAttr(
+// "stackitprivatepreview_postgresflexalpha_instance.instance",
+// "version",
+// instanceResource["version"],
+// ),
+// ),
+// },
+// // Deletion is done by the framework implicitly
+// },
+// },
+// )
+//}
+//
+// func testAccCheckPostgresFlexDestroy(s *terraform.State) error {
+// ctx := context.Background()
+// var client *postgresflex.APIClient
+// var err error
+// if testutils.PostgresFlexCustomEndpoint == "" {
+// client, err = postgresflex.NewAPIClient()
+// } else {
+// client, err = postgresflex.NewAPIClient(
+// config.WithEndpoint(testutils.PostgresFlexCustomEndpoint),
+// )
+// }
+// if err != nil {
+// return fmt.Errorf("creating client: %w", err)
+// }
+//
+// instancesToDestroy := []string{}
+// for _, rs := range s.RootModule().Resources {
+// if rs.Type != "stackitprivatepreview_postgresflexalpha_instance" {
+// continue
+// }
+// // instance terraform ID: = "[project_id],[region],[instance_id]"
+// instanceId := strings.Split(rs.Primary.ID, core.Separator)[2]
+// instancesToDestroy = append(instancesToDestroy, instanceId)
+// }
+//
+// instancesResp, err := client.ListInstancesRequest(ctx, testutils.ProjectId, testutils.Region).Execute()
+// if err != nil {
+// return fmt.Errorf("getting instancesResp: %w", err)
+// }
+//
+// items := *instancesResp.Instances
+// for i := range items {
+// if items[i].Id == nil {
+// continue
+// }
+// if utils.Contains(instancesToDestroy, *items[i].Id) {
+// // TODO @mhenselin - does force still exist?
+// err := client.DeleteInstanceRequestExecute(ctx, testutils.ProjectId, testutils.Region, *items[i].Id)
+// if err != nil {
+// return fmt.Errorf("deleting instance %s during CheckDestroy: %w", *items[i].Id, err)
+// }
+// }
+// }
+// return nil
+//}
diff --git a/stackit/internal/services/postgresflexalpha/role/datasources_gen/roles_data_source_gen.go b/stackit/internal/services/postgresflexalpha/role/datasources_gen/roles_data_source_gen.go
new file mode 100644
index 00000000..415f0647
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/role/datasources_gen/roles_data_source_gen.go
@@ -0,0 +1,52 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func RolesDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "roles": schema.ListAttribute{
+ ElementType: types.StringType,
+ Computed: true,
+ Description: "List of all role names available in the instance",
+ MarkdownDescription: "List of all role names available in the instance",
+ },
+ },
+ }
+}
+
+type RolesModel struct {
+ InstanceId types.String `tfsdk:"instance_id"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Roles types.List `tfsdk:"roles"`
+}
diff --git a/stackit/internal/services/postgresflexalpha/testdata/instance_template.gompl b/stackit/internal/services/postgresflexalpha/testdata/instance_template.gompl
new file mode 100644
index 00000000..260f0b57
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/testdata/instance_template.gompl
@@ -0,0 +1,54 @@
+provider "stackitprivatepreview" {
+ default_region = "{{ .Region }}"
+ service_account_key_path = "{{ .ServiceAccountFilePath }}"
+}
+
+resource "stackitprivatepreview_postgresflexalpha_instance" "{{ .TfName }}" {
+ project_id = "{{ .ProjectId }}"
+ name = "{{ .Name }}"
+ backup_schedule = "{{ .BackupSchedule }}"
+ retention_days = {{ .RetentionDays }}
+ flavor_id = "{{ .FlavorId }}"
+ replicas = {{ .Replicas }}
+ storage = {
+ performance_class = "{{ .PerformanceClass }}"
+ size = {{ .Size }}
+ }
+{{ if .UseEncryption }}
+ encryption = {
+ kek_key_id = {{ .KekKeyId }}
+ kek_key_ring_id = {{ .KekKeyRingId }}
+ kek_key_version = {{ .KekKeyVersion }}
+ service_account = "{{ .KekServiceAccount }}"
+ }
+{{ end }}
+ network = {
+ acl = ["{{ .AclString }}"]
+ access_scope = "{{ .AccessScope }}"
+ }
+ version = {{ .Version }}
+}
+
+{{ if .Users }}
+{{ $tfName := .TfName }}
+{{ range $user := .Users }}
+resource "stackitprivatepreview_postgresflexalpha_user" "{{ $user.Name }}" {
+ project_id = "{{ $user.ProjectId }}"
+ instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.instance_id
+ name = "{{ $user.Name }}"
+ roles = [{{ range $i, $v := $user.Roles }}{{if $i}},{{end}}"{{$v}}"{{end}}]
+}
+{{ end }}
+{{ end }}
+
+{{ if .Databases }}
+{{ $tfName := .TfName }}
+{{ range $db := .Databases }}
+resource "stackitprivatepreview_postgresflexalpha_database" "{{ $db.Name }}" {
+ project_id = "{{ $db.ProjectId }}"
+ instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.instance_id
+ name = "{{ $db.Name }}"
+ owner = stackitprivatepreview_postgresflexalpha_user.{{ $db.Owner }}.name
+}
+{{ end }}
+{{ end }}
diff --git a/stackit/internal/services/postgresflexalpha/testdata/resource-enc.tf b/stackit/internal/services/postgresflexalpha/testdata/resource-enc.tf
new file mode 100644
index 00000000..65fd46d9
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/testdata/resource-enc.tf
@@ -0,0 +1,27 @@
+variable "project_id" {}
+variable "kek_key_id" {}
+variable "kek_key_ring_id" {}
+
+resource "stackitprivatepreview_postgresflexalpha_instance" "msh-instance-only" {
+ project_id = var.project_id
+ name = "example-instance"
+ backup_schedule = "0 0 * * *"
+ retention_days = 30
+ flavor_id = "2.4"
+ replicas = 1
+ storage = {
+ performance_class = "premium-perf2-stackit"
+ size = 10
+ }
+ encryption = {
+ kek_key_id = var.kek_key_id
+ kek_key_ring_id = var.kek_key_ring_id
+ kek_key_version = 1
+ service_account = "service@account.email"
+ }
+ network = {
+ acl = ["0.0.0.0/0"]
+ access_scope = "PUBLIC"
+ }
+ version = 17
+}
diff --git a/stackit/internal/services/postgresflexalpha/testdata/resource-no-enc.tf b/stackit/internal/services/postgresflexalpha/testdata/resource-no-enc.tf
new file mode 100644
index 00000000..8e81b998
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/testdata/resource-no-enc.tf
@@ -0,0 +1,19 @@
+variable "project_id" {}
+
+resource "stackitprivatepreview_postgresflexalpha_instance" "msh-instance-only" {
+ project_id = var.project_id
+ name = "example-instance"
+ backup_schedule = "0 0 * * *"
+ retention_days = 30
+ flavor_id = "2.4"
+ replicas = 1
+ storage = {
+ performance_class = "premium-perf2-stackit"
+ size = 10
+ }
+ network = {
+ acl = ["0.0.0.0/0"]
+ access_scope = "PUBLIC"
+ }
+ version = 17
+}
diff --git a/stackit/internal/services/postgresflexalpha/user/datasource.go b/stackit/internal/services/postgresflexalpha/user/datasource.go
index 79861e19..0bb991df 100644
--- a/stackit/internal/services/postgresflexalpha/user/datasource.go
+++ b/stackit/internal/services/postgresflexalpha/user/datasource.go
@@ -1,26 +1,25 @@
-// Copyright (c) STACKIT
-
-package postgresflexa
+package postgresflexalpha
import (
"context"
"fmt"
+ "math"
"net/http"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- postgresflexUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflex/utils"
-
- "github.com/hashicorp/terraform-plugin-framework/attr"
- "github.com/hashicorp/terraform-plugin-framework/datasource"
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
-
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ postgresflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user/datasources_gen"
+ postgresflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/utils"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
)
// Ensure the implementation satisfies the expected interfaces.
@@ -28,23 +27,17 @@ var (
_ datasource.DataSource = &userDataSource{}
)
-type DataSourceModel struct {
- Id types.String `tfsdk:"id"` // needed by TF
- UserId types.String `tfsdk:"user_id"`
- InstanceId types.String `tfsdk:"instance_id"`
- ProjectId types.String `tfsdk:"project_id"`
- Username types.String `tfsdk:"username"`
- Roles types.Set `tfsdk:"roles"`
- Host types.String `tfsdk:"host"`
- Port types.Int64 `tfsdk:"port"`
- Region types.String `tfsdk:"region"`
-}
-
// NewUserDataSource is a helper function to simplify the provider implementation.
func NewUserDataSource() datasource.DataSource {
return &userDataSource{}
}
+// dataSourceModel maps the data source schema data.
+type dataSourceModel struct {
+ postgresflexalpha.UserModel
+ TerraformID types.String `tfsdk:"id"`
+}
+
// userDataSource is the data source implementation.
type userDataSource struct {
client *postgresflex.APIClient
@@ -52,12 +45,20 @@ type userDataSource struct {
}
// Metadata returns the data source type name.
-func (r *userDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
- resp.TypeName = req.ProviderTypeName + "_postgresflex_user"
+func (r *userDataSource) Metadata(
+ _ context.Context,
+ req datasource.MetadataRequest,
+ resp *datasource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_postgresflexalpha_user"
}
// Configure adds the provider configured client to the data source.
-func (r *userDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
+func (r *userDataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
var ok bool
r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
if !ok {
@@ -73,71 +74,25 @@ func (r *userDataSource) Configure(ctx context.Context, req datasource.Configure
}
// Schema defines the schema for the data source.
-func (r *userDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
- descriptions := map[string]string{
- "main": "Postgres Flex user data source schema. Must have a `region` specified in the provider configuration.",
- "id": "Terraform's internal data source. ID. It is structured as \"`project_id`,`region`,`instance_id`,`user_id`\".",
- "user_id": "User ID.",
- "instance_id": "ID of the PostgresFlex instance.",
- "project_id": "STACKIT project ID to which the instance is associated.",
- "region": "The resource region. If not defined, the provider region is used.",
+func (r *userDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ s := postgresflexalpha.UserDataSourceSchema(ctx)
+ s.Attributes["id"] = schema.StringAttribute{
+ Description: "Terraform's internal resource ID. It is structured as \\\"`project_id`,`region`,`instance_id`," +
+ "`user_id`\\\".\",",
+ Optional: true,
+ Computed: true,
}
- resp.Schema = schema.Schema{
- Description: descriptions["main"],
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Description: descriptions["id"],
- Computed: true,
- },
- "user_id": schema.StringAttribute{
- Description: descriptions["user_id"],
- Required: true,
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- "instance_id": schema.StringAttribute{
- Description: descriptions["instance_id"],
- Required: true,
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "project_id": schema.StringAttribute{
- Description: descriptions["project_id"],
- Required: true,
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "username": schema.StringAttribute{
- Computed: true,
- },
- "roles": schema.SetAttribute{
- ElementType: types.StringType,
- Computed: true,
- },
- "host": schema.StringAttribute{
- Computed: true,
- },
- "port": schema.Int64Attribute{
- Computed: true,
- },
- "region": schema.StringAttribute{
- // the region cannot be found automatically, so it has to be passed
- Optional: true,
- Description: descriptions["region"],
- },
- },
- }
+ resp.Schema = s
}
// Read refreshes the Terraform state with the latest data.
-func (r *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
- var model DataSourceModel
+func (r *userDataSource) Read(
+ ctx context.Context,
+ req datasource.ReadRequest,
+ resp *datasource.ReadResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model dataSourceModel
diags := req.Config.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -148,25 +103,22 @@ func (r *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
projectId := model.ProjectId.ValueString()
instanceId := model.InstanceId.ValueString()
- userId := model.UserId.ValueString()
+ userId64 := model.UserId.ValueInt64()
+ if userId64 > math.MaxInt32 {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (userId)")
+ return
+ }
+ userId := int32(userId64) // nolint:gosec // check is performed above
+
region := r.providerData.GetRegionWithOverride(model.Region)
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "instance_id", instanceId)
- ctx = tflog.SetField(ctx, "user_id", userId)
ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "user_id", userId)
- recordSetResp, err := r.client.GetUser(ctx, projectId, region, instanceId, userId).Execute()
+ recordSetResp, err := r.client.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute()
if err != nil {
- utils.LogError(
- ctx,
- &resp.Diagnostics,
- err,
- "Reading user",
- fmt.Sprintf("User with ID %q or instance with ID %q does not exist in project %q.", userId, instanceId, projectId),
- map[int]string{
- http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId),
- },
- )
+ handleReadError(ctx, &diags, err, projectId, instanceId, userId)
resp.State.RemoveResource(ctx)
return
}
@@ -176,7 +128,12 @@ func (r *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
// Map response body to schema and populate Computed attribute values
err = mapDataSourceFields(recordSetResp, &model, region)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading user", fmt.Sprintf("Processing API payload: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading user",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
return
}
@@ -189,44 +146,38 @@ func (r *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
tflog.Info(ctx, "Postgres Flex user read")
}
-func mapDataSourceFields(userResp *postgresflex.GetUserResponse, model *DataSourceModel, region string) error {
- if userResp == nil || userResp.Item == nil {
- return fmt.Errorf("response is nil")
- }
- if model == nil {
- return fmt.Errorf("model input is nil")
- }
- user := userResp.Item
-
- var userId string
- if model.UserId.ValueString() != "" {
- userId = model.UserId.ValueString()
- } else if user.Id != nil {
- userId = *user.Id
- } else {
- return fmt.Errorf("user id not present")
- }
- model.Id = utils.BuildInternalTerraformId(
- model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), userId,
+// handleReadError centralizes API error handling for the Read operation.
+func handleReadError(
+ ctx context.Context,
+ diags *diag.Diagnostics,
+ err error,
+ projectId, instanceId string,
+ userId int32,
+) {
+ utils.LogError(
+ ctx,
+ diags,
+ err,
+ "Reading user",
+ fmt.Sprintf(
+ "User with ID %q or instance with ID %q does not exist in project %q.",
+ userId,
+ instanceId,
+ projectId,
+ ),
+ map[int]string{
+ http.StatusBadRequest: fmt.Sprintf(
+ "Invalid user request parameters for project %q and instance %q.",
+ projectId,
+ instanceId,
+ ),
+ http.StatusNotFound: fmt.Sprintf(
+ "User, instance %q, or project %q or user %q not found.",
+ instanceId,
+ projectId,
+ userId,
+ ),
+ http.StatusForbidden: fmt.Sprintf("Forbidden access to project %q.", projectId),
+ },
)
- model.UserId = types.StringValue(userId)
- model.Username = types.StringPointerValue(user.Username)
-
- if user.Roles == nil {
- model.Roles = types.SetNull(types.StringType)
- } else {
- roles := []attr.Value{}
- for _, role := range *user.Roles {
- roles = append(roles, types.StringValue(role))
- }
- rolesSet, diags := types.SetValue(types.StringType, roles)
- if diags.HasError() {
- return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
- }
- model.Roles = rolesSet
- }
- model.Host = types.StringPointerValue(user.Host)
- model.Port = types.Int64PointerValue(user.Port)
- model.Region = types.StringValue(region)
- return nil
}
diff --git a/stackit/internal/services/postgresflexalpha/user/datasource_test.go b/stackit/internal/services/postgresflexalpha/user/datasource_test.go
deleted file mode 100644
index d49ef243..00000000
--- a/stackit/internal/services/postgresflexalpha/user/datasource_test.go
+++ /dev/null
@@ -1,146 +0,0 @@
-// Copyright (c) STACKIT
-
-package postgresflexa
-
-import (
- "testing"
-
- "github.com/google/go-cmp/cmp"
- "github.com/hashicorp/terraform-plugin-framework/attr"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/stackit-sdk-go/core/utils"
- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
-)
-
-func TestMapDataSourceFields(t *testing.T) {
- const testRegion = "region"
- tests := []struct {
- description string
- input *postgresflex.GetUserResponse
- region string
- expected DataSourceModel
- isValid bool
- }{
- {
- "default_values",
- &postgresflex.GetUserResponse{
- Item: &postgresflex.UserResponse{},
- },
- testRegion,
- DataSourceModel{
- Id: types.StringValue("pid,region,iid,uid"),
- UserId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringNull(),
- Roles: types.SetNull(types.StringType),
- Host: types.StringNull(),
- Port: types.Int64Null(),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "simple_values",
- &postgresflex.GetUserResponse{
- Item: &postgresflex.UserResponse{
- Roles: &[]string{
- "role_1",
- "role_2",
- "",
- },
- Username: utils.Ptr("username"),
- Host: utils.Ptr("host"),
- Port: utils.Ptr(int64(1234)),
- },
- },
- testRegion,
- DataSourceModel{
- Id: types.StringValue("pid,region,iid,uid"),
- UserId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringValue("username"),
- Roles: types.SetValueMust(types.StringType, []attr.Value{
- types.StringValue("role_1"),
- types.StringValue("role_2"),
- types.StringValue(""),
- }),
- Host: types.StringValue("host"),
- Port: types.Int64Value(1234),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "null_fields_and_int_conversions",
- &postgresflex.GetUserResponse{
- Item: &postgresflex.UserResponse{
- Id: utils.Ptr("uid"),
- Roles: &[]string{},
- Username: nil,
- Host: nil,
- Port: utils.Ptr(int64(2123456789)),
- },
- },
- testRegion,
- DataSourceModel{
- Id: types.StringValue("pid,region,iid,uid"),
- UserId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringNull(),
- Roles: types.SetValueMust(types.StringType, []attr.Value{}),
- Host: types.StringNull(),
- Port: types.Int64Value(2123456789),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "nil_response",
- nil,
- testRegion,
- DataSourceModel{},
- false,
- },
- {
- "nil_response_2",
- &postgresflex.GetUserResponse{},
- testRegion,
- DataSourceModel{},
- false,
- },
- {
- "no_resource_id",
- &postgresflex.GetUserResponse{
- Item: &postgresflex.UserResponse{},
- },
- testRegion,
- DataSourceModel{},
- false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.description, func(t *testing.T) {
- state := &DataSourceModel{
- ProjectId: tt.expected.ProjectId,
- InstanceId: tt.expected.InstanceId,
- UserId: tt.expected.UserId,
- }
- err := mapDataSourceFields(tt.input, state, tt.region)
- if !tt.isValid && err == nil {
- t.Fatalf("Should have failed")
- }
- if tt.isValid && err != nil {
- t.Fatalf("Should not have failed: %v", err)
- }
- if tt.isValid {
- diff := cmp.Diff(state, &tt.expected)
- if diff != "" {
- t.Fatalf("Data does not match: %s", diff)
- }
- }
- })
- }
-}
diff --git a/stackit/internal/services/postgresflexalpha/user/datasources_gen/user_data_source_gen.go b/stackit/internal/services/postgresflexalpha/user/datasources_gen/user_data_source_gen.go
new file mode 100644
index 00000000..29a7cca0
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/user/datasources_gen/user_data_source_gen.go
@@ -0,0 +1,76 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func UserDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "tf_original_api_id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The ID of the user.",
+ MarkdownDescription: "The ID of the user.",
+ },
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the user.",
+ MarkdownDescription: "The name of the user.",
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "roles": schema.ListAttribute{
+ ElementType: types.StringType,
+ Computed: true,
+ Description: "A list of user roles.",
+ MarkdownDescription: "A list of user roles.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ Description: "The current status of the user.",
+ MarkdownDescription: "The current status of the user.",
+ },
+ "user_id": schema.Int64Attribute{
+ Required: true,
+ Description: "The ID of the user.",
+ MarkdownDescription: "The ID of the user.",
+ },
+ },
+ }
+}
+
+type UserModel struct {
+ Id types.Int64 `tfsdk:"tf_original_api_id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Name types.String `tfsdk:"name"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Roles types.List `tfsdk:"roles"`
+ Status types.String `tfsdk:"status"`
+ UserId types.Int64 `tfsdk:"user_id"`
+}
diff --git a/stackit/internal/services/postgresflexalpha/user/datasources_gen/users_data_source_gen.go b/stackit/internal/services/postgresflexalpha/user/datasources_gen/users_data_source_gen.go
new file mode 100644
index 00000000..bc83be6b
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/user/datasources_gen/users_data_source_gen.go
@@ -0,0 +1,1116 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func UsersDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the users to be returned on each page.",
+ MarkdownDescription: "Sorting of the users to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "id.asc",
+ "id.desc",
+ "name.desc",
+ "name.asc",
+ "status.desc",
+ "status.asc",
+ ),
+ },
+ },
+ "users": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The ID of the user.",
+ MarkdownDescription: "The ID of the user.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the user.",
+ MarkdownDescription: "The name of the user.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ Description: "The current status of the user.",
+ MarkdownDescription: "The current status of the user.",
+ },
+ },
+ CustomType: UsersType{
+ ObjectType: types.ObjectType{
+ AttrTypes: UsersValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of all users inside an instance",
+ MarkdownDescription: "List of all users inside an instance",
+ },
+ },
+ }
+}
+
+type UsersModel struct {
+ InstanceId types.String `tfsdk:"instance_id"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+ Users types.List `tfsdk:"users"`
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
+
+var _ basetypes.ObjectTypable = UsersType{}
+
+type UsersType struct {
+ basetypes.ObjectType
+}
+
+func (t UsersType) Equal(o attr.Type) bool {
+ other, ok := o.(UsersType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t UsersType) String() string {
+ return "UsersType"
+}
+
+func (t UsersType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return nil, diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return nil, diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return UsersValue{
+ Id: idVal,
+ Name: nameVal,
+ Status: statusVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewUsersValueNull() UsersValue {
+ return UsersValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewUsersValueUnknown() UsersValue {
+ return UsersValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewUsersValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (UsersValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing UsersValue Attribute Value",
+ "While creating a UsersValue value, a missing attribute value was detected. "+
+ "A UsersValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("UsersValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid UsersValue Attribute Type",
+ "While creating a UsersValue value, an invalid attribute value was detected. "+
+ "A UsersValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("UsersValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("UsersValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra UsersValue Attribute Value",
+ "While creating a UsersValue value, an extra attribute value was detected. "+
+ "A UsersValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra UsersValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewUsersValueUnknown(), diags
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewUsersValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return NewUsersValueUnknown(), diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return NewUsersValueUnknown(), diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ if diags.HasError() {
+ return NewUsersValueUnknown(), diags
+ }
+
+ return UsersValue{
+ Id: idVal,
+ Name: nameVal,
+ Status: statusVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewUsersValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) UsersValue {
+ object, diags := NewUsersValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewUsersValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t UsersType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewUsersValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewUsersValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewUsersValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewUsersValueMust(UsersValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t UsersType) ValueType(ctx context.Context) attr.Value {
+ return UsersValue{}
+}
+
+var _ basetypes.ObjectValuable = UsersValue{}
+
+type UsersValue struct {
+ Id basetypes.Int64Value `tfsdk:"id"`
+ Name basetypes.StringValue `tfsdk:"name"`
+ Status basetypes.StringValue `tfsdk:"status"`
+ state attr.ValueState
+}
+
+func (v UsersValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 3)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["id"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["name"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["status"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 3)
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.Name.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["name"] = val
+
+ val, err = v.Status.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["status"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v UsersValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v UsersValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v UsersValue) String() string {
+ return "UsersValue"
+}
+
+func (v UsersValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "id": basetypes.Int64Type{},
+ "name": basetypes.StringType{},
+ "status": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "id": v.Id,
+ "name": v.Name,
+ "status": v.Status,
+ })
+
+ return objVal, diags
+}
+
+func (v UsersValue) Equal(o attr.Value) bool {
+ other, ok := o.(UsersValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.Name.Equal(other.Name) {
+ return false
+ }
+
+ if !v.Status.Equal(other.Status) {
+ return false
+ }
+
+ return true
+}
+
+func (v UsersValue) Type(ctx context.Context) attr.Type {
+ return UsersType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v UsersValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "id": basetypes.Int64Type{},
+ "name": basetypes.StringType{},
+ "status": basetypes.StringType{},
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/user/mapper.go b/stackit/internal/services/postgresflexalpha/user/mapper.go
new file mode 100644
index 00000000..952235ca
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/user/mapper.go
@@ -0,0 +1,142 @@
+package postgresflexalpha
+
+import (
+ "fmt"
+ "strconv"
+
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+// mapDataSourceFields maps API response to data source model, preserving existing ID.
+func mapDataSourceFields(userResp *postgresflex.GetUserResponse, model *dataSourceModel, region string) error {
+ if userResp == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if model == nil {
+ return fmt.Errorf("model input is nil")
+ }
+ user := userResp
+
+ var userId int64
+ if model.UserId.ValueInt64() != 0 {
+ userId = model.UserId.ValueInt64()
+ } else if user.Id != nil {
+ userId = *user.Id
+ } else {
+ return fmt.Errorf("user id not present")
+ }
+
+ model.TerraformID = utils.BuildInternalTerraformId(
+ model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), strconv.FormatInt(userId, 10),
+ )
+
+ model.UserId = types.Int64Value(userId)
+ model.Name = types.StringValue(user.GetName())
+
+ if user.Roles == nil {
+ model.Roles = types.List(types.SetNull(types.StringType))
+ } else {
+ var roles []attr.Value
+ for _, role := range *user.Roles {
+ roles = append(roles, types.StringValue(string(role)))
+ }
+ rolesSet, diags := types.SetValue(types.StringType, roles)
+ if diags.HasError() {
+ return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
+ }
+ model.Roles = types.List(rolesSet)
+ }
+
+ model.Id = types.Int64Value(userId)
+ model.Region = types.StringValue(region)
+ model.Status = types.StringValue(user.GetStatus())
+ return nil
+}
+
+// toPayloadRoles converts a string slice to the API's role type.
+func toPayloadRoles(roles *[]string) *[]postgresflex.UserRole {
+ var userRoles = make([]postgresflex.UserRole, 0, len(*roles))
+ for _, role := range *roles {
+ userRoles = append(userRoles, postgresflex.UserRole(role))
+ }
+ return &userRoles
+}
+
+// toUpdatePayload creates an API update payload from the resource model.
+func toUpdatePayload(model *resourceModel, roles *[]string) (
+ *postgresflex.UpdateUserRequestPayload,
+ error,
+) {
+ if model == nil {
+ return nil, fmt.Errorf("nil model")
+ }
+ if roles == nil {
+ return nil, fmt.Errorf("nil roles")
+ }
+
+ return &postgresflex.UpdateUserRequestPayload{
+ Name: model.Name.ValueStringPointer(),
+ Roles: toPayloadRoles(roles),
+ }, nil
+}
+
+// toCreatePayload creates an API create payload from the resource model.
+func toCreatePayload(model *resourceModel, roles *[]string) (*postgresflex.CreateUserRequestPayload, error) {
+ if model == nil {
+ return nil, fmt.Errorf("nil model")
+ }
+ if roles == nil {
+ return nil, fmt.Errorf("nil roles")
+ }
+
+ return &postgresflex.CreateUserRequestPayload{
+ Roles: toPayloadRoles(roles),
+ Name: model.Name.ValueStringPointer(),
+ }, nil
+}
+
+// mapResourceFields maps API response to the resource model, preserving existing ID.
+func mapResourceFields(userResp *postgresflex.GetUserResponse, model *resourceModel, region string) error {
+ if userResp == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if model == nil {
+ return fmt.Errorf("model input is nil")
+ }
+ user := userResp
+
+ var userId int64
+ if !model.UserId.IsNull() && !model.UserId.IsUnknown() && model.UserId.ValueInt64() != 0 {
+ userId = model.UserId.ValueInt64()
+ } else if user.Id != nil {
+ userId = *user.Id
+ } else {
+ return fmt.Errorf("user id not present")
+ }
+
+ model.Id = types.Int64Value(userId)
+ model.UserId = types.Int64Value(userId)
+ model.Name = types.StringPointerValue(user.Name)
+
+ if user.Roles == nil {
+ model.Roles = types.List(types.SetNull(types.StringType))
+ } else {
+ var roles []attr.Value
+ for _, role := range *user.Roles {
+ roles = append(roles, types.StringValue(string(role)))
+ }
+ rolesSet, diags := types.SetValue(types.StringType, roles)
+ if diags.HasError() {
+ return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
+ }
+ model.Roles = types.List(rolesSet)
+ }
+ model.Region = types.StringValue(region)
+ model.Status = types.StringPointerValue(user.Status)
+ return nil
+}
diff --git a/stackit/internal/services/postgresflexalpha/user/mapper_test.go b/stackit/internal/services/postgresflexalpha/user/mapper_test.go
new file mode 100644
index 00000000..5014d4ac
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/user/mapper_test.go
@@ -0,0 +1,572 @@
+package postgresflexalpha
+
+import (
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ data "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user/datasources_gen"
+)
+
+func TestMapDataSourceFields(t *testing.T) {
+ const testRegion = "region"
+ tests := []struct {
+ description string
+ input *postgresflex.GetUserResponse
+ region string
+ expected dataSourceModel
+ isValid bool
+ }{
+ {
+ "default_values",
+ &postgresflex.GetUserResponse{},
+ testRegion,
+ dataSourceModel{
+ UserModel: data.UserModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Name: types.StringValue(""),
+ Roles: types.List(types.SetNull(types.StringType)),
+ Status: types.StringValue(""),
+ Region: types.StringValue(testRegion),
+ },
+ TerraformID: types.StringValue("pid,region,iid,1"),
+ },
+ true,
+ },
+ {
+ "simple_values",
+ &postgresflex.GetUserResponse{
+ Roles: &[]postgresflex.UserRole{
+ "role_1",
+ "role_2",
+ "",
+ },
+ Name: utils.Ptr("username"),
+ },
+ testRegion,
+ dataSourceModel{
+ UserModel: data.UserModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Name: types.StringValue("username"),
+ Roles: types.List(
+ types.SetValueMust(
+ types.StringType, []attr.Value{
+ types.StringValue("role_1"),
+ types.StringValue("role_2"),
+ types.StringValue(""),
+ },
+ ),
+ ),
+ Region: types.StringValue(testRegion),
+ Status: types.StringValue(""),
+ },
+ TerraformID: types.StringValue("pid,region,iid,1"),
+ },
+ true,
+ },
+ {
+ "null_fields_and_int_conversions",
+ &postgresflex.GetUserResponse{
+ Id: utils.Ptr(int64(1)),
+ Roles: &[]postgresflex.UserRole{},
+ Name: nil,
+ Status: utils.Ptr("status"),
+ },
+ testRegion,
+ dataSourceModel{
+ UserModel: data.UserModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Name: types.StringValue(""),
+ Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
+ Region: types.StringValue(testRegion),
+ Status: types.StringValue("status"),
+ },
+ TerraformID: types.StringValue("pid,region,iid,1"),
+ },
+ true,
+ },
+ {
+ "nil_response",
+ nil,
+ testRegion,
+ dataSourceModel{},
+ false,
+ },
+ {
+ "nil_response_2",
+ &postgresflex.GetUserResponse{},
+ testRegion,
+ dataSourceModel{},
+ false,
+ },
+ {
+ "no_resource_id",
+ &postgresflex.GetUserResponse{},
+ testRegion,
+ dataSourceModel{},
+ false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ state := &dataSourceModel{
+ UserModel: data.UserModel{
+ ProjectId: tt.expected.ProjectId,
+ InstanceId: tt.expected.InstanceId,
+ UserId: tt.expected.UserId,
+ },
+ }
+ err := mapDataSourceFields(tt.input, state, tt.region)
+ if !tt.isValid && err == nil {
+ t.Fatalf("Should have failed")
+ }
+ if tt.isValid && err != nil {
+ t.Fatalf("Should not have failed: %v", err)
+ }
+ if tt.isValid {
+ diff := cmp.Diff(state, &tt.expected)
+ if diff != "" {
+ t.Fatalf("Data does not match: %s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestMapFieldsCreate(t *testing.T) {
+ const testRegion = "region"
+ tests := []struct {
+ description string
+ input *postgresflex.GetUserResponse
+ region string
+ expected resourceModel
+ isValid bool
+ }{
+ {
+ "default_values",
+ &postgresflex.GetUserResponse{
+ Id: utils.Ptr(int64(1)),
+ },
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Name: types.StringNull(),
+ Roles: types.List(types.SetNull(types.StringType)),
+ Password: types.StringNull(),
+ Region: types.StringValue(testRegion),
+ Status: types.StringNull(),
+ //ConnectionString: types.StringNull(),
+ },
+ true,
+ },
+ {
+ "simple_values",
+ &postgresflex.GetUserResponse{
+ Id: utils.Ptr(int64(1)),
+ Name: utils.Ptr("username"),
+ Status: utils.Ptr("status"),
+ },
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Name: types.StringValue("username"),
+ Roles: types.List(types.SetNull(types.StringType)),
+ Password: types.StringNull(),
+ Region: types.StringValue(testRegion),
+ Status: types.StringValue("status"),
+ //ConnectionString: types.StringNull(),
+ },
+ true,
+ },
+ {
+ "null_fields_and_int_conversions",
+ &postgresflex.GetUserResponse{
+ Id: utils.Ptr(int64(1)),
+ Name: nil,
+ Status: nil,
+ },
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Name: types.StringNull(),
+ Roles: types.List(types.SetNull(types.StringType)),
+ Password: types.StringNull(),
+ Region: types.StringValue(testRegion),
+ Status: types.StringNull(),
+ //ConnectionString: types.StringNull(),
+ },
+ true,
+ },
+ {
+ "nil_response",
+ nil,
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ {
+ "nil_response_2",
+ &postgresflex.GetUserResponse{},
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ {
+ "no_resource_id",
+ &postgresflex.GetUserResponse{},
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ state := &resourceModel{
+ ProjectId: tt.expected.ProjectId,
+ InstanceId: tt.expected.InstanceId,
+ }
+
+ err := mapResourceFields(tt.input, state, tt.region)
+ if !tt.isValid && err == nil {
+ t.Fatalf("Should have failed")
+ }
+ if tt.isValid && err != nil {
+ t.Fatalf("Should not have failed: %v", err)
+ }
+ if tt.isValid {
+ diff := cmp.Diff(state, &tt.expected)
+ if diff != "" {
+ t.Fatalf("Data does not match: %s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestMapFields(t *testing.T) {
+ const testRegion = "region"
+ tests := []struct {
+ description string
+ input *postgresflex.GetUserResponse
+ region string
+ expected resourceModel
+ isValid bool
+ }{
+ {
+ "default_values",
+ &postgresflex.GetUserResponse{
+ Id: utils.Ptr(int64(1)),
+ },
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(int64(1)),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Name: types.StringNull(),
+ Roles: types.List(types.SetNull(types.StringType)),
+ Region: types.StringValue(testRegion),
+ Status: types.StringNull(),
+ //ConnectionString: types.StringNull(),
+ },
+ true,
+ },
+ {
+ "simple_values",
+ &postgresflex.GetUserResponse{
+ Id: utils.Ptr(int64(1)),
+ Roles: &[]postgresflex.UserRole{
+ "role_1",
+ "role_2",
+ "",
+ },
+ Name: utils.Ptr("username"),
+ },
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Name: types.StringValue("username"),
+ Roles: types.List(
+ types.SetValueMust(
+ types.StringType, []attr.Value{
+ types.StringValue("role_1"),
+ types.StringValue("role_2"),
+ types.StringValue(""),
+ },
+ ),
+ ),
+ Region: types.StringValue(testRegion),
+ Status: types.StringNull(),
+ //ConnectionString: types.StringNull(),
+ },
+ true,
+ },
+ {
+ "null_fields_and_int_conversions",
+ &postgresflex.GetUserResponse{
+ Id: utils.Ptr(int64(1)),
+ Name: nil,
+ },
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Name: types.StringNull(),
+ Roles: types.List(types.SetNull(types.StringType)),
+ Region: types.StringValue(testRegion),
+ Status: types.StringNull(),
+ //ConnectionString: types.StringNull(),
+ },
+ true,
+ },
+ {
+ "nil_response",
+ nil,
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ {
+ "nil_response_2",
+ &postgresflex.GetUserResponse{},
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ {
+ "no_resource_id",
+ &postgresflex.GetUserResponse{},
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ state := &resourceModel{
+ ProjectId: tt.expected.ProjectId,
+ InstanceId: tt.expected.InstanceId,
+ }
+ err := mapResourceFields(tt.input, state, tt.region)
+ if !tt.isValid && err == nil {
+ t.Fatalf("Should have failed")
+ }
+ if tt.isValid && err != nil {
+ t.Fatalf("Should not have failed: %v", err)
+ }
+ if tt.isValid {
+ diff := cmp.Diff(state, &tt.expected)
+ if diff != "" {
+ t.Fatalf("Data does not match: %s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestToCreatePayload(t *testing.T) {
+ tests := []struct {
+ description string
+ input *resourceModel
+ inputRoles *[]string
+ expected *postgresflex.CreateUserRequestPayload
+ isValid bool
+ }{
+ {
+ "default_values",
+ &resourceModel{},
+ &[]string{},
+ &postgresflex.CreateUserRequestPayload{
+ Name: nil,
+ Roles: &[]postgresflex.UserRole{},
+ },
+ true,
+ },
+ {
+ "simple_values",
+ &resourceModel{
+ Name: types.StringValue("username"),
+ },
+ &[]string{
+ "role_1",
+ "role_2",
+ },
+ &postgresflex.CreateUserRequestPayload{
+ Name: utils.Ptr("username"),
+ Roles: &[]postgresflex.UserRole{
+ "role_1",
+ "role_2",
+ },
+ },
+ true,
+ },
+ {
+ "null_fields_and_int_conversions",
+ &resourceModel{
+ Name: types.StringNull(),
+ },
+ &[]string{
+ "",
+ },
+ &postgresflex.CreateUserRequestPayload{
+ Roles: &[]postgresflex.UserRole{
+ "",
+ },
+ Name: nil,
+ },
+ true,
+ },
+ {
+ "nil_model",
+ nil,
+ &[]string{},
+ nil,
+ false,
+ },
+ {
+ "nil_roles",
+ &resourceModel{},
+ nil,
+ nil,
+ false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ output, err := toCreatePayload(tt.input, tt.inputRoles)
+ if !tt.isValid && err == nil {
+ t.Fatalf("Should have failed")
+ }
+ if tt.isValid && err != nil {
+ t.Fatalf("Should not have failed: %v", err)
+ }
+ if tt.isValid {
+ diff := cmp.Diff(output, tt.expected)
+ if diff != "" {
+ t.Fatalf("Data does not match: %s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestToUpdatePayload(t *testing.T) {
+ tests := []struct {
+ description string
+ input *resourceModel
+ inputRoles *[]string
+ expected *postgresflex.UpdateUserRequestPayload
+ isValid bool
+ }{
+ {
+ "default_values",
+ &resourceModel{},
+ &[]string{},
+ &postgresflex.UpdateUserRequestPayload{
+ Roles: &[]postgresflex.UserRole{},
+ },
+ true,
+ },
+ {
+ "default_values",
+ &resourceModel{
+ Name: types.StringValue("username"),
+ },
+ &[]string{
+ "role_1",
+ "role_2",
+ },
+ &postgresflex.UpdateUserRequestPayload{
+ Name: utils.Ptr("username"),
+ Roles: &[]postgresflex.UserRole{
+ "role_1",
+ "role_2",
+ },
+ },
+ true,
+ },
+ {
+ "null_fields_and_int_conversions",
+ &resourceModel{
+ Name: types.StringNull(),
+ },
+ &[]string{
+ "",
+ },
+ &postgresflex.UpdateUserRequestPayload{
+ Roles: &[]postgresflex.UserRole{
+ "",
+ },
+ },
+ true,
+ },
+ {
+ "nil_model",
+ nil,
+ &[]string{},
+ nil,
+ false,
+ },
+ {
+ "nil_roles",
+ &resourceModel{},
+ nil,
+ nil,
+ false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ output, err := toUpdatePayload(tt.input, tt.inputRoles)
+ if !tt.isValid && err == nil {
+ t.Fatalf("Should have failed")
+ }
+ if tt.isValid && err != nil {
+ t.Fatalf("Should not have failed: %v", err)
+ }
+ if tt.isValid {
+ diff := cmp.Diff(output, tt.expected)
+ if diff != "" {
+ t.Fatalf("Data does not match: %s", diff)
+ }
+ }
+ },
+ )
+ }
+}
diff --git a/stackit/internal/services/postgresflexalpha/user/planModifiers.yaml b/stackit/internal/services/postgresflexalpha/user/planModifiers.yaml
new file mode 100644
index 00000000..e0822704
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/user/planModifiers.yaml
@@ -0,0 +1,64 @@
+fields:
+ - name: 'id'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'user_id'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'instance_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'project_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'name'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'roles'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'password'
+ modifiers:
+ - 'RequiresReplace'
+ - 'UseStateForUnknown'
+
+ - name: 'host'
+ modifiers:
+ - 'RequiresReplace'
+ - 'UseStateForUnknown'
+
+ - name: 'port'
+ modifiers:
+ - 'RequiresReplace'
+ - 'UseStateForUnknown'
+
+ - name: 'region'
+ modifiers:
+ - 'RequiresReplace'
+ - 'RequiresReplace'
+
+ - name: 'status'
+ modifiers:
+ - 'RequiresReplace'
+ - 'UseStateForUnknown'
+
+ - name: 'connection_string'
+ modifiers:
+ - 'RequiresReplace'
+ - 'UseStateForUnknown'
diff --git a/stackit/internal/services/postgresflexalpha/user/resource.go b/stackit/internal/services/postgresflexalpha/user/resource.go
index fbc3035c..ab7ec563 100644
--- a/stackit/internal/services/postgresflexalpha/user/resource.go
+++ b/stackit/internal/services/postgresflexalpha/user/resource.go
@@ -1,64 +1,64 @@
-// Copyright (c) STACKIT
-
-package postgresflexa
+package postgresflexalpha
import (
"context"
+ _ "embed"
"fmt"
- "net/http"
+ "math"
+ "slices"
+ "strconv"
"strings"
+ "time"
- postgresflexUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflex/utils"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
- "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
- "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ postgresflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user/resources_gen"
+ postgresflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/utils"
+ postgresflexalphaWait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/postgresflexalpha"
- "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/planmodifier"
- "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/wait"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
)
-// Ensure the implementation satisfies the expected interfaces.
var (
- _ resource.Resource = &userResource{}
- _ resource.ResourceWithConfigure = &userResource{}
- _ resource.ResourceWithImportState = &userResource{}
- _ resource.ResourceWithModifyPlan = &userResource{}
-)
+ // Ensure the implementation satisfies the expected interfaces.
+ _ resource.Resource = &userResource{}
+ _ resource.ResourceWithConfigure = &userResource{}
+ _ resource.ResourceWithImportState = &userResource{}
+ _ resource.ResourceWithModifyPlan = &userResource{}
+ _ resource.ResourceWithIdentity = &userResource{}
+ _ resource.ResourceWithValidateConfig = &userResource{}
-type Model struct {
- Id types.String `tfsdk:"id"` // needed by TF
- UserId types.String `tfsdk:"user_id"`
- InstanceId types.String `tfsdk:"instance_id"`
- ProjectId types.String `tfsdk:"project_id"`
- Username types.String `tfsdk:"username"`
- Roles types.Set `tfsdk:"roles"`
- Password types.String `tfsdk:"password"`
- Host types.String `tfsdk:"host"`
- Port types.Int64 `tfsdk:"port"`
- Uri types.String `tfsdk:"uri"`
- Region types.String `tfsdk:"region"`
-}
+ // Error message constants
+ extractErrorSummary = "extracting failed"
+ extractErrorMessage = "Extracting identity data: %v"
+)
// NewUserResource is a helper function to simplify the provider implementation.
func NewUserResource() resource.Resource {
return &userResource{}
}
-// userResource is the resource implementation.
+// resourceModel represents the Terraform resource state for a PostgreSQL Flex user.
+type resourceModel = postgresflexalpha.UserModel
+
+// UserResourceIdentityModel describes the resource's identity attributes.
+type UserResourceIdentityModel struct {
+ ProjectID types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ InstanceID types.String `tfsdk:"instance_id"`
+ UserID types.Int64 `tfsdk:"user_id"`
+}
+
+// userResource implements the resource handling for a PostgreSQL Flex user.
type userResource struct {
client *postgresflex.APIClient
providerData core.ProviderData
@@ -66,8 +66,12 @@ type userResource struct {
// ModifyPlan implements resource.ResourceWithModifyPlan.
// Use the modifier to set the effective region in the current plan.
-func (r *userResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { // nolint:gocritic // function signature required by Terraform
- var configModel Model
+func (r *userResource) ModifyPlan(
+ ctx context.Context,
+ req resource.ModifyPlanRequest,
+ resp *resource.ModifyPlanResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var configModel resourceModel
// skip initial empty configuration to avoid follow-up errors
if req.Config.Raw.IsNull() {
return
@@ -77,7 +81,7 @@ func (r *userResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRe
return
}
- var planModel Model
+ var planModel resourceModel
resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...)
if resp.Diagnostics.HasError() {
return
@@ -96,7 +100,7 @@ func (r *userResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRe
// Metadata returns the resource type name.
func (r *userResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
- resp.TypeName = req.ProviderTypeName + "_postgresflex_user"
+ resp.TypeName = req.ProviderTypeName + "_postgresflexalpha_user"
}
// Configure adds the provider configured client to the resource.
@@ -115,110 +119,67 @@ func (r *userResource) Configure(ctx context.Context, req resource.ConfigureRequ
tflog.Info(ctx, "Postgres Flex user client configured")
}
-// Schema defines the schema for the resource.
-func (r *userResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
- rolesOptions := []string{"login", "createdb"}
+//go:embed planModifiers.yaml
+var modifiersFileByte []byte
- descriptions := map[string]string{
- "main": "Postgres Flex user resource schema. Must have a `region` specified in the provider configuration.",
- "id": "Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`,`user_id`\".",
- "user_id": "User ID.",
- "instance_id": "ID of the PostgresFlex instance.",
- "project_id": "STACKIT project ID to which the instance is associated.",
- "roles": "Database access levels for the user. " + utils.FormatPossibleValues(rolesOptions...),
- "region": "The resource region. If not defined, the provider region is used.",
+// Schema defines the schema for the resource.
+func (r *userResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
+ s := postgresflexalpha.UserResourceSchema(ctx)
+
+ fields, err := utils.ReadModifiersConfig(modifiersFileByte)
+ if err != nil {
+ resp.Diagnostics.AddError("error during read modifiers config file", err.Error())
+ return
}
- resp.Schema = schema.Schema{
- Description: descriptions["main"],
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Description: descriptions["id"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- "user_id": schema.StringAttribute{
- Description: descriptions["user_id"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- "instance_id": schema.StringAttribute{
- Description: descriptions["instance_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "project_id": schema.StringAttribute{
- Description: descriptions["project_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "username": schema.StringAttribute{
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- },
- "roles": schema.SetAttribute{
- Description: descriptions["roles"],
- ElementType: types.StringType,
- Required: true,
- Validators: []validator.Set{
- setvalidator.ValueStringsAre(
- stringvalidator.OneOf("login", "createdb"),
- ),
- },
- },
- "password": schema.StringAttribute{
- Computed: true,
- Sensitive: true,
- },
- "host": schema.StringAttribute{
- Computed: true,
- },
- "port": schema.Int64Attribute{
- Computed: true,
- },
- "uri": schema.StringAttribute{
- Computed: true,
- Sensitive: true,
- },
- "region": schema.StringAttribute{
- Optional: true,
- // must be computed to allow for storing the override value from the provider
- Computed: true,
- Description: descriptions["region"],
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- },
- },
+ err = utils.AddPlanModifiersToResourceSchema(fields, &s)
+ if err != nil {
+ resp.Diagnostics.AddError("error adding plan modifiers", err.Error())
+ return
+ }
+ resp.Schema = s
+}
+
+func (r *userResource) ValidateConfig(
+ ctx context.Context,
+ req resource.ValidateConfigRequest,
+ resp *resource.ValidateConfigResponse,
+) {
+ var data resourceModel
+
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ var roles []string
+ diags := data.Roles.ElementsAs(ctx, &roles, false)
+ resp.Diagnostics.Append(diags...)
+ if diags.HasError() {
+ return
+ }
+
+ var resRoles []string
+ for _, role := range roles {
+ if slices.Contains(resRoles, role) {
+ resp.Diagnostics.AddAttributeError(
+ path.Root("roles"),
+ "Attribute Configuration Error",
+ "defined roles MUST NOT contain duplicates",
+ )
+ return
+ }
+ resRoles = append(resRoles, role)
}
}
// Create creates the resource and sets the initial Terraform state.
-func (r *userResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
- var model Model
+func (r *userResource) Create(
+ ctx context.Context,
+ req resource.CreateRequest,
+ resp *resource.CreateResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
diags := req.Plan.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -227,50 +188,117 @@ func (r *userResource) Create(ctx context.Context, req resource.CreateRequest, r
ctx = core.InitProviderContext(ctx)
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- region := model.Region.ValueString()
- ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
- ctx = tflog.SetField(ctx, "region", region)
+ arg := &clientArg{
+ projectId: model.ProjectId.ValueString(),
+ instanceId: model.InstanceId.ValueString(),
+ region: r.providerData.GetRegionWithOverride(model.Region),
+ }
- var roles []string
- if !(model.Roles.IsNull() || model.Roles.IsUnknown()) {
- diags = model.Roles.ElementsAs(ctx, &roles, false)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
+ ctx = r.setTFLogFields(ctx, arg)
+
+ var roles = r.expandRoles(ctx, model.Roles, &resp.Diagnostics)
+ if resp.Diagnostics.HasError() {
+ return
}
// Generate API request body from model
- payload, err := toCreatePayload(&model, roles)
+ payload, err := toCreatePayload(&model, &roles)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating user", fmt.Sprintf("Creating API payload: %v", err))
return
}
+
// Create new user
- userResp, err := r.client.CreateUser(ctx, projectId, region, instanceId).CreateUserPayload(*payload).Execute()
+ userResp, err := r.client.CreateUserRequest(
+ ctx,
+ arg.projectId,
+ arg.region,
+ arg.instanceId,
+ ).CreateUserRequestPayload(*payload).Execute()
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating user", fmt.Sprintf("Calling API: %v", err))
return
}
+ id, ok := userResp.GetIdOk()
+ if !ok || id == 0 {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating user",
+ "API didn't return user Id. A user might have been created",
+ )
+ return
+ }
+ arg.userId = id
+
+ ctx = tflog.SetField(ctx, "user_id", id)
+
ctx = core.LogResponse(ctx)
- if userResp == nil || userResp.Item == nil || userResp.Item.Id == nil || *userResp.Item.Id == "" {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating user", "API didn't return user Id. A user might have been created")
+ // Set data returned by API in identity
+ identity := UserResourceIdentityModel{
+ ProjectID: types.StringValue(arg.projectId),
+ Region: types.StringValue(arg.region),
+ InstanceID: types.StringValue(arg.instanceId),
+ UserID: types.Int64Value(id),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
return
}
- userId := *userResp.Item.Id
- ctx = tflog.SetField(ctx, "user_id", userId)
- // Map response body to schema
- err = mapFieldsCreate(userResp, &model, region)
+ model.Id = types.Int64Value(id)
+ model.UserId = types.Int64Value(id)
+ model.Password = types.StringValue(userResp.GetPassword())
+ model.Status = types.StringValue(userResp.GetStatus())
+
+ waitResp, err := postgresflexalphaWait.GetUserByIdWaitHandler(
+ ctx,
+ r.client,
+ arg.projectId,
+ arg.instanceId,
+ arg.region,
+ id,
+ ).SetSleepBeforeWait(
+ 10 * time.Second,
+ ).SetTimeout(
+ 15 * time.Minute,
+ ).WaitWithContext(ctx)
+
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating user", fmt.Sprintf("Processing API payload: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "create user",
+ fmt.Sprintf("Instance creation waiting: %v", err),
+ )
return
}
+
+ if waitResp.Id == nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "create user",
+ "Instance creation waiting: returned id is nil",
+ )
+ return
+ }
+ if waitResp.Id == nil || *waitResp.Id != id {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "create user",
+ fmt.Sprintf(
+ "Instance creation waiting: returned id is wrong: %+v - %+v",
+ waitResp.Id,
+ id,
+ ),
+ )
+ return
+ }
+
// Set state to fully populated data
diags = resp.State.Set(ctx, model)
resp.Diagnostics.Append(diags...)
@@ -281,8 +309,12 @@ func (r *userResource) Create(ctx context.Context, req resource.CreateRequest, r
}
// Read refreshes the Terraform state with the latest data.
-func (r *userResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
- var model Model
+func (r *userResource) Read(
+ ctx context.Context,
+ req resource.ReadRequest,
+ resp *resource.ReadResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
diags := req.State.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -291,32 +323,62 @@ func (r *userResource) Read(ctx context.Context, req resource.ReadRequest, resp
ctx = core.InitProviderContext(ctx)
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- userId := model.UserId.ValueString()
- region := r.providerData.GetRegionWithOverride(model.Region)
- ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
- ctx = tflog.SetField(ctx, "user_id", userId)
- ctx = tflog.SetField(ctx, "region", region)
+ arg := &clientArg{
+ projectId: model.ProjectId.ValueString(),
+ instanceId: model.InstanceId.ValueString(),
+ region: r.providerData.GetRegionWithOverride(model.Region),
+ }
+
+ ctx = r.setTFLogFields(ctx, arg)
+
+ ctx = core.InitProviderContext(ctx)
+
+ // Read resource state
+ waitResp, err := postgresflexalphaWait.GetUserByIdWaitHandler(
+ ctx,
+ r.client,
+ arg.projectId,
+ arg.instanceId,
+ arg.region,
+ model.UserId.ValueInt64(),
+ ).SetSleepBeforeWait(
+ 10 * time.Second,
+ ).SetTimeout(
+ 15 * time.Minute,
+ ).WaitWithContext(ctx)
- recordSetResp, err := r.client.GetUser(ctx, projectId, region, instanceId, userId).Execute()
if err != nil {
- oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
- if ok && oapiErr.StatusCode == http.StatusNotFound {
- resp.State.RemoveResource(ctx)
- return
- }
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading user", fmt.Sprintf("Calling API: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "read user",
+ fmt.Sprintf("Instance creation waiting: %v", err),
+ )
return
}
+ if waitResp.Id == nil || *waitResp.Id != model.UserId.ValueInt64() {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "read user",
+ "Instance creation waiting: returned id is nil or wrong",
+ )
+ return
+ }
+ arg.userId = *waitResp.Id
+
ctx = core.LogResponse(ctx)
- // Map response body to schema
- err = mapFields(recordSetResp, &model, region)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading user", fmt.Sprintf("Processing API payload: %v", err))
+ // Set data returned by API in identity
+ identity := UserResourceIdentityModel{
+ ProjectID: types.StringValue(arg.projectId),
+ Region: types.StringValue(arg.region),
+ InstanceID: types.StringValue(arg.instanceId),
+ UserID: types.Int64Value(arg.userId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
return
}
@@ -330,9 +392,12 @@ func (r *userResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
// Update updates the resource and sets the updated Terraform state on success.
-func (r *userResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
- // Retrieve values from plan
- var model Model
+func (r *userResource) Update(
+ ctx context.Context,
+ req resource.UpdateRequest,
+ resp *resource.UpdateResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
diags := req.Plan.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -341,41 +406,50 @@ func (r *userResource) Update(ctx context.Context, req resource.UpdateRequest, r
ctx = core.InitProviderContext(ctx)
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- userId := model.UserId.ValueString()
- region := model.Region.ValueString()
- ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
- ctx = tflog.SetField(ctx, "user_id", userId)
- ctx = tflog.SetField(ctx, "region", region)
+ arg := &clientArg{
+ projectId: model.ProjectId.ValueString(),
+ instanceId: model.InstanceId.ValueString(),
+ region: r.providerData.GetRegionWithOverride(model.Region),
+ }
+
+ ctx = r.setTFLogFields(ctx, arg)
+ ctx = core.InitProviderContext(ctx)
// Retrieve values from state
- var stateModel Model
+ var stateModel resourceModel
diags = req.State.Get(ctx, &stateModel)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
- var roles []string
- if !(model.Roles.IsNull() || model.Roles.IsUnknown()) {
- diags = model.Roles.ElementsAs(ctx, &roles, false)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
+ var roles = r.expandRoles(ctx, model.Roles, &resp.Diagnostics)
+ if resp.Diagnostics.HasError() {
+ return
}
// Generate API request body from model
- payload, err := toUpdatePayload(&model, roles)
+ payload, err := toUpdatePayload(&model, &roles)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating user", fmt.Sprintf("Updating API payload: %v", err))
return
}
+ userId64 := arg.userId
+ if userId64 > math.MaxInt32 {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (userId)")
+ return
+ }
+ userId := int32(userId64) // nolint:gosec // check is performed above
+
// Update existing instance
- err = r.client.UpdateUser(ctx, projectId, region, instanceId, userId).UpdateUserPayload(*payload).Execute()
+ err = r.client.UpdateUserRequest(
+ ctx,
+ arg.projectId,
+ arg.region,
+ arg.instanceId,
+ userId,
+ ).UpdateUserRequestPayload(*payload).Execute()
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating user", err.Error())
return
@@ -383,19 +457,53 @@ func (r *userResource) Update(ctx context.Context, req resource.UpdateRequest, r
ctx = core.LogResponse(ctx)
- userResp, err := r.client.GetUser(ctx, projectId, region, instanceId, userId).Execute()
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating user", fmt.Sprintf("Calling API: %v", err))
+ // Set data returned by API in identity
+ identity := UserResourceIdentityModel{
+ ProjectID: types.StringValue(arg.projectId),
+ Region: types.StringValue(arg.region),
+ InstanceID: types.StringValue(arg.instanceId),
+ UserID: types.Int64Value(userId64),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
return
}
- // Map response body to schema
- err = mapFields(userResp, &stateModel, region)
+ // Verify update
+ waitResp, err := postgresflexalphaWait.GetUserByIdWaitHandler(
+ ctx,
+ r.client,
+ arg.projectId,
+ arg.instanceId,
+ arg.region,
+ model.UserId.ValueInt64(),
+ ).SetSleepBeforeWait(
+ 10 * time.Second,
+ ).SetTimeout(
+ 15 * time.Minute,
+ ).WaitWithContext(ctx)
+
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating user", fmt.Sprintf("Processing API payload: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "read user",
+ fmt.Sprintf("user update waiting: %v", err),
+ )
return
}
+ if waitResp.Id == nil || *waitResp.Id != model.UserId.ValueInt64() {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "update user",
+ "User creation waiting: returned id is nil or wrong",
+ )
+ return
+ }
+ arg.userId = *waitResp.Id
+
// Set state to fully populated data
diags = resp.State.Set(ctx, stateModel)
resp.Diagnostics.Append(diags...)
@@ -406,174 +514,238 @@ func (r *userResource) Update(ctx context.Context, req resource.UpdateRequest, r
}
// Delete deletes the resource and removes the Terraform state on success.
-func (r *userResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
- // Retrieve values from plan
- var model Model
+func (r *userResource) Delete(
+ ctx context.Context,
+ req resource.DeleteRequest,
+ resp *resource.DeleteResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
diags := req.State.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
+ // Read identity data
+ var identityData UserResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
ctx = core.InitProviderContext(ctx)
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- userId := model.UserId.ValueString()
- region := model.Region.ValueString()
- ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
- ctx = tflog.SetField(ctx, "user_id", userId)
- ctx = tflog.SetField(ctx, "region", region)
+ arg, errExt := r.extractIdentityData(model, identityData)
+ if errExt != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ extractErrorSummary,
+ fmt.Sprintf(extractErrorMessage, errExt),
+ )
+ }
+
+ ctx = r.setTFLogFields(ctx, arg)
+ ctx = core.InitProviderContext(ctx)
+
+ userId64 := arg.userId
+ if userId64 > math.MaxInt32 {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (userId)")
+ return
+ }
+ userId := int32(userId64) // nolint:gosec // check is performed above
// Delete existing record set
- err := r.client.DeleteUser(ctx, projectId, region, instanceId, userId).Execute()
+ err := r.client.DeleteUserRequest(ctx, arg.projectId, arg.region, arg.instanceId, userId).Execute()
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting user", fmt.Sprintf("Calling API: %v", err))
}
ctx = core.LogResponse(ctx)
- _, err = wait.DeleteUserWaitHandler(ctx, r.client, projectId, region, instanceId, userId).WaitWithContext(ctx)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting user", fmt.Sprintf("Instance deletion waiting: %v", err))
- return
- }
+ // TODO: Verify deletion
+ // exists, err := r.getUserResource(ctx, &model, arg)
+ // if err != nil {
+ // core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting user", fmt.Sprintf("Calling API: %v", err))
+ // return
+ //}
+ // if exists {
+ // core.LogAndAddError(
+ // ctx, &resp.Diagnostics, "Error deleting user",
+ // fmt.Sprintf("User ID '%v' resource still exists after deletion", model.UserId.ValueInt64()),
+ // )
+ // return
+ //}
+
+ resp.State.RemoveResource(ctx)
+
tflog.Info(ctx, "Postgres Flex user deleted")
}
+// IdentitySchema defines the fields that are required to uniquely identify a resource.
+func (r *userResource) IdentitySchema(
+ _ context.Context,
+ _ resource.IdentitySchemaRequest,
+ response *resource.IdentitySchemaResponse,
+) {
+ response.IdentitySchema = identityschema.Schema{
+ Attributes: map[string]identityschema.Attribute{
+ "project_id": identityschema.StringAttribute{
+ RequiredForImport: true,
+ },
+ "region": identityschema.StringAttribute{
+ RequiredForImport: true,
+ },
+ "instance_id": identityschema.StringAttribute{
+ RequiredForImport: true,
+ },
+ "user_id": identityschema.Int64Attribute{
+ RequiredForImport: true,
+ },
+ },
+ }
+}
+
+// clientArg holds the arguments for API calls.
+type clientArg struct {
+ projectId string
+ instanceId string
+ region string
+ userId int64
+}
+
// ImportState imports a resource into the Terraform state on success.
-// The expected format of the resource import identifier is: project_id,zone_id,record_set_id
-func (r *userResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
- idParts := strings.Split(req.ID, core.Separator)
- if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" {
- core.LogAndAddError(ctx, &resp.Diagnostics,
- "Error importing user",
- fmt.Sprintf("Expected import identifier with format [project_id],[region],[instance_id],[user_id], got %q", req.ID),
- )
+// The expected import identifier format is: [project_id],[region],[instance_id],[database_id]
+func (r *userResource) ImportState(
+ ctx context.Context,
+ req resource.ImportStateRequest,
+ resp *resource.ImportStateResponse,
+) {
+ ctx = core.InitProviderContext(ctx)
+
+ if req.ID != "" {
+ idParts := strings.Split(req.ID, core.Separator)
+
+ if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" {
+ core.LogAndAddError(
+ ctx, &resp.Diagnostics,
+ "Error importing user",
+ fmt.Sprintf(
+ "Expected import identifier with format [project_id],[region],[instance_id],[user_id], got %q",
+ req.ID,
+ ),
+ )
+ return
+ }
+
+ userId, err := strconv.ParseInt(idParts[3], 10, 64)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error importing user",
+ fmt.Sprintf("Invalid user_id format: %q. It must be a valid integer.", idParts[3]),
+ )
+ return
+ }
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_id"), userId)...)
+
+ tflog.Info(ctx, "Postgres Flex user state imported")
+
return
}
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_id"), idParts[3])...)
- core.LogAndAddWarning(ctx, &resp.Diagnostics,
- "Postgresflex user imported with empty password and empty uri",
- "The user password and uri are not imported as they are only available upon creation of a new user. The password and uri fields will be empty.",
- )
- tflog.Info(ctx, "Postgresflex user state imported")
+ // If no ID is provided, attempt to read identity attributes from the import configuration
+ var identityData UserResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ instanceId := identityData.InstanceID.ValueString()
+ userId := identityData.UserID.ValueInt64()
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), projectId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), region)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), instanceId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_id"), userId)...)
+
+ tflog.Info(ctx, "Postgres Flex user state imported")
}
-func mapFieldsCreate(userResp *postgresflex.CreateUserResponse, model *Model, region string) error {
- if userResp == nil || userResp.Item == nil {
- return fmt.Errorf("response is nil")
- }
- if model == nil {
- return fmt.Errorf("model input is nil")
- }
- user := userResp.Item
+// extractIdentityData extracts essential identifiers from the resource model, falling back to the identity model.
+func (r *userResource) extractIdentityData(
+ model resourceModel,
+ identity UserResourceIdentityModel,
+) (*clientArg, error) {
+ var projectId, region, instanceId string
+ var userId int64
- if user.Id == nil {
- return fmt.Errorf("user id not present")
- }
- userId := *user.Id
- model.Id = utils.BuildInternalTerraformId(
- model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), userId,
- )
- model.UserId = types.StringValue(userId)
- model.Username = types.StringPointerValue(user.Username)
-
- if user.Password == nil {
- return fmt.Errorf("user password not present")
- }
- model.Password = types.StringValue(*user.Password)
-
- if user.Roles == nil {
- model.Roles = types.SetNull(types.StringType)
+ if !model.UserId.IsNull() && !model.UserId.IsUnknown() {
+ userId = model.UserId.ValueInt64()
} else {
- roles := []attr.Value{}
- for _, role := range *user.Roles {
- roles = append(roles, types.StringValue(role))
+ if identity.UserID.IsNull() || identity.UserID.IsUnknown() {
+ return nil, fmt.Errorf("user_id not found in config")
}
- rolesSet, diags := types.SetValue(types.StringType, roles)
- if diags.HasError() {
- return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
- }
- model.Roles = rolesSet
+ userId = identity.UserID.ValueInt64()
}
- model.Host = types.StringPointerValue(user.Host)
- model.Port = types.Int64PointerValue(user.Port)
- model.Uri = types.StringPointerValue(user.Uri)
- model.Region = types.StringValue(region)
- return nil
-}
-func mapFields(userResp *postgresflex.GetUserResponse, model *Model, region string) error {
- if userResp == nil || userResp.Item == nil {
- return fmt.Errorf("response is nil")
- }
- if model == nil {
- return fmt.Errorf("model input is nil")
- }
- user := userResp.Item
-
- var userId string
- if model.UserId.ValueString() != "" {
- userId = model.UserId.ValueString()
- } else if user.Id != nil {
- userId = *user.Id
+ if !model.ProjectId.IsNull() && !model.ProjectId.IsUnknown() {
+ projectId = model.ProjectId.ValueString()
} else {
- return fmt.Errorf("user id not present")
+ if identity.ProjectID.IsNull() || identity.ProjectID.IsUnknown() {
+ return nil, fmt.Errorf("project_id not found in config")
+ }
+ projectId = identity.ProjectID.ValueString()
}
- model.Id = utils.BuildInternalTerraformId(
- model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), userId,
- )
- model.UserId = types.StringValue(userId)
- model.Username = types.StringPointerValue(user.Username)
- if user.Roles == nil {
- model.Roles = types.SetNull(types.StringType)
+ if !model.Region.IsNull() && !model.Region.IsUnknown() {
+ region = r.providerData.GetRegionWithOverride(model.Region)
} else {
- roles := []attr.Value{}
- for _, role := range *user.Roles {
- roles = append(roles, types.StringValue(role))
+ if identity.Region.IsNull() || identity.Region.IsUnknown() {
+ return nil, fmt.Errorf("region not found in config")
}
- rolesSet, diags := types.SetValue(types.StringType, roles)
- if diags.HasError() {
- return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
- }
- model.Roles = rolesSet
- }
- model.Host = types.StringPointerValue(user.Host)
- model.Port = types.Int64PointerValue(user.Port)
- model.Region = types.StringValue(region)
- return nil
-}
-
-func toCreatePayload(model *Model, roles []string) (*postgresflex.CreateUserPayload, error) {
- if model == nil {
- return nil, fmt.Errorf("nil model")
- }
- if roles == nil {
- return nil, fmt.Errorf("nil roles")
+ region = r.providerData.GetRegionWithOverride(identity.Region)
}
- return &postgresflex.CreateUserPayload{
- Roles: &roles,
- Username: conversion.StringValueToPointer(model.Username),
+ if !model.InstanceId.IsNull() && !model.InstanceId.IsUnknown() {
+ instanceId = model.InstanceId.ValueString()
+ } else {
+ if identity.InstanceID.IsNull() || identity.InstanceID.IsUnknown() {
+ return nil, fmt.Errorf("instance_id not found in config")
+ }
+ instanceId = identity.InstanceID.ValueString()
+ }
+ return &clientArg{
+ projectId: projectId,
+ instanceId: instanceId,
+ region: region,
+ userId: userId,
}, nil
}
-func toUpdatePayload(model *Model, roles []string) (*postgresflex.UpdateUserPayload, error) {
- if model == nil {
- return nil, fmt.Errorf("nil model")
- }
- if roles == nil {
- return nil, fmt.Errorf("nil roles")
- }
+// setTFLogFields adds relevant fields to the context for terraform logging purposes.
+func (r *userResource) setTFLogFields(ctx context.Context, arg *clientArg) context.Context {
+ ctx = tflog.SetField(ctx, "project_id", arg.projectId)
+ ctx = tflog.SetField(ctx, "instance_id", arg.instanceId)
+ ctx = tflog.SetField(ctx, "region", arg.region)
+ ctx = tflog.SetField(ctx, "user_id", arg.userId)
- return &postgresflex.UpdateUserPayload{
- Roles: &roles,
- }, nil
+ return ctx
+}
+
+// expandRoles converts a Terraform list of roles to a string slice.
+func (r *userResource) expandRoles(ctx context.Context, rolesSet types.List, diags *diag.Diagnostics) []string {
+ if rolesSet.IsNull() || rolesSet.IsUnknown() {
+ return nil
+ }
+ var roles []string
+ diags.Append(rolesSet.ElementsAs(ctx, &roles, false)...)
+ slices.Sort(roles)
+ return roles
}
diff --git a/stackit/internal/services/postgresflexalpha/user/resource_test.go b/stackit/internal/services/postgresflexalpha/user/resource_test.go
deleted file mode 100644
index 6dbe2e18..00000000
--- a/stackit/internal/services/postgresflexalpha/user/resource_test.go
+++ /dev/null
@@ -1,472 +0,0 @@
-// Copyright (c) STACKIT
-
-package postgresflexa
-
-import (
- "testing"
-
- "github.com/google/go-cmp/cmp"
- "github.com/hashicorp/terraform-plugin-framework/attr"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/stackit-sdk-go/core/utils"
- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
-)
-
-func TestMapFieldsCreate(t *testing.T) {
- const testRegion = "region"
- tests := []struct {
- description string
- input *postgresflex.CreateUserResponse
- region string
- expected Model
- isValid bool
- }{
- {
- "default_values",
- &postgresflex.CreateUserResponse{
- Item: &postgresflex.User{
- Id: utils.Ptr("uid"),
- Password: utils.Ptr(""),
- },
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,uid"),
- UserId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringNull(),
- Roles: types.SetNull(types.StringType),
- Password: types.StringValue(""),
- Host: types.StringNull(),
- Port: types.Int64Null(),
- Uri: types.StringNull(),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "simple_values",
- &postgresflex.CreateUserResponse{
- Item: &postgresflex.User{
- Id: utils.Ptr("uid"),
- Roles: &[]string{
- "role_1",
- "role_2",
- "",
- },
- Username: utils.Ptr("username"),
- Password: utils.Ptr("password"),
- Host: utils.Ptr("host"),
- Port: utils.Ptr(int64(1234)),
- Uri: utils.Ptr("uri"),
- },
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,uid"),
- UserId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringValue("username"),
- Roles: types.SetValueMust(types.StringType, []attr.Value{
- types.StringValue("role_1"),
- types.StringValue("role_2"),
- types.StringValue(""),
- }),
- Password: types.StringValue("password"),
- Host: types.StringValue("host"),
- Port: types.Int64Value(1234),
- Uri: types.StringValue("uri"),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "null_fields_and_int_conversions",
- &postgresflex.CreateUserResponse{
- Item: &postgresflex.User{
- Id: utils.Ptr("uid"),
- Roles: &[]string{},
- Username: nil,
- Password: utils.Ptr(""),
- Host: nil,
- Port: utils.Ptr(int64(2123456789)),
- Uri: nil,
- },
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,uid"),
- UserId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringNull(),
- Roles: types.SetValueMust(types.StringType, []attr.Value{}),
- Password: types.StringValue(""),
- Host: types.StringNull(),
- Port: types.Int64Value(2123456789),
- Uri: types.StringNull(),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "nil_response",
- nil,
- testRegion,
- Model{},
- false,
- },
- {
- "nil_response_2",
- &postgresflex.CreateUserResponse{},
- testRegion,
- Model{},
- false,
- },
- {
- "no_resource_id",
- &postgresflex.CreateUserResponse{
- Item: &postgresflex.User{},
- },
- testRegion,
- Model{},
- false,
- },
- {
- "no_password",
- &postgresflex.CreateUserResponse{
- Item: &postgresflex.User{
- Id: utils.Ptr("uid"),
- },
- },
- testRegion,
- Model{},
- false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.description, func(t *testing.T) {
- state := &Model{
- ProjectId: tt.expected.ProjectId,
- InstanceId: tt.expected.InstanceId,
- }
- err := mapFieldsCreate(tt.input, state, tt.region)
- if !tt.isValid && err == nil {
- t.Fatalf("Should have failed")
- }
- if tt.isValid && err != nil {
- t.Fatalf("Should not have failed: %v", err)
- }
- if tt.isValid {
- diff := cmp.Diff(state, &tt.expected)
- if diff != "" {
- t.Fatalf("Data does not match: %s", diff)
- }
- }
- })
- }
-}
-
-func TestMapFields(t *testing.T) {
- const testRegion = "region"
- tests := []struct {
- description string
- input *postgresflex.GetUserResponse
- region string
- expected Model
- isValid bool
- }{
- {
- "default_values",
- &postgresflex.GetUserResponse{
- Item: &postgresflex.UserResponse{},
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,uid"),
- UserId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringNull(),
- Roles: types.SetNull(types.StringType),
- Host: types.StringNull(),
- Port: types.Int64Null(),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "simple_values",
- &postgresflex.GetUserResponse{
- Item: &postgresflex.UserResponse{
- Roles: &[]string{
- "role_1",
- "role_2",
- "",
- },
- Username: utils.Ptr("username"),
- Host: utils.Ptr("host"),
- Port: utils.Ptr(int64(1234)),
- },
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,uid"),
- UserId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringValue("username"),
- Roles: types.SetValueMust(types.StringType, []attr.Value{
- types.StringValue("role_1"),
- types.StringValue("role_2"),
- types.StringValue(""),
- }),
- Host: types.StringValue("host"),
- Port: types.Int64Value(1234),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "null_fields_and_int_conversions",
- &postgresflex.GetUserResponse{
- Item: &postgresflex.UserResponse{
- Id: utils.Ptr("uid"),
- Roles: &[]string{},
- Username: nil,
- Host: nil,
- Port: utils.Ptr(int64(2123456789)),
- },
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,uid"),
- UserId: types.StringValue("uid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringNull(),
- Roles: types.SetValueMust(types.StringType, []attr.Value{}),
- Host: types.StringNull(),
- Port: types.Int64Value(2123456789),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "nil_response",
- nil,
- testRegion,
- Model{},
- false,
- },
- {
- "nil_response_2",
- &postgresflex.GetUserResponse{},
- testRegion,
- Model{},
- false,
- },
- {
- "no_resource_id",
- &postgresflex.GetUserResponse{
- Item: &postgresflex.UserResponse{},
- },
- testRegion,
- Model{},
- false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.description, func(t *testing.T) {
- state := &Model{
- ProjectId: tt.expected.ProjectId,
- InstanceId: tt.expected.InstanceId,
- UserId: tt.expected.UserId,
- }
- err := mapFields(tt.input, state, tt.region)
- if !tt.isValid && err == nil {
- t.Fatalf("Should have failed")
- }
- if tt.isValid && err != nil {
- t.Fatalf("Should not have failed: %v", err)
- }
- if tt.isValid {
- diff := cmp.Diff(state, &tt.expected)
- if diff != "" {
- t.Fatalf("Data does not match: %s", diff)
- }
- }
- })
- }
-}
-
-func TestToCreatePayload(t *testing.T) {
- tests := []struct {
- description string
- input *Model
- inputRoles []string
- expected *postgresflex.CreateUserPayload
- isValid bool
- }{
- {
- "default_values",
- &Model{},
- []string{},
- &postgresflex.CreateUserPayload{
- Roles: &[]string{},
- Username: nil,
- },
- true,
- },
- {
- "default_values",
- &Model{
- Username: types.StringValue("username"),
- },
- []string{
- "role_1",
- "role_2",
- },
- &postgresflex.CreateUserPayload{
- Roles: &[]string{
- "role_1",
- "role_2",
- },
- Username: utils.Ptr("username"),
- },
- true,
- },
- {
- "null_fields_and_int_conversions",
- &Model{
- Username: types.StringNull(),
- },
- []string{
- "",
- },
- &postgresflex.CreateUserPayload{
- Roles: &[]string{
- "",
- },
- Username: nil,
- },
- true,
- },
- {
- "nil_model",
- nil,
- []string{},
- nil,
- false,
- },
- {
- "nil_roles",
- &Model{},
- nil,
- nil,
- false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.description, func(t *testing.T) {
- output, err := toCreatePayload(tt.input, tt.inputRoles)
- if !tt.isValid && err == nil {
- t.Fatalf("Should have failed")
- }
- if tt.isValid && err != nil {
- t.Fatalf("Should not have failed: %v", err)
- }
- if tt.isValid {
- diff := cmp.Diff(output, tt.expected)
- if diff != "" {
- t.Fatalf("Data does not match: %s", diff)
- }
- }
- })
- }
-}
-
-func TestToUpdatePayload(t *testing.T) {
- tests := []struct {
- description string
- input *Model
- inputRoles []string
- expected *postgresflex.UpdateUserPayload
- isValid bool
- }{
- {
- "default_values",
- &Model{},
- []string{},
- &postgresflex.UpdateUserPayload{
- Roles: &[]string{},
- },
- true,
- },
- {
- "default_values",
- &Model{
- Username: types.StringValue("username"),
- },
- []string{
- "role_1",
- "role_2",
- },
- &postgresflex.UpdateUserPayload{
- Roles: &[]string{
- "role_1",
- "role_2",
- },
- },
- true,
- },
- {
- "null_fields_and_int_conversions",
- &Model{
- Username: types.StringNull(),
- },
- []string{
- "",
- },
- &postgresflex.UpdateUserPayload{
- Roles: &[]string{
- "",
- },
- },
- true,
- },
- {
- "nil_model",
- nil,
- []string{},
- nil,
- false,
- },
- {
- "nil_roles",
- &Model{},
- nil,
- nil,
- false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.description, func(t *testing.T) {
- output, err := toUpdatePayload(tt.input, tt.inputRoles)
- if !tt.isValid && err == nil {
- t.Fatalf("Should have failed")
- }
- if tt.isValid && err != nil {
- t.Fatalf("Should not have failed: %v", err)
- }
- if tt.isValid {
- diff := cmp.Diff(output, tt.expected)
- if diff != "" {
- t.Fatalf("Data does not match: %s", diff)
- }
- }
- })
- }
-}
diff --git a/stackit/internal/services/postgresflexalpha/user/resources_gen/user_resource_gen.go b/stackit/internal/services/postgresflexalpha/user/resources_gen/user_resource_gen.go
new file mode 100644
index 00000000..f96d8d93
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/user/resources_gen/user_resource_gen.go
@@ -0,0 +1,87 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+)
+
+func UserResourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The ID of the user.",
+ MarkdownDescription: "The ID of the user.",
+ },
+ "instance_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "name": schema.StringAttribute{
+ Required: true,
+ Description: "The name of the user.",
+ MarkdownDescription: "The name of the user.",
+ },
+ "password": schema.StringAttribute{
+ Computed: true,
+ Description: "The password for the user.",
+ MarkdownDescription: "The password for the user.",
+ },
+ "project_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "roles": schema.ListAttribute{
+ ElementType: types.StringType,
+ Optional: true,
+ Computed: true,
+ Description: "A list containing the user roles for the instance.",
+ MarkdownDescription: "A list containing the user roles for the instance.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ Description: "The current status of the user.",
+ MarkdownDescription: "The current status of the user.",
+ },
+ "user_id": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the user.",
+ MarkdownDescription: "The ID of the user.",
+ },
+ },
+ }
+}
+
+type UserModel struct {
+ Id types.Int64 `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Name types.String `tfsdk:"name"`
+ Password types.String `tfsdk:"password"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Roles types.List `tfsdk:"roles"`
+ Status types.String `tfsdk:"status"`
+ UserId types.Int64 `tfsdk:"user_id"`
+}
diff --git a/stackit/internal/services/postgresflexalpha/utils/util.go b/stackit/internal/services/postgresflexalpha/utils/util.go
index e15548fa..2b6d1de8 100644
--- a/stackit/internal/services/postgresflexalpha/utils/util.go
+++ b/stackit/internal/services/postgresflexalpha/utils/util.go
@@ -8,10 +8,11 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/stackitcloud/stackit-sdk-go/core/config"
- postgresflex "github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
)
func ConfigureClient(ctx context.Context, providerData *core.ProviderData, diags *diag.Diagnostics) *postgresflex.APIClient {
diff --git a/stackit/internal/services/postgresflexalpha/utils/util_test.go b/stackit/internal/services/postgresflexalpha/utils/util_test.go
index a5f17e37..e0f7a829 100644
--- a/stackit/internal/services/postgresflexalpha/utils/util_test.go
+++ b/stackit/internal/services/postgresflexalpha/utils/util_test.go
@@ -11,9 +11,11 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
sdkClients "github.com/stackitcloud/stackit-sdk-go/core/clients"
"github.com/stackitcloud/stackit-sdk-go/core/config"
- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
)
const (
diff --git a/stackit/internal/services/postgresflexalpha/version/datasources_gen/versions_data_source_gen.go b/stackit/internal/services/postgresflexalpha/version/datasources_gen/versions_data_source_gen.go
new file mode 100644
index 00000000..03530869
--- /dev/null
+++ b/stackit/internal/services/postgresflexalpha/version/datasources_gen/versions_data_source_gen.go
@@ -0,0 +1,569 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package postgresflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func VersionsDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "versions": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "beta": schema.BoolAttribute{
+ Computed: true,
+ Description: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.",
+ MarkdownDescription: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.",
+ },
+ "deprecated": schema.StringAttribute{
+ Computed: true,
+ Description: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.",
+ MarkdownDescription: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.",
+ },
+ "recommend": schema.BoolAttribute{
+ Computed: true,
+ Description: "Flag if the version is recommend by the STACKIT Team.",
+ MarkdownDescription: "Flag if the version is recommend by the STACKIT Team.",
+ },
+ "version": schema.StringAttribute{
+ Computed: true,
+ Description: "The postgres version used for the instance.",
+ MarkdownDescription: "The postgres version used for the instance.",
+ },
+ },
+ CustomType: VersionsType{
+ ObjectType: types.ObjectType{
+ AttrTypes: VersionsValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "A list containing available postgres versions.",
+ MarkdownDescription: "A list containing available postgres versions.",
+ },
+ },
+ }
+}
+
+type VersionsModel struct {
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Versions types.List `tfsdk:"versions"`
+}
+
+var _ basetypes.ObjectTypable = VersionsType{}
+
+type VersionsType struct {
+ basetypes.ObjectType
+}
+
+func (t VersionsType) Equal(o attr.Type) bool {
+ other, ok := o.(VersionsType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t VersionsType) String() string {
+ return "VersionsType"
+}
+
+func (t VersionsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ betaAttribute, ok := attributes["beta"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `beta is missing from object`)
+
+ return nil, diags
+ }
+
+ betaVal, ok := betaAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute))
+ }
+
+ deprecatedAttribute, ok := attributes["deprecated"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `deprecated is missing from object`)
+
+ return nil, diags
+ }
+
+ deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute))
+ }
+
+ recommendAttribute, ok := attributes["recommend"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `recommend is missing from object`)
+
+ return nil, diags
+ }
+
+ recommendVal, ok := recommendAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute))
+ }
+
+ versionAttribute, ok := attributes["version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `version is missing from object`)
+
+ return nil, diags
+ }
+
+ versionVal, ok := versionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return VersionsValue{
+ Beta: betaVal,
+ Deprecated: deprecatedVal,
+ Recommend: recommendVal,
+ Version: versionVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewVersionsValueNull() VersionsValue {
+ return VersionsValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewVersionsValueUnknown() VersionsValue {
+ return VersionsValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewVersionsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (VersionsValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing VersionsValue Attribute Value",
+ "While creating a VersionsValue value, a missing attribute value was detected. "+
+ "A VersionsValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid VersionsValue Attribute Type",
+ "While creating a VersionsValue value, an invalid attribute value was detected. "+
+ "A VersionsValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("VersionsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra VersionsValue Attribute Value",
+ "While creating a VersionsValue value, an extra attribute value was detected. "+
+ "A VersionsValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra VersionsValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewVersionsValueUnknown(), diags
+ }
+
+ betaAttribute, ok := attributes["beta"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `beta is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ betaVal, ok := betaAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute))
+ }
+
+ deprecatedAttribute, ok := attributes["deprecated"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `deprecated is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute))
+ }
+
+ recommendAttribute, ok := attributes["recommend"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `recommend is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ recommendVal, ok := recommendAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute))
+ }
+
+ versionAttribute, ok := attributes["version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `version is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ versionVal, ok := versionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute))
+ }
+
+ if diags.HasError() {
+ return NewVersionsValueUnknown(), diags
+ }
+
+ return VersionsValue{
+ Beta: betaVal,
+ Deprecated: deprecatedVal,
+ Recommend: recommendVal,
+ Version: versionVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewVersionsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) VersionsValue {
+ object, diags := NewVersionsValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewVersionsValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t VersionsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewVersionsValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewVersionsValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewVersionsValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewVersionsValueMust(VersionsValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t VersionsType) ValueType(ctx context.Context) attr.Value {
+ return VersionsValue{}
+}
+
+var _ basetypes.ObjectValuable = VersionsValue{}
+
+type VersionsValue struct {
+ Beta basetypes.BoolValue `tfsdk:"beta"`
+ Deprecated basetypes.StringValue `tfsdk:"deprecated"`
+ Recommend basetypes.BoolValue `tfsdk:"recommend"`
+ Version basetypes.StringValue `tfsdk:"version"`
+ state attr.ValueState
+}
+
+func (v VersionsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["beta"] = basetypes.BoolType{}.TerraformType(ctx)
+ attrTypes["deprecated"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["recommend"] = basetypes.BoolType{}.TerraformType(ctx)
+ attrTypes["version"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.Beta.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["beta"] = val
+
+ val, err = v.Deprecated.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["deprecated"] = val
+
+ val, err = v.Recommend.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["recommend"] = val
+
+ val, err = v.Version.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["version"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v VersionsValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v VersionsValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v VersionsValue) String() string {
+ return "VersionsValue"
+}
+
+func (v VersionsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "beta": basetypes.BoolType{},
+ "deprecated": basetypes.StringType{},
+ "recommend": basetypes.BoolType{},
+ "version": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "beta": v.Beta,
+ "deprecated": v.Deprecated,
+ "recommend": v.Recommend,
+ "version": v.Version,
+ })
+
+ return objVal, diags
+}
+
+func (v VersionsValue) Equal(o attr.Value) bool {
+ other, ok := o.(VersionsValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Beta.Equal(other.Beta) {
+ return false
+ }
+
+ if !v.Deprecated.Equal(other.Deprecated) {
+ return false
+ }
+
+ if !v.Recommend.Equal(other.Recommend) {
+ return false
+ }
+
+ if !v.Version.Equal(other.Version) {
+ return false
+ }
+
+ return true
+}
+
+func (v VersionsValue) Type(ctx context.Context) attr.Type {
+ return VersionsType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v VersionsValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "beta": basetypes.BoolType{},
+ "deprecated": basetypes.StringType{},
+ "recommend": basetypes.BoolType{},
+ "version": basetypes.StringType{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/database/datasource.go b/stackit/internal/services/sqlserverflexalpha/database/datasource.go
new file mode 100644
index 00000000..5155b41c
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/database/datasource.go
@@ -0,0 +1,174 @@
+package sqlserverflexalpha
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexalphaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+ sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database/datasources_gen"
+)
+
+var _ datasource.DataSource = (*databaseDataSource)(nil)
+
+const errorPrefix = "[sqlserverflexalpha - Database]"
+
+func NewDatabaseDataSource() datasource.DataSource {
+ return &databaseDataSource{}
+}
+
+type dataSourceModel struct {
+ sqlserverflexalphaGen.DatabaseModel
+ TerraformId types.String `tfsdk:"id"`
+}
+
+type databaseDataSource struct {
+ client *sqlserverflexalphaPkg.APIClient
+ providerData core.ProviderData
+}
+
+func (d *databaseDataSource) Metadata(
+ _ context.Context,
+ req datasource.MetadataRequest,
+ resp *datasource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_database"
+}
+
+func (d *databaseDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = sqlserverflexalphaGen.DatabaseDataSourceSchema(ctx)
+ resp.Schema.Attributes["id"] = schema.StringAttribute{
+ Computed: true,
+ Description: "The terraform internal identifier.",
+ MarkdownDescription: "The terraform internal identifier.",
+ }
+}
+
+// Configure adds the provider configured client to the data source.
+func (d *databaseDataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
+ var ok bool
+ d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(d.providerData.RoundTripper),
+ utils.UserAgentConfigOption(d.providerData.Version),
+ }
+ if d.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(d.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithRegion(d.providerData.GetRegion()),
+ )
+ }
+ apiClient, err := sqlserverflexalphaPkg.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ d.client = apiClient
+ tflog.Info(ctx, fmt.Sprintf("%s client configured", errorPrefix))
+}
+
+func (d *databaseDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var data dataSourceModel
+ // Read Terraform configuration data into the model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ // Extract identifiers from the plan
+ projectId := data.ProjectId.ValueString()
+ region := d.providerData.GetRegionWithOverride(data.Region)
+ instanceId := data.InstanceId.ValueString()
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+
+ databaseName := data.DatabaseName.ValueString()
+
+ databaseResp, err := d.client.GetDatabaseRequest(ctx, projectId, region, instanceId, databaseName).Execute()
+ if err != nil {
+ handleReadError(ctx, &resp.Diagnostics, err, projectId, instanceId)
+ resp.State.RemoveResource(ctx)
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+ // Map response body to schema and populate Computed attribute values
+ err = mapFields(databaseResp, &data, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading database",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Save data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+
+ tflog.Info(ctx, "SQL Server Flex beta database read")
+}
+
+// handleReadError centralizes API error handling for the Read operation.
+func handleReadError(ctx context.Context, diags *diag.Diagnostics, err error, projectId, instanceId string) {
+ utils.LogError(
+ ctx,
+ diags,
+ err,
+ "Reading database",
+ fmt.Sprintf(
+ "Could not retrieve database for instance %q in project %q.",
+ instanceId,
+ projectId,
+ ),
+ map[int]string{
+ http.StatusBadRequest: fmt.Sprintf(
+ "Invalid request parameters for project %q and instance %q.",
+ projectId,
+ instanceId,
+ ),
+ http.StatusNotFound: fmt.Sprintf(
+ "Database, instance %q, or project %q not found.",
+ instanceId,
+ projectId,
+ ),
+ http.StatusForbidden: fmt.Sprintf("Forbidden access to project %q.", projectId),
+ },
+ )
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/database/datasources_gen/database_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/database/datasources_gen/database_data_source_gen.go
new file mode 100644
index 00000000..82250802
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/database/datasources_gen/database_data_source_gen.go
@@ -0,0 +1,81 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexalpha
+
+import (
+ "context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func DatabaseDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "collation_name": schema.StringAttribute{
+ Computed: true,
+ Description: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ MarkdownDescription: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ },
+ "compatibility_level": schema.Int64Attribute{
+ Computed: true,
+ Description: "CompatibilityLevel of the Database.",
+ MarkdownDescription: "CompatibilityLevel of the Database.",
+ },
+ "database_name": schema.StringAttribute{
+ Required: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "tf_original_api_id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The id of the database.",
+ MarkdownDescription: "The id of the database.",
+ },
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "owner": schema.StringAttribute{
+ Computed: true,
+ Description: "The owner of the database.",
+ MarkdownDescription: "The owner of the database.",
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type DatabaseModel struct {
+ CollationName types.String `tfsdk:"collation_name"`
+ CompatibilityLevel types.Int64 `tfsdk:"compatibility_level"`
+ DatabaseName types.String `tfsdk:"database_name"`
+ Id types.Int64 `tfsdk:"tf_original_api_id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Name types.String `tfsdk:"name"`
+ Owner types.String `tfsdk:"owner"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/database/datasources_gen/databases_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/database/datasources_gen/databases_data_source_gen.go
new file mode 100644
index 00000000..c6b6350a
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/database/datasources_gen/databases_data_source_gen.go
@@ -0,0 +1,1180 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func DatabasesDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "databases": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "created": schema.StringAttribute{
+ Computed: true,
+ Description: "The date when the database was created in RFC3339 format.",
+ MarkdownDescription: "The date when the database was created in RFC3339 format.",
+ },
+ "id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The id of the database.",
+ MarkdownDescription: "The id of the database.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "owner": schema.StringAttribute{
+ Computed: true,
+ Description: "The owner of the database.",
+ MarkdownDescription: "The owner of the database.",
+ },
+ },
+ CustomType: DatabasesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: DatabasesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "A list containing all databases for the instance.",
+ MarkdownDescription: "A list containing all databases for the instance.",
+ },
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the databases to be returned on each page.",
+ MarkdownDescription: "Sorting of the databases to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "created_at.desc",
+ "created_at.asc",
+ "database_id.desc",
+ "database_id.asc",
+ "database_name.desc",
+ "database_name.asc",
+ "database_owner.desc",
+ "database_owner.asc",
+ "index.asc",
+ "index.desc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type DatabasesModel struct {
+ Databases types.List `tfsdk:"databases"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = DatabasesType{}
+
+type DatabasesType struct {
+ basetypes.ObjectType
+}
+
+func (t DatabasesType) Equal(o attr.Type) bool {
+ other, ok := o.(DatabasesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t DatabasesType) String() string {
+ return "DatabasesType"
+}
+
+func (t DatabasesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ createdAttribute, ok := attributes["created"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `created is missing from object`)
+
+ return nil, diags
+ }
+
+ createdVal, ok := createdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`created expected to be basetypes.StringValue, was: %T`, createdAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return nil, diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ ownerAttribute, ok := attributes["owner"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `owner is missing from object`)
+
+ return nil, diags
+ }
+
+ ownerVal, ok := ownerAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`owner expected to be basetypes.StringValue, was: %T`, ownerAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return DatabasesValue{
+ Created: createdVal,
+ Id: idVal,
+ Name: nameVal,
+ Owner: ownerVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewDatabasesValueNull() DatabasesValue {
+ return DatabasesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewDatabasesValueUnknown() DatabasesValue {
+ return DatabasesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewDatabasesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (DatabasesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing DatabasesValue Attribute Value",
+ "While creating a DatabasesValue value, a missing attribute value was detected. "+
+ "A DatabasesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("DatabasesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid DatabasesValue Attribute Type",
+ "While creating a DatabasesValue value, an invalid attribute value was detected. "+
+ "A DatabasesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("DatabasesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("DatabasesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra DatabasesValue Attribute Value",
+ "While creating a DatabasesValue value, an extra attribute value was detected. "+
+ "A DatabasesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra DatabasesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ createdAttribute, ok := attributes["created"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `created is missing from object`)
+
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ createdVal, ok := createdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`created expected to be basetypes.StringValue, was: %T`, createdAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ ownerAttribute, ok := attributes["owner"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `owner is missing from object`)
+
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ ownerVal, ok := ownerAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`owner expected to be basetypes.StringValue, was: %T`, ownerAttribute))
+ }
+
+ if diags.HasError() {
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ return DatabasesValue{
+ Created: createdVal,
+ Id: idVal,
+ Name: nameVal,
+ Owner: ownerVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewDatabasesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) DatabasesValue {
+ object, diags := NewDatabasesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewDatabasesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t DatabasesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewDatabasesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewDatabasesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewDatabasesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewDatabasesValueMust(DatabasesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t DatabasesType) ValueType(ctx context.Context) attr.Value {
+ return DatabasesValue{}
+}
+
+var _ basetypes.ObjectValuable = DatabasesValue{}
+
+type DatabasesValue struct {
+ Created basetypes.StringValue `tfsdk:"created"`
+ Id basetypes.Int64Value `tfsdk:"id"`
+ Name basetypes.StringValue `tfsdk:"name"`
+ Owner basetypes.StringValue `tfsdk:"owner"`
+ state attr.ValueState
+}
+
+func (v DatabasesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["created"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["id"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["name"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["owner"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.Created.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["created"] = val
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.Name.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["name"] = val
+
+ val, err = v.Owner.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["owner"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v DatabasesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v DatabasesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v DatabasesValue) String() string {
+ return "DatabasesValue"
+}
+
+func (v DatabasesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "created": basetypes.StringType{},
+ "id": basetypes.Int64Type{},
+ "name": basetypes.StringType{},
+ "owner": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "created": v.Created,
+ "id": v.Id,
+ "name": v.Name,
+ "owner": v.Owner,
+ })
+
+ return objVal, diags
+}
+
+func (v DatabasesValue) Equal(o attr.Value) bool {
+ other, ok := o.(DatabasesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Created.Equal(other.Created) {
+ return false
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.Name.Equal(other.Name) {
+ return false
+ }
+
+ if !v.Owner.Equal(other.Owner) {
+ return false
+ }
+
+ return true
+}
+
+func (v DatabasesValue) Type(ctx context.Context) attr.Type {
+ return DatabasesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v DatabasesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "created": basetypes.StringType{},
+ "id": basetypes.Int64Type{},
+ "name": basetypes.StringType{},
+ "owner": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/database/mapper.go b/stackit/internal/services/sqlserverflexalpha/database/mapper.go
new file mode 100644
index 00000000..55d0e5ae
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/database/mapper.go
@@ -0,0 +1,104 @@
+package sqlserverflexalpha
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+// mapFields maps fields from a ListDatabase API response to a resourceModel for the data source.
+func mapFields(source *sqlserverflexalpha.GetDatabaseResponse, model *dataSourceModel, region string) error {
+ if source == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if source.Id == nil || *source.Id == 0 {
+ return fmt.Errorf("id not present")
+ }
+ if model == nil {
+ return fmt.Errorf("model given is nil")
+ }
+
+ var databaseId int64
+ if model.Id.ValueInt64() != 0 {
+ databaseId = model.Id.ValueInt64()
+ } else if source.Id != nil {
+ databaseId = *source.Id
+ } else {
+ return fmt.Errorf("database id not present")
+ }
+
+ model.Id = types.Int64Value(databaseId)
+ model.DatabaseName = types.StringValue(source.GetName())
+ model.Name = types.StringValue(source.GetName())
+ model.Owner = types.StringValue(strings.Trim(source.GetOwner(), "\""))
+ model.Region = types.StringValue(region)
+ model.ProjectId = types.StringValue(model.ProjectId.ValueString())
+ model.InstanceId = types.StringValue(model.InstanceId.ValueString())
+ model.CompatibilityLevel = types.Int64Value(source.GetCompatibilityLevel())
+ model.CollationName = types.StringValue(source.GetCollationName())
+
+ model.TerraformId = utils.BuildInternalTerraformId(
+ model.ProjectId.ValueString(),
+ region,
+ model.InstanceId.ValueString(),
+ model.DatabaseName.ValueString(),
+ )
+
+ return nil
+}
+
+// mapResourceFields maps fields from a ListDatabase API response to a resourceModel for the resource.
+func mapResourceFields(source *sqlserverflexalpha.GetDatabaseResponse, model *resourceModel, region string) error {
+ if source == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if source.Id == nil || *source.Id == 0 {
+ return fmt.Errorf("id not present")
+ }
+ if model == nil {
+ return fmt.Errorf("model input is nil")
+ }
+
+ var databaseId int64
+ if model.Id.ValueInt64() != 0 {
+ databaseId = model.Id.ValueInt64()
+ } else if source.Id != nil {
+ databaseId = *source.Id
+ } else {
+ return fmt.Errorf("database id not present")
+ }
+
+ model.Id = types.Int64Value(databaseId)
+ model.DatabaseName = types.StringValue(source.GetName())
+ model.Name = types.StringValue(source.GetName())
+ model.Owner = types.StringValue(strings.Trim(source.GetOwner(), "\""))
+ model.Region = types.StringValue(region)
+ model.ProjectId = types.StringValue(model.ProjectId.ValueString())
+ model.InstanceId = types.StringValue(model.InstanceId.ValueString())
+
+ model.Compatibility = types.Int64Value(source.GetCompatibilityLevel())
+ model.CompatibilityLevel = types.Int64Value(source.GetCompatibilityLevel())
+
+ model.Collation = types.StringValue(source.GetCollationName()) // it does not come back from api
+ model.CollationName = types.StringValue(source.GetCollationName())
+
+ return nil
+}
+
+// toCreatePayload converts the resource model to an API create payload.
+func toCreatePayload(model *resourceModel) (*sqlserverflexalpha.CreateDatabaseRequestPayload, error) {
+ if model == nil {
+ return nil, fmt.Errorf("nil model")
+ }
+
+ return &sqlserverflexalpha.CreateDatabaseRequestPayload{
+ Name: model.Name.ValueStringPointer(),
+ Owner: model.Owner.ValueStringPointer(),
+ Collation: model.Collation.ValueStringPointer(),
+ Compatibility: model.Compatibility.ValueInt64Pointer(),
+ }, nil
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/database/mapper_test.go b/stackit/internal/services/sqlserverflexalpha/database/mapper_test.go
new file mode 100644
index 00000000..b0daa742
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/database/mapper_test.go
@@ -0,0 +1,232 @@
+package sqlserverflexalpha
+
+import (
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+ datasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database/datasources_gen"
+)
+
+func TestMapFields(t *testing.T) {
+ type given struct {
+ source *sqlserverflexalpha.GetDatabaseResponse
+ model *dataSourceModel
+ region string
+ }
+ type expected struct {
+ model *dataSourceModel
+ err bool
+ }
+
+ testcases := []struct {
+ name string
+ given given
+ expected expected
+ }{
+ {
+ name: "should map fields correctly",
+ given: given{
+ source: &sqlserverflexalpha.GetDatabaseResponse{
+ Id: utils.Ptr(int64(1)),
+ Name: utils.Ptr("my-db"),
+ CollationName: utils.Ptr("collation"),
+ CompatibilityLevel: utils.Ptr(int64(150)),
+ Owner: utils.Ptr("my-owner"),
+ },
+ model: &dataSourceModel{
+ DatabaseModel: datasource.DatabaseModel{
+ ProjectId: types.StringValue("my-project"),
+ InstanceId: types.StringValue("my-instance"),
+ },
+ },
+ region: "eu01",
+ },
+ expected: expected{
+ model: &dataSourceModel{
+ DatabaseModel: datasource.DatabaseModel{
+ Id: types.Int64Value(1),
+ Name: types.StringValue("my-db"),
+ DatabaseName: types.StringValue("my-db"),
+ Owner: types.StringValue("my-owner"),
+ Region: types.StringValue("eu01"),
+ InstanceId: types.StringValue("my-instance"),
+ ProjectId: types.StringValue("my-project"),
+ CompatibilityLevel: types.Int64Value(150),
+ CollationName: types.StringValue("collation"),
+ },
+ TerraformId: types.StringValue("my-project,eu01,my-instance,my-db"),
+ },
+ },
+ },
+ {
+ name: "should fail on nil source",
+ given: given{
+ source: nil,
+ model: &dataSourceModel{},
+ },
+ expected: expected{err: true},
+ },
+ {
+ name: "should fail on nil source ID",
+ given: given{
+ source: &sqlserverflexalpha.GetDatabaseResponse{Id: nil},
+ model: &dataSourceModel{},
+ },
+ expected: expected{err: true},
+ },
+ {
+ name: "should fail on nil model",
+ given: given{
+ source: &sqlserverflexalpha.GetDatabaseResponse{Id: utils.Ptr(int64(1))},
+ model: nil,
+ },
+ expected: expected{err: true},
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ err := mapFields(tc.given.source, tc.given.model, tc.given.region)
+ if (err != nil) != tc.expected.err {
+ t.Fatalf("expected error: %v, got: %v", tc.expected.err, err)
+ }
+ if err == nil {
+ if diff := cmp.Diff(tc.expected.model, tc.given.model); diff != "" {
+ t.Errorf("model mismatch (-want +got):\n%s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestMapResourceFields(t *testing.T) {
+ type given struct {
+ source *sqlserverflexalpha.GetDatabaseResponse
+ model *resourceModel
+ region string
+ }
+ type expected struct {
+ model *resourceModel
+ err bool
+ }
+
+ testcases := []struct {
+ name string
+ given given
+ expected expected
+ }{
+ {
+ name: "should map fields correctly",
+ given: given{
+ source: &sqlserverflexalpha.GetDatabaseResponse{
+ Id: utils.Ptr(int64(1)),
+ Name: utils.Ptr("my-db"),
+ Owner: utils.Ptr("my-owner"),
+ },
+ model: &resourceModel{
+ ProjectId: types.StringValue("my-project"),
+ InstanceId: types.StringValue("my-instance"),
+ },
+ region: "eu01",
+ },
+ expected: expected{
+ model: &resourceModel{
+ Id: types.Int64Value(1),
+ Name: types.StringValue("my-db"),
+ Compatibility: types.Int64Value(0),
+ CompatibilityLevel: types.Int64Value(0),
+ Collation: types.StringValue(""),
+ CollationName: types.StringValue(""),
+ DatabaseName: types.StringValue("my-db"),
+ InstanceId: types.StringValue("my-instance"),
+ ProjectId: types.StringValue("my-project"),
+ Region: types.StringValue("eu01"),
+ Owner: types.StringValue("my-owner"),
+ },
+ },
+ },
+ {
+ name: "should fail on nil source",
+ given: given{
+ source: nil,
+ model: &resourceModel{},
+ },
+ expected: expected{err: true},
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ err := mapResourceFields(tc.given.source, tc.given.model, tc.given.region)
+ if (err != nil) != tc.expected.err {
+ t.Fatalf("expected error: %v, got: %v", tc.expected.err, err)
+ }
+ if err == nil {
+ if diff := cmp.Diff(tc.expected.model, tc.given.model); diff != "" {
+ t.Errorf("model mismatch (-want +got):\n%s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestToCreatePayload(t *testing.T) {
+ type given struct {
+ model *resourceModel
+ }
+ type expected struct {
+ payload *sqlserverflexalpha.CreateDatabaseRequestPayload
+ err bool
+ }
+
+ testcases := []struct {
+ name string
+ given given
+ expected expected
+ }{
+ {
+ name: "should convert model to payload",
+ given: given{
+ model: &resourceModel{
+ Name: types.StringValue("my-db"),
+ Owner: types.StringValue("my-owner"),
+ },
+ },
+ expected: expected{
+ payload: &sqlserverflexalpha.CreateDatabaseRequestPayload{
+ Name: utils.Ptr("my-db"),
+ Owner: utils.Ptr("my-owner"),
+ },
+ },
+ },
+ {
+ name: "should fail on nil model",
+ given: given{model: nil},
+ expected: expected{err: true},
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ actual, err := toCreatePayload(tc.given.model)
+ if (err != nil) != tc.expected.err {
+ t.Fatalf("expected error: %v, got: %v", tc.expected.err, err)
+ }
+ if err == nil {
+ if diff := cmp.Diff(tc.expected.payload, actual); diff != "" {
+ t.Errorf("payload mismatch (-want +got):\n%s", diff)
+ }
+ }
+ },
+ )
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/database/planModifiers.yaml b/stackit/internal/services/sqlserverflexalpha/database/planModifiers.yaml
new file mode 100644
index 00000000..1d010ed7
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/database/planModifiers.yaml
@@ -0,0 +1,51 @@
+fields:
+ - name: 'id'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'instance_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'project_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'region'
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'name'
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'collation'
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'owner'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'database_name'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'collation_name'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'compatibility'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'compatibility_level'
+ modifiers:
+ - 'UseStateForUnknown'
diff --git a/stackit/internal/services/sqlserverflexalpha/database/resource.go b/stackit/internal/services/sqlserverflexalpha/database/resource.go
new file mode 100644
index 00000000..5b46c52c
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/database/resource.go
@@ -0,0 +1,539 @@
+package sqlserverflexalpha
+
+import (
+ "context"
+ _ "embed"
+ "errors"
+ "fmt"
+ "net/http"
+ "strings"
+ "time"
+
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+ "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ wait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexalpha"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexalphaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database/resources_gen"
+)
+
+var (
+ _ resource.Resource = &databaseResource{}
+ _ resource.ResourceWithConfigure = &databaseResource{}
+ _ resource.ResourceWithImportState = &databaseResource{}
+ _ resource.ResourceWithModifyPlan = &databaseResource{}
+ _ resource.ResourceWithIdentity = &databaseResource{}
+
+ // Define errors
+ errDatabaseNotFound = errors.New("database not found")
+)
+
+func NewDatabaseResource() resource.Resource {
+ return &databaseResource{}
+}
+
+// resourceModel describes the resource data model.
+type resourceModel = sqlserverflexalphaResGen.DatabaseModel
+
+type databaseResource struct {
+ client *sqlserverflexalpha.APIClient
+ providerData core.ProviderData
+}
+
+type DatabaseResourceIdentityModel struct {
+ ProjectID types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ InstanceID types.String `tfsdk:"instance_id"`
+ DatabaseName types.String `tfsdk:"database_name"`
+}
+
+func (r *databaseResource) Metadata(
+ _ context.Context,
+ req resource.MetadataRequest,
+ resp *resource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_database"
+}
+
+//go:embed planModifiers.yaml
+var modifiersFileByte []byte
+
+func (r *databaseResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
+ s := sqlserverflexalphaResGen.DatabaseResourceSchema(ctx)
+
+ fields, err := utils.ReadModifiersConfig(modifiersFileByte)
+ if err != nil {
+ resp.Diagnostics.AddError("error during read modifiers config file", err.Error())
+ return
+ }
+
+ err = utils.AddPlanModifiersToResourceSchema(fields, &s)
+ if err != nil {
+ resp.Diagnostics.AddError("error adding plan modifiers", err.Error())
+ return
+ }
+ resp.Schema = s
+}
+
+func (r *databaseResource) IdentitySchema(
+ _ context.Context,
+ _ resource.IdentitySchemaRequest,
+ resp *resource.IdentitySchemaResponse,
+) {
+ resp.IdentitySchema = identityschema.Schema{
+ Attributes: map[string]identityschema.Attribute{
+ "project_id": identityschema.StringAttribute{
+ RequiredForImport: true, // must be set during import by the practitioner
+ },
+ "region": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ "instance_id": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ "database_name": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ },
+ }
+}
+
+// Configure adds the provider configured client to the resource.
+func (r *databaseResource) Configure(
+ ctx context.Context,
+ req resource.ConfigureRequest,
+ resp *resource.ConfigureResponse,
+) {
+ var ok bool
+ r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(r.providerData.RoundTripper),
+ utils.UserAgentConfigOption(r.providerData.Version),
+ }
+ if r.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(r.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(apiClientConfigOptions, config.WithRegion(r.providerData.GetRegion()))
+ }
+ apiClient, err := sqlserverflexalpha.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ r.client = apiClient
+ tflog.Info(ctx, "sqlserverflexalpha.Database client configured")
+}
+
+func (r *databaseResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
+ var data resourceModel
+ createErr := "DB create error"
+
+ // Read Terraform plan data into the model
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := data.ProjectId.ValueString()
+ region := data.Region.ValueString()
+ instanceId := data.InstanceId.ValueString()
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+
+ databaseName := data.Name.ValueString()
+ ctx = tflog.SetField(ctx, "database_name", databaseName)
+
+ payLoad := sqlserverflexalpha.CreateDatabaseRequestPayload{}
+ if !data.Collation.IsNull() && !data.Collation.IsUnknown() {
+ payLoad.Collation = data.Collation.ValueStringPointer()
+ }
+
+ if !data.Compatibility.IsNull() && !data.Compatibility.IsUnknown() {
+ payLoad.Compatibility = data.Compatibility.ValueInt64Pointer()
+ }
+
+ payLoad.Name = data.Name.ValueStringPointer()
+ payLoad.Owner = data.Owner.ValueStringPointer()
+
+ createResp, err := r.client.CreateDatabaseRequest(ctx, projectId, region, instanceId).
+ CreateDatabaseRequestPayload(payLoad).
+ Execute()
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ fmt.Sprintf("Calling API: %v", err),
+ )
+ return
+ }
+
+ if createResp == nil || createResp.Id == nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating database",
+ "API didn't return database Id. A database might have been created",
+ )
+ return
+ }
+
+ databaseId := *createResp.Id
+
+ ctx = tflog.SetField(ctx, "database_id", databaseId)
+
+ ctx = core.LogResponse(ctx)
+
+ // Set data returned by API in identity
+ identity := DatabaseResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ DatabaseName: types.StringValue(databaseName),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // TODO: is this necessary to wait for the database-> API say 200 ?
+ waitResp, err := wait.CreateDatabaseWaitHandler(
+ ctx,
+ r.client,
+ projectId,
+ instanceId,
+ region,
+ databaseName,
+ ).SetSleepBeforeWait(
+ 30 * time.Second,
+ ).SetTimeout(
+ 15 * time.Minute,
+ ).WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ fmt.Sprintf("Database creation waiting: %v", err),
+ )
+ return
+ }
+
+ if waitResp.Id == nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ "Database creation waiting: returned id is nil",
+ )
+ return
+ }
+
+ if *waitResp.Id != databaseId {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ "Database creation waiting: returned id is different",
+ )
+ return
+ }
+
+ if *waitResp.Owner != data.Owner.ValueString() {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ "Database creation waiting: returned owner is different",
+ )
+ return
+ }
+
+ if *waitResp.Name != data.Name.ValueString() {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ "Database creation waiting: returned name is different",
+ )
+ return
+ }
+
+ database, err := r.client.GetDatabaseRequest(ctx, projectId, region, instanceId, databaseName).Execute()
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating database",
+ fmt.Sprintf("Getting database details after creation: %v", err),
+ )
+ return
+ }
+
+ // Map response body to schema
+ err = mapResourceFields(database, &data, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating database",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Set state to fully populated data
+ resp.Diagnostics.Append(resp.State.Set(ctx, data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Save data into Terraform state
+
+ tflog.Info(ctx, "sqlserverflexalpha.Database created")
+}
+
+func (r *databaseResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
+ var model resourceModel
+ diags := req.State.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ region := model.Region.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ databaseName := model.DatabaseName.ValueString()
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "database_name", databaseName)
+
+ databaseResp, err := r.client.GetDatabaseRequest(ctx, projectId, region, instanceId, databaseName).Execute()
+ if err != nil {
+ oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
+ if (ok && oapiErr.StatusCode == http.StatusNotFound) || errors.Is(err, errDatabaseNotFound) {
+ resp.State.RemoveResource(ctx)
+ return
+ }
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading database", fmt.Sprintf("Calling API: %v", err))
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ // Map response body to schema
+ err = mapResourceFields(databaseResp, &model, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading database",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Save identity into Terraform state
+ identity := DatabaseResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ DatabaseName: types.StringValue(databaseName),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Set refreshed state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &model)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ tflog.Info(ctx, "sqlserverflexalpha.Database read")
+}
+
+func (r *databaseResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) {
+ // TODO: Check update api endpoint - not available at the moment, so return an error for now
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating database", "Database can't be updated")
+}
+
+func (r *databaseResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
+ // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
+ diags := req.State.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Read identity data
+ var identityData DatabaseResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ region := model.Region.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ databaseName := model.DatabaseName.ValueString()
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "database_name", databaseName)
+
+ // Delete existing record set
+ err := r.client.DeleteDatabaseRequestExecute(ctx, projectId, region, instanceId, databaseName)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error deleting database",
+ fmt.Sprintf(
+ "Calling API: %v\nname: %s, region: %s, instanceId: %s", err, databaseName, region, instanceId,
+ ),
+ )
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+ resp.State.RemoveResource(ctx)
+
+ tflog.Info(ctx, "sqlserverflexalpha.Database deleted")
+}
+
+// ModifyPlan implements resource.ResourceWithModifyPlan.
+// Use the modifier to set the effective region in the current plan.
+func (r *databaseResource) ModifyPlan(
+ ctx context.Context,
+ req resource.ModifyPlanRequest,
+ resp *resource.ModifyPlanResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ // skip initial empty configuration to avoid follow-up errors
+ if req.Config.Raw.IsNull() {
+ return
+ }
+
+ var configModel resourceModel
+ resp.Diagnostics.Append(req.Config.Get(ctx, &configModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ var planModel resourceModel
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+}
+
+// ImportState imports a resource into the Terraform state on success.
+// The expected format of the resource import identifier is: project_id,zone_id,record_set_id
+func (r *databaseResource) ImportState(
+ ctx context.Context,
+ req resource.ImportStateRequest,
+ resp *resource.ImportStateResponse,
+) {
+ ctx = core.InitProviderContext(ctx)
+
+ if req.ID != "" {
+ idParts := strings.Split(req.ID, core.Separator)
+
+ if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" {
+ core.LogAndAddError(
+ ctx, &resp.Diagnostics,
+ "Error importing database",
+ fmt.Sprintf(
+ "Expected import identifier with format [project_id],[region],[instance_id],[database_name] Got: %q",
+ req.ID,
+ ),
+ )
+ return
+ }
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("database_name"), idParts[3])...)
+
+ var identityData DatabaseResourceIdentityModel
+ identityData.ProjectID = types.StringValue(idParts[0])
+ identityData.Region = types.StringValue(idParts[1])
+ identityData.InstanceID = types.StringValue(idParts[2])
+ identityData.DatabaseName = types.StringValue(idParts[3])
+
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ tflog.Info(ctx, "sqlserverflexalpha database state imported")
+ return
+ }
+
+ // If no ID is provided, attempt to read identity attributes from the import configuration
+ var identityData DatabaseResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ instanceId := identityData.InstanceID.ValueString()
+ databaseName := identityData.DatabaseName.ValueString()
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), projectId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), region)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), instanceId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("database_name"), databaseName)...)
+
+ tflog.Info(ctx, "sqlserverflexalpha database state imported")
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/database/resources_gen/database_resource_gen.go b/stackit/internal/services/sqlserverflexalpha/database/resources_gen/database_resource_gen.go
new file mode 100644
index 00000000..8e5886ad
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/database/resources_gen/database_resource_gen.go
@@ -0,0 +1,99 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexalpha
+
+import (
+ "context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+)
+
+func DatabaseResourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "collation": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ MarkdownDescription: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ },
+ "collation_name": schema.StringAttribute{
+ Computed: true,
+ Description: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ MarkdownDescription: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ },
+ "compatibility": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "CompatibilityLevel of the Database.",
+ MarkdownDescription: "CompatibilityLevel of the Database.",
+ },
+ "compatibility_level": schema.Int64Attribute{
+ Computed: true,
+ Description: "CompatibilityLevel of the Database.",
+ MarkdownDescription: "CompatibilityLevel of the Database.",
+ },
+ "database_name": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The id of the database.",
+ MarkdownDescription: "The id of the database.",
+ },
+ "instance_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "name": schema.StringAttribute{
+ Required: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "owner": schema.StringAttribute{
+ Required: true,
+ Description: "The owner of the database.",
+ MarkdownDescription: "The owner of the database.",
+ },
+ "project_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type DatabaseModel struct {
+ Collation types.String `tfsdk:"collation"`
+ CollationName types.String `tfsdk:"collation_name"`
+ Compatibility types.Int64 `tfsdk:"compatibility"`
+ CompatibilityLevel types.Int64 `tfsdk:"compatibility_level"`
+ DatabaseName types.String `tfsdk:"database_name"`
+ Id types.Int64 `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Name types.String `tfsdk:"name"`
+ Owner types.String `tfsdk:"owner"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/flavor/datasource.go b/stackit/internal/services/sqlserverflexalpha/flavor/datasource.go
new file mode 100644
index 00000000..d56aafa5
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/flavor/datasource.go
@@ -0,0 +1,355 @@
+package sqlserverflexalphaFlavor
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexalphaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+ sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/flavor/datasources_gen"
+)
+
+// Ensure the implementation satisfies the expected interfaces.
+var (
+ _ datasource.DataSource = &flavorDataSource{}
+ _ datasource.DataSourceWithConfigure = &flavorDataSource{}
+)
+
+type FlavorModel struct {
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ StorageClass types.String `tfsdk:"storage_class"`
+ Cpu types.Int64 `tfsdk:"cpu"`
+ Description types.String `tfsdk:"description"`
+ Id types.String `tfsdk:"id"`
+ FlavorId types.String `tfsdk:"flavor_id"`
+ MaxGb types.Int64 `tfsdk:"max_gb"`
+ Memory types.Int64 `tfsdk:"ram"`
+ MinGb types.Int64 `tfsdk:"min_gb"`
+ NodeType types.String `tfsdk:"node_type"`
+ StorageClasses types.List `tfsdk:"storage_classes"`
+}
+
+// NewFlavorDataSource is a helper function to simplify the provider implementation.
+func NewFlavorDataSource() datasource.DataSource {
+ return &flavorDataSource{}
+}
+
+// flavorDataSource is the data source implementation.
+type flavorDataSource struct {
+ client *sqlserverflexalphaPkg.APIClient
+ providerData core.ProviderData
+}
+
+// Metadata returns the data source type name.
+func (r *flavorDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_flavor"
+}
+
+// Configure adds the provider configured client to the data source.
+func (r *flavorDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
+ var ok bool
+ r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(r.providerData.RoundTripper),
+ utils.UserAgentConfigOption(r.providerData.Version),
+ }
+ if r.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(r.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithRegion(r.providerData.GetRegion()),
+ )
+ }
+ apiClient, err := sqlserverflexalphaPkg.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ r.client = apiClient
+ tflog.Info(ctx, "SQL Server Flex instance client configured")
+}
+
+func (r *flavorDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The project ID of the flavor.",
+ MarkdownDescription: "The project ID of the flavor.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region of the flavor.",
+ MarkdownDescription: "The region of the flavor.",
+ },
+ "cpu": schema.Int64Attribute{
+ Required: true,
+ Description: "The cpu count of the instance.",
+ MarkdownDescription: "The cpu count of the instance.",
+ },
+ "ram": schema.Int64Attribute{
+ Required: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "storage_class": schema.StringAttribute{
+ Required: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "node_type": schema.StringAttribute{
+ Required: true,
+ Description: "defines the nodeType it can be either single or HA",
+ MarkdownDescription: "defines the nodeType it can be either single or HA",
+ },
+ "flavor_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "description": schema.StringAttribute{
+ Computed: true,
+ Description: "The flavor description.",
+ MarkdownDescription: "The flavor description.",
+ },
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "max_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ "min_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "minimum storage which is required to order in Gigabyte.",
+ MarkdownDescription: "minimum storage which is required to order in Gigabyte.",
+ },
+ "storage_classes": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Computed: true,
+ },
+ "max_io_per_sec": schema.Int64Attribute{
+ Computed: true,
+ },
+ "max_through_in_mb": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: sqlserverflexalphaGen.StorageClassesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: sqlserverflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ },
+ //Attributes: map[string]schema.Attribute{
+ // "project_id": schema.StringAttribute{
+ // Required: true,
+ // Description: "The cpu count of the instance.",
+ // MarkdownDescription: "The cpu count of the instance.",
+ // },
+ // "region": schema.StringAttribute{
+ // Required: true,
+ // Description: "The flavor description.",
+ // MarkdownDescription: "The flavor description.",
+ // },
+ // "cpu": schema.Int64Attribute{
+ // Required: true,
+ // Description: "The cpu count of the instance.",
+ // MarkdownDescription: "The cpu count of the instance.",
+ // },
+ // "ram": schema.Int64Attribute{
+ // Required: true,
+ // Description: "The memory of the instance in Gibibyte.",
+ // MarkdownDescription: "The memory of the instance in Gibibyte.",
+ // },
+ // "storage_class": schema.StringAttribute{
+ // Required: true,
+ // Description: "The memory of the instance in Gibibyte.",
+ // MarkdownDescription: "The memory of the instance in Gibibyte.",
+ // },
+ // "description": schema.StringAttribute{
+ // Computed: true,
+ // Description: "The flavor description.",
+ // MarkdownDescription: "The flavor description.",
+ // },
+ // "id": schema.StringAttribute{
+ // Computed: true,
+ // Description: "The terraform id of the instance flavor.",
+ // MarkdownDescription: "The terraform id of the instance flavor.",
+ // },
+ // "flavor_id": schema.StringAttribute{
+ // Computed: true,
+ // Description: "The flavor id of the instance flavor.",
+ // MarkdownDescription: "The flavor id of the instance flavor.",
+ // },
+ // "max_gb": schema.Int64Attribute{
+ // Computed: true,
+ // Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ // MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ // },
+ // "min_gb": schema.Int64Attribute{
+ // Computed: true,
+ // Description: "minimum storage which is required to order in Gigabyte.",
+ // MarkdownDescription: "minimum storage which is required to order in Gigabyte.",
+ // },
+ // "node_type": schema.StringAttribute{
+ // Required: true,
+ // Description: "defines the nodeType it can be either single or replica",
+ // MarkdownDescription: "defines the nodeType it can be either single or replica",
+ // },
+ // "storage_classes": schema.ListNestedAttribute{
+ // Computed: true,
+ // NestedObject: schema.NestedAttributeObject{
+ // Attributes: map[string]schema.Attribute{
+ // "class": schema.StringAttribute{
+ // Computed: true,
+ // },
+ // "max_io_per_sec": schema.Int64Attribute{
+ // Computed: true,
+ // },
+ // "max_through_in_mb": schema.Int64Attribute{
+ // Computed: true,
+ // },
+ // },
+ // CustomType: sqlserverflexalphaGen.StorageClassesType{
+ // ObjectType: types.ObjectType{
+ // AttrTypes: sqlserverflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ // },
+ // },
+ // },
+ // },
+ // },
+ }
+}
+
+func (r *flavorDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var model FlavorModel
+ diags := req.Config.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ region := r.providerData.GetRegionWithOverride(model.Region)
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ flavors, err := getAllFlavors(ctx, r.client, projectId, region)
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading flavors", fmt.Sprintf("getAllFlavors: %v", err))
+ return
+ }
+
+ var foundFlavors []sqlserverflexalphaPkg.ListFlavors
+ for _, flavor := range flavors {
+ if model.Cpu.ValueInt64() != *flavor.Cpu {
+ continue
+ }
+ if model.Memory.ValueInt64() != *flavor.Memory {
+ continue
+ }
+ if model.NodeType.ValueString() != *flavor.NodeType {
+ continue
+ }
+ for _, sc := range *flavor.StorageClasses {
+ if model.StorageClass.ValueString() != *sc.Class {
+ continue
+ }
+ foundFlavors = append(foundFlavors, flavor)
+ }
+ }
+ if len(foundFlavors) == 0 {
+ resp.Diagnostics.AddError("get flavor", "could not find requested flavor")
+ return
+ }
+ if len(foundFlavors) > 1 {
+ resp.Diagnostics.AddError("get flavor", "found too many matching flavors")
+ return
+ }
+
+ f := foundFlavors[0]
+ model.Description = types.StringValue(*f.Description)
+ model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), region, *f.Id)
+ model.FlavorId = types.StringValue(*f.Id)
+ model.MaxGb = types.Int64Value(*f.MaxGB)
+ model.MinGb = types.Int64Value(*f.MinGB)
+
+ if f.StorageClasses == nil {
+ model.StorageClasses = types.ListNull(sqlserverflexalphaGen.StorageClassesType{
+ ObjectType: basetypes.ObjectType{
+ AttrTypes: sqlserverflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ })
+ } else {
+ var scList []attr.Value
+ for _, sc := range *f.StorageClasses {
+ scList = append(
+ scList,
+ sqlserverflexalphaGen.NewStorageClassesValueMust(
+ sqlserverflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "class": types.StringValue(*sc.Class),
+ "max_io_per_sec": types.Int64Value(*sc.MaxIoPerSec),
+ "max_through_in_mb": types.Int64Value(*sc.MaxThroughInMb),
+ },
+ ),
+ )
+ }
+ storageClassesList := types.ListValueMust(
+ sqlserverflexalphaGen.StorageClassesType{
+ ObjectType: basetypes.ObjectType{
+ AttrTypes: sqlserverflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ scList,
+ )
+ model.StorageClasses = storageClassesList
+ }
+
+ // Set refreshed state
+ diags = resp.State.Set(ctx, model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ tflog.Info(ctx, "SQL Server Flex flavors read")
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/flavor/datasources_gen/flavor_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/flavor/datasources_gen/flavor_data_source_gen.go
new file mode 100644
index 00000000..d8654cf4
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/flavor/datasources_gen/flavor_data_source_gen.go
@@ -0,0 +1,1909 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func FlavorDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "flavors": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "cpu": schema.Int64Attribute{
+ Computed: true,
+ Description: "The cpu count of the instance.",
+ MarkdownDescription: "The cpu count of the instance.",
+ },
+ "description": schema.StringAttribute{
+ Computed: true,
+ Description: "The flavor description.",
+ MarkdownDescription: "The flavor description.",
+ },
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "max_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ "memory": schema.Int64Attribute{
+ Computed: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "min_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "minimum storage which is required to order in Gigabyte.",
+ MarkdownDescription: "minimum storage which is required to order in Gigabyte.",
+ },
+ "node_type": schema.StringAttribute{
+ Computed: true,
+ Description: "defines the nodeType it can be either single or HA",
+ MarkdownDescription: "defines the nodeType it can be either single or HA",
+ },
+ "storage_classes": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Computed: true,
+ },
+ "max_io_per_sec": schema.Int64Attribute{
+ Computed: true,
+ },
+ "max_through_in_mb": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: StorageClassesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ },
+ CustomType: FlavorsType{
+ ObjectType: types.ObjectType{
+ AttrTypes: FlavorsValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of flavors available for the project.",
+ MarkdownDescription: "List of flavors available for the project.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the flavors to be returned on each page.",
+ MarkdownDescription: "Sorting of the flavors to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "index.desc",
+ "index.asc",
+ "cpu.desc",
+ "cpu.asc",
+ "flavor_description.asc",
+ "flavor_description.desc",
+ "id.desc",
+ "id.asc",
+ "size_max.desc",
+ "size_max.asc",
+ "ram.desc",
+ "ram.asc",
+ "size_min.desc",
+ "size_min.asc",
+ "storage_class.asc",
+ "storage_class.desc",
+ "node_type.asc",
+ "node_type.desc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type FlavorModel struct {
+ Flavors types.List `tfsdk:"flavors"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = FlavorsType{}
+
+type FlavorsType struct {
+ basetypes.ObjectType
+}
+
+func (t FlavorsType) Equal(o attr.Type) bool {
+ other, ok := o.(FlavorsType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t FlavorsType) String() string {
+ return "FlavorsType"
+}
+
+func (t FlavorsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return nil, diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return nil, diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return nil, diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return nil, diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return nil, diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueNull() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewFlavorsValueUnknown() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewFlavorsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (FlavorsValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, a missing attribute value was detected. "+
+ "A FlavorsValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid FlavorsValue Attribute Type",
+ "While creating a FlavorsValue value, an invalid attribute value was detected. "+
+ "A FlavorsValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, an extra attribute value was detected. "+
+ "A FlavorsValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra FlavorsValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) FlavorsValue {
+ object, diags := NewFlavorsValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewFlavorsValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t FlavorsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewFlavorsValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewFlavorsValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewFlavorsValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewFlavorsValueMust(FlavorsValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t FlavorsType) ValueType(ctx context.Context) attr.Value {
+ return FlavorsValue{}
+}
+
+var _ basetypes.ObjectValuable = FlavorsValue{}
+
+type FlavorsValue struct {
+ Cpu basetypes.Int64Value `tfsdk:"cpu"`
+ Description basetypes.StringValue `tfsdk:"description"`
+ Id basetypes.StringValue `tfsdk:"id"`
+ MaxGb basetypes.Int64Value `tfsdk:"max_gb"`
+ Memory basetypes.Int64Value `tfsdk:"memory"`
+ MinGb basetypes.Int64Value `tfsdk:"min_gb"`
+ NodeType basetypes.StringValue `tfsdk:"node_type"`
+ StorageClasses basetypes.ListValue `tfsdk:"storage_classes"`
+ state attr.ValueState
+}
+
+func (v FlavorsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 8)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["cpu"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["description"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["memory"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["min_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["node_type"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["storage_classes"] = basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ }.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 8)
+
+ val, err = v.Cpu.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["cpu"] = val
+
+ val, err = v.Description.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["description"] = val
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.MaxGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_gb"] = val
+
+ val, err = v.Memory.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["memory"] = val
+
+ val, err = v.MinGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["min_gb"] = val
+
+ val, err = v.NodeType.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["node_type"] = val
+
+ val, err = v.StorageClasses.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["storage_classes"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v FlavorsValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v FlavorsValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v FlavorsValue) String() string {
+ return "FlavorsValue"
+}
+
+func (v FlavorsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ storageClasses := types.ListValueMust(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ v.StorageClasses.Elements(),
+ )
+
+ if v.StorageClasses.IsNull() {
+ storageClasses = types.ListNull(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ if v.StorageClasses.IsUnknown() {
+ storageClasses = types.ListUnknown(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "cpu": v.Cpu,
+ "description": v.Description,
+ "id": v.Id,
+ "max_gb": v.MaxGb,
+ "memory": v.Memory,
+ "min_gb": v.MinGb,
+ "node_type": v.NodeType,
+ "storage_classes": storageClasses,
+ })
+
+ return objVal, diags
+}
+
+func (v FlavorsValue) Equal(o attr.Value) bool {
+ other, ok := o.(FlavorsValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Cpu.Equal(other.Cpu) {
+ return false
+ }
+
+ if !v.Description.Equal(other.Description) {
+ return false
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.MaxGb.Equal(other.MaxGb) {
+ return false
+ }
+
+ if !v.Memory.Equal(other.Memory) {
+ return false
+ }
+
+ if !v.MinGb.Equal(other.MinGb) {
+ return false
+ }
+
+ if !v.NodeType.Equal(other.NodeType) {
+ return false
+ }
+
+ if !v.StorageClasses.Equal(other.StorageClasses) {
+ return false
+ }
+
+ return true
+}
+
+func (v FlavorsValue) Type(ctx context.Context) attr.Type {
+ return FlavorsType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v FlavorsValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageClassesType{}
+
+type StorageClassesType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageClassesType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageClassesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageClassesType) String() string {
+ return "StorageClassesType"
+}
+
+func (t StorageClassesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return nil, diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return nil, diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueNull() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageClassesValueUnknown() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageClassesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageClassesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, a missing attribute value was detected. "+
+ "A StorageClassesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageClassesValue Attribute Type",
+ "While creating a StorageClassesValue value, an invalid attribute value was detected. "+
+ "A StorageClassesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, an extra attribute value was detected. "+
+ "A StorageClassesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageClassesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageClassesValue {
+ object, diags := NewStorageClassesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageClassesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageClassesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageClassesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageClassesValueMust(StorageClassesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageClassesType) ValueType(ctx context.Context) attr.Value {
+ return StorageClassesValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageClassesValue{}
+
+type StorageClassesValue struct {
+ Class basetypes.StringValue `tfsdk:"class"`
+ MaxIoPerSec basetypes.Int64Value `tfsdk:"max_io_per_sec"`
+ MaxThroughInMb basetypes.Int64Value `tfsdk:"max_through_in_mb"`
+ state attr.ValueState
+}
+
+func (v StorageClassesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 3)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_io_per_sec"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["max_through_in_mb"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 3)
+
+ val, err = v.Class.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["class"] = val
+
+ val, err = v.MaxIoPerSec.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_io_per_sec"] = val
+
+ val, err = v.MaxThroughInMb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_through_in_mb"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageClassesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageClassesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageClassesValue) String() string {
+ return "StorageClassesValue"
+}
+
+func (v StorageClassesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "class": v.Class,
+ "max_io_per_sec": v.MaxIoPerSec,
+ "max_through_in_mb": v.MaxThroughInMb,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageClassesValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageClassesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Class.Equal(other.Class) {
+ return false
+ }
+
+ if !v.MaxIoPerSec.Equal(other.MaxIoPerSec) {
+ return false
+ }
+
+ if !v.MaxThroughInMb.Equal(other.MaxThroughInMb) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageClassesValue) Type(ctx context.Context) attr.Type {
+ return StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageClassesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/flavor/functions.go b/stackit/internal/services/sqlserverflexalpha/flavor/functions.go
new file mode 100644
index 00000000..469b7bce
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/flavor/functions.go
@@ -0,0 +1,65 @@
+package sqlserverflexalphaFlavor
+
+import (
+ "context"
+ "fmt"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+)
+
+type flavorsClientReader interface {
+ GetFlavorsRequest(
+ ctx context.Context,
+ projectId, region string,
+ ) sqlserverflexalpha.ApiGetFlavorsRequestRequest
+}
+
+func getAllFlavors(ctx context.Context, client flavorsClientReader, projectId, region string) (
+ []sqlserverflexalpha.ListFlavors,
+ error,
+) {
+ getAllFilter := func(_ sqlserverflexalpha.ListFlavors) bool { return true }
+ flavorList, err := getFlavorsByFilter(ctx, client, projectId, region, getAllFilter)
+ if err != nil {
+ return nil, err
+ }
+ return flavorList, nil
+}
+
+// getFlavorsByFilter is a helper function to retrieve flavors using a filtern function.
+// Hint: The API does not have a GetFlavors endpoint, only ListFlavors
+func getFlavorsByFilter(
+ ctx context.Context,
+ client flavorsClientReader,
+ projectId, region string,
+ filter func(db sqlserverflexalpha.ListFlavors) bool,
+) ([]sqlserverflexalpha.ListFlavors, error) {
+ if projectId == "" || region == "" {
+ return nil, fmt.Errorf("listing sqlserverflexalpha flavors: projectId and region are required")
+ }
+
+ const pageSize = 25
+
+ var result = make([]sqlserverflexalpha.ListFlavors, 0)
+
+ for page := int64(1); ; page++ {
+ res, err := client.GetFlavorsRequest(ctx, projectId, region).
+ Page(page).Size(pageSize).Sort(sqlserverflexalpha.FLAVORSORT_INDEX_ASC).Execute()
+ if err != nil {
+ return nil, fmt.Errorf("requesting flavors list (page %d): %w", page, err)
+ }
+
+ // If the API returns no flavors, we have reached the end of the list.
+ if res.Flavors == nil || len(*res.Flavors) == 0 {
+ break
+ }
+
+ for _, flavor := range *res.Flavors {
+ if filter(flavor) {
+ result = append(result, flavor)
+ }
+ }
+ }
+
+ return result, nil
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/flavor/functions_test.go b/stackit/internal/services/sqlserverflexalpha/flavor/functions_test.go
new file mode 100644
index 00000000..bed6462c
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/flavor/functions_test.go
@@ -0,0 +1,135 @@
+package sqlserverflexalphaFlavor
+
+import (
+ "context"
+ "testing"
+
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+)
+
+type mockRequest struct {
+ executeFunc func() (*sqlserverflexalpha.GetFlavorsResponse, error)
+}
+
+func (m *mockRequest) Page(_ int64) sqlserverflexalpha.ApiGetFlavorsRequestRequest { return m }
+func (m *mockRequest) Size(_ int64) sqlserverflexalpha.ApiGetFlavorsRequestRequest { return m }
+func (m *mockRequest) Sort(_ sqlserverflexalpha.FlavorSort) sqlserverflexalpha.ApiGetFlavorsRequestRequest {
+ return m
+}
+func (m *mockRequest) Execute() (*sqlserverflexalpha.GetFlavorsResponse, error) {
+ return m.executeFunc()
+}
+
+type mockFlavorsClient struct {
+ executeRequest func() sqlserverflexalpha.ApiGetFlavorsRequestRequest
+}
+
+func (m *mockFlavorsClient) GetFlavorsRequest(_ context.Context, _, _ string) sqlserverflexalpha.ApiGetFlavorsRequestRequest {
+ return m.executeRequest()
+}
+
+var mockResp = func(page int64) (*sqlserverflexalpha.GetFlavorsResponse, error) {
+ if page == 1 {
+ return &sqlserverflexalpha.GetFlavorsResponse{
+ Flavors: &[]sqlserverflexalpha.ListFlavors{
+ {Id: utils.Ptr("flavor-1"), Description: utils.Ptr("first")},
+ {Id: utils.Ptr("flavor-2"), Description: utils.Ptr("second")},
+ },
+ }, nil
+ }
+ if page == 2 {
+ return &sqlserverflexalpha.GetFlavorsResponse{
+ Flavors: &[]sqlserverflexalpha.ListFlavors{
+ {Id: utils.Ptr("flavor-3"), Description: utils.Ptr("three")},
+ },
+ }, nil
+ }
+
+ return &sqlserverflexalpha.GetFlavorsResponse{
+ Flavors: &[]sqlserverflexalpha.ListFlavors{},
+ }, nil
+}
+
+func TestGetFlavorsByFilter(t *testing.T) {
+ tests := []struct {
+ description string
+ projectId string
+ region string
+ mockErr error
+ filter func(sqlserverflexalpha.ListFlavors) bool
+ wantCount int
+ wantErr bool
+ }{
+ {
+ description: "Success - Get all flavors (2 pages)",
+ projectId: "pid", region: "reg",
+ filter: func(_ sqlserverflexalpha.ListFlavors) bool { return true },
+ wantCount: 3,
+ wantErr: false,
+ },
+ {
+ description: "Success - Filter flavors by description",
+ projectId: "pid", region: "reg",
+ filter: func(f sqlserverflexalpha.ListFlavors) bool { return *f.Description == "first" },
+ wantCount: 1,
+ wantErr: false,
+ },
+ {
+ description: "Error - Missing parameters",
+ projectId: "", region: "reg",
+ wantErr: true,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ var currentPage int64
+ client := &mockFlavorsClient{
+ executeRequest: func() sqlserverflexalpha.ApiGetFlavorsRequestRequest {
+ return &mockRequest{
+ executeFunc: func() (*sqlserverflexalpha.GetFlavorsResponse, error) {
+ currentPage++
+ return mockResp(currentPage)
+ },
+ }
+ },
+ }
+ actual, err := getFlavorsByFilter(context.Background(), client, tt.projectId, tt.region, tt.filter)
+
+ if (err != nil) != tt.wantErr {
+ t.Errorf("getFlavorsByFilter() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+
+ if !tt.wantErr && len(actual) != tt.wantCount {
+ t.Errorf("getFlavorsByFilter() got %d flavors, want %d", len(actual), tt.wantCount)
+ }
+ },
+ )
+ }
+}
+
+func TestGetAllFlavors(t *testing.T) {
+ var currentPage int64
+ client := &mockFlavorsClient{
+ executeRequest: func() sqlserverflexalpha.ApiGetFlavorsRequestRequest {
+ return &mockRequest{
+ executeFunc: func() (*sqlserverflexalpha.GetFlavorsResponse, error) {
+ currentPage++
+ return mockResp(currentPage)
+ },
+ }
+ },
+ }
+
+ res, err := getAllFlavors(context.Background(), client, "pid", "reg")
+ if err != nil {
+ t.Errorf("getAllFlavors() unexpected error: %v", err)
+ }
+ if len(res) != 3 {
+ t.Errorf("getAllFlavors() expected 3 flavor, got %d", len(res))
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/flavors/datasource.go b/stackit/internal/services/sqlserverflexalpha/flavors/datasource.go
new file mode 100644
index 00000000..2286e81b
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/flavors/datasource.go
@@ -0,0 +1,156 @@
+package sqlserverflexalpha
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexalphaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+
+ sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/flavors/datasources_gen"
+)
+
+var _ datasource.DataSource = (*flavorsDataSource)(nil)
+
+const errorPrefix = "[sqlserverflexalpha - Flavors]"
+
+func NewFlavorsDataSource() datasource.DataSource {
+ return &flavorsDataSource{}
+}
+
+type dataSourceModel struct {
+ sqlserverflexalphaGen.FlavorsModel
+ TerraformId types.String `tfsdk:"id"`
+}
+
+type flavorsDataSource struct {
+ client *sqlserverflexalphaPkg.APIClient
+ providerData core.ProviderData
+}
+
+func (d *flavorsDataSource) Metadata(
+ _ context.Context,
+ req datasource.MetadataRequest,
+ resp *datasource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_flavors"
+}
+
+func (d *flavorsDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = sqlserverflexalphaGen.FlavorsDataSourceSchema(ctx)
+ resp.Schema.Attributes["id"] = schema.StringAttribute{
+ Computed: true,
+ Description: "The terraform internal identifier.",
+ MarkdownDescription: "The terraform internal identifier.",
+ }
+}
+
+// Configure adds the provider configured client to the data source.
+func (d *flavorsDataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
+ var ok bool
+ d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(d.providerData.RoundTripper),
+ utils.UserAgentConfigOption(d.providerData.Version),
+ }
+ if d.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(d.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithRegion(d.providerData.GetRegion()),
+ )
+ }
+ apiClient, err := sqlserverflexalphaPkg.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ d.client = apiClient
+ tflog.Info(ctx, fmt.Sprintf("%s client configured", errorPrefix))
+}
+
+func (d *flavorsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var data dataSourceModel
+
+ // Read Terraform configuration data into the model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := data.ProjectId.ValueString()
+ region := d.providerData.GetRegionWithOverride(data.Region)
+ // TODO: implement right identifier for flavors
+ flavorsId := data.Flavors
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ // TODO: implement needed fields
+ ctx = tflog.SetField(ctx, "flavors_id", flavorsId)
+
+ // TODO: refactor to correct implementation
+ _, err := d.client.GetFlavorsRequest(ctx, projectId, region).Execute()
+ if err != nil {
+ utils.LogError(
+ ctx,
+ &resp.Diagnostics,
+ err,
+ "Reading flavors",
+ fmt.Sprintf("flavors with ID %q does not exist in project %q.", flavorsId, projectId),
+ map[int]string{
+ http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId),
+ },
+ )
+ resp.State.RemoveResource(ctx)
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ // TODO: refactor to correct implementation of internal tf id
+ data.TerraformId = utils.BuildInternalTerraformId(projectId, region)
+
+ // TODO: fill remaining fields
+ // data.Flavors = types.Sometype(apiResponse.GetFlavors())
+ // data.Page = types.Sometype(apiResponse.GetPage())
+ // data.Pagination = types.Sometype(apiResponse.GetPagination())
+ // data.ProjectId = types.Sometype(apiResponse.GetProjectId())
+ // data.Region = types.Sometype(apiResponse.GetRegion())
+ // data.Size = types.Sometype(apiResponse.GetSize())
+ // data.Sort = types.Sometype(apiResponse.GetSort())// Save data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+
+ tflog.Info(ctx, fmt.Sprintf("%s read successful", errorPrefix))
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/flavors/datasources_gen/flavors_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/flavors/datasources_gen/flavors_data_source_gen.go
new file mode 100644
index 00000000..40f086e2
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/flavors/datasources_gen/flavors_data_source_gen.go
@@ -0,0 +1,1909 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func FlavorsDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "flavors": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "cpu": schema.Int64Attribute{
+ Computed: true,
+ Description: "The cpu count of the instance.",
+ MarkdownDescription: "The cpu count of the instance.",
+ },
+ "description": schema.StringAttribute{
+ Computed: true,
+ Description: "The flavor description.",
+ MarkdownDescription: "The flavor description.",
+ },
+ "tf_original_api_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "max_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ "memory": schema.Int64Attribute{
+ Computed: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "min_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "minimum storage which is required to order in Gigabyte.",
+ MarkdownDescription: "minimum storage which is required to order in Gigabyte.",
+ },
+ "node_type": schema.StringAttribute{
+ Computed: true,
+ Description: "defines the nodeType it can be either single or HA",
+ MarkdownDescription: "defines the nodeType it can be either single or HA",
+ },
+ "storage_classes": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Computed: true,
+ },
+ "max_io_per_sec": schema.Int64Attribute{
+ Computed: true,
+ },
+ "max_through_in_mb": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: StorageClassesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ },
+ CustomType: FlavorsType{
+ ObjectType: types.ObjectType{
+ AttrTypes: FlavorsValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of flavors available for the project.",
+ MarkdownDescription: "List of flavors available for the project.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the flavors to be returned on each page.",
+ MarkdownDescription: "Sorting of the flavors to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "index.desc",
+ "index.asc",
+ "cpu.desc",
+ "cpu.asc",
+ "flavor_description.asc",
+ "flavor_description.desc",
+ "id.desc",
+ "id.asc",
+ "size_max.desc",
+ "size_max.asc",
+ "ram.desc",
+ "ram.asc",
+ "size_min.desc",
+ "size_min.asc",
+ "storage_class.asc",
+ "storage_class.desc",
+ "node_type.asc",
+ "node_type.desc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type FlavorsModel struct {
+ Flavors types.List `tfsdk:"flavors"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = FlavorsType{}
+
+type FlavorsType struct {
+ basetypes.ObjectType
+}
+
+func (t FlavorsType) Equal(o attr.Type) bool {
+ other, ok := o.(FlavorsType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t FlavorsType) String() string {
+ return "FlavorsType"
+}
+
+func (t FlavorsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return nil, diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return nil, diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return nil, diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return nil, diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return nil, diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueNull() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewFlavorsValueUnknown() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewFlavorsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (FlavorsValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, a missing attribute value was detected. "+
+ "A FlavorsValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid FlavorsValue Attribute Type",
+ "While creating a FlavorsValue value, an invalid attribute value was detected. "+
+ "A FlavorsValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, an extra attribute value was detected. "+
+ "A FlavorsValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra FlavorsValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) FlavorsValue {
+ object, diags := NewFlavorsValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewFlavorsValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t FlavorsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewFlavorsValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewFlavorsValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewFlavorsValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewFlavorsValueMust(FlavorsValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t FlavorsType) ValueType(ctx context.Context) attr.Value {
+ return FlavorsValue{}
+}
+
+var _ basetypes.ObjectValuable = FlavorsValue{}
+
+type FlavorsValue struct {
+ Cpu basetypes.Int64Value `tfsdk:"cpu"`
+ Description basetypes.StringValue `tfsdk:"description"`
+ Id basetypes.StringValue `tfsdk:"id"`
+ MaxGb basetypes.Int64Value `tfsdk:"max_gb"`
+ Memory basetypes.Int64Value `tfsdk:"memory"`
+ MinGb basetypes.Int64Value `tfsdk:"min_gb"`
+ NodeType basetypes.StringValue `tfsdk:"node_type"`
+ StorageClasses basetypes.ListValue `tfsdk:"storage_classes"`
+ state attr.ValueState
+}
+
+func (v FlavorsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 8)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["cpu"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["description"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["memory"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["min_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["node_type"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["storage_classes"] = basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ }.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 8)
+
+ val, err = v.Cpu.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["cpu"] = val
+
+ val, err = v.Description.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["description"] = val
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.MaxGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_gb"] = val
+
+ val, err = v.Memory.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["memory"] = val
+
+ val, err = v.MinGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["min_gb"] = val
+
+ val, err = v.NodeType.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["node_type"] = val
+
+ val, err = v.StorageClasses.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["storage_classes"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v FlavorsValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v FlavorsValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v FlavorsValue) String() string {
+ return "FlavorsValue"
+}
+
+func (v FlavorsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ storageClasses := types.ListValueMust(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ v.StorageClasses.Elements(),
+ )
+
+ if v.StorageClasses.IsNull() {
+ storageClasses = types.ListNull(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ if v.StorageClasses.IsUnknown() {
+ storageClasses = types.ListUnknown(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "cpu": v.Cpu,
+ "description": v.Description,
+ "id": v.Id,
+ "max_gb": v.MaxGb,
+ "memory": v.Memory,
+ "min_gb": v.MinGb,
+ "node_type": v.NodeType,
+ "storage_classes": storageClasses,
+ })
+
+ return objVal, diags
+}
+
+func (v FlavorsValue) Equal(o attr.Value) bool {
+ other, ok := o.(FlavorsValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Cpu.Equal(other.Cpu) {
+ return false
+ }
+
+ if !v.Description.Equal(other.Description) {
+ return false
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.MaxGb.Equal(other.MaxGb) {
+ return false
+ }
+
+ if !v.Memory.Equal(other.Memory) {
+ return false
+ }
+
+ if !v.MinGb.Equal(other.MinGb) {
+ return false
+ }
+
+ if !v.NodeType.Equal(other.NodeType) {
+ return false
+ }
+
+ if !v.StorageClasses.Equal(other.StorageClasses) {
+ return false
+ }
+
+ return true
+}
+
+func (v FlavorsValue) Type(ctx context.Context) attr.Type {
+ return FlavorsType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v FlavorsValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageClassesType{}
+
+type StorageClassesType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageClassesType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageClassesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageClassesType) String() string {
+ return "StorageClassesType"
+}
+
+func (t StorageClassesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return nil, diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return nil, diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueNull() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageClassesValueUnknown() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageClassesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageClassesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, a missing attribute value was detected. "+
+ "A StorageClassesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageClassesValue Attribute Type",
+ "While creating a StorageClassesValue value, an invalid attribute value was detected. "+
+ "A StorageClassesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, an extra attribute value was detected. "+
+ "A StorageClassesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageClassesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageClassesValue {
+ object, diags := NewStorageClassesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageClassesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageClassesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageClassesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageClassesValueMust(StorageClassesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageClassesType) ValueType(ctx context.Context) attr.Value {
+ return StorageClassesValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageClassesValue{}
+
+type StorageClassesValue struct {
+ Class basetypes.StringValue `tfsdk:"class"`
+ MaxIoPerSec basetypes.Int64Value `tfsdk:"max_io_per_sec"`
+ MaxThroughInMb basetypes.Int64Value `tfsdk:"max_through_in_mb"`
+ state attr.ValueState
+}
+
+func (v StorageClassesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 3)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_io_per_sec"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["max_through_in_mb"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 3)
+
+ val, err = v.Class.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["class"] = val
+
+ val, err = v.MaxIoPerSec.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_io_per_sec"] = val
+
+ val, err = v.MaxThroughInMb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_through_in_mb"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageClassesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageClassesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageClassesValue) String() string {
+ return "StorageClassesValue"
+}
+
+func (v StorageClassesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "class": v.Class,
+ "max_io_per_sec": v.MaxIoPerSec,
+ "max_through_in_mb": v.MaxThroughInMb,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageClassesValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageClassesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Class.Equal(other.Class) {
+ return false
+ }
+
+ if !v.MaxIoPerSec.Equal(other.MaxIoPerSec) {
+ return false
+ }
+
+ if !v.MaxThroughInMb.Equal(other.MaxThroughInMb) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageClassesValue) Type(ctx context.Context) attr.Type {
+ return StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageClassesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/instance/datasource.go b/stackit/internal/services/sqlserverflexalpha/instance/datasource.go
index 6cac7466..123b1fe8 100644
--- a/stackit/internal/services/sqlserverflexalpha/instance/datasource.go
+++ b/stackit/internal/services/sqlserverflexalpha/instance/datasource.go
@@ -1,232 +1,125 @@
-package sqlserverflex
+package sqlserverflexalpha
import (
"context"
"fmt"
"net/http"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- sqlserverflexUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/sqlserverflexalpha/utils"
-
- sqlserverflex "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
-
"github.com/hashicorp/terraform-plugin-framework/datasource"
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
- "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexalphaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+
+ sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen"
)
-// Ensure the implementation satisfies the expected interfaces.
-var (
- _ datasource.DataSource = &instanceDataSource{}
-)
+var _ datasource.DataSource = (*instanceDataSource)(nil)
+
+const errorPrefix = "[sqlserverflexalpha - Instance]"
-// NewInstanceDataSource is a helper function to simplify the provider implementation.
func NewInstanceDataSource() datasource.DataSource {
return &instanceDataSource{}
}
-// instanceDataSource is the data source implementation.
+// dataSourceModel maps the data source schema data.
+type dataSourceModel struct {
+ sqlserverflexalphaGen.InstanceModel
+ TerraformID types.String `tfsdk:"id"`
+}
+
type instanceDataSource struct {
- client *sqlserverflex.APIClient
+ client *sqlserverflexalphaPkg.APIClient
providerData core.ProviderData
}
-// Metadata returns the data source type name.
-func (r *instanceDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
+func (d *instanceDataSource) Metadata(
+ _ context.Context,
+ req datasource.MetadataRequest,
+ resp *datasource.MetadataResponse,
+) {
resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_instance"
}
+func (d *instanceDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = sqlserverflexalphaGen.InstanceDataSourceSchema(ctx)
+}
+
// Configure adds the provider configured client to the data source.
-func (r *instanceDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
+func (d *instanceDataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
var ok bool
- r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
if !ok {
return
}
- apiClient := sqlserverflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics)
- if resp.Diagnostics.HasError() {
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(d.providerData.RoundTripper),
+ utils.UserAgentConfigOption(d.providerData.Version),
+ }
+ if d.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(d.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithRegion(d.providerData.GetRegion()),
+ )
+ }
+ apiClient, err := sqlserverflexalphaPkg.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
return
}
- r.client = apiClient
- tflog.Info(ctx, "SQLServer Flex instance client configured")
+ d.client = apiClient
+ tflog.Info(ctx, fmt.Sprintf("%s client configured", errorPrefix))
}
-// Schema defines the schema for the data source.
-func (r *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
- descriptions := map[string]string{
- "main": "SQLServer Flex instance data source schema. Must have a `region` specified in the provider configuration.",
- "id": "Terraform's internal data source. ID. It is structured as \"`project_id`,`region`,`instance_id`\".",
- "instance_id": "ID of the SQLServer Flex instance.",
- "project_id": "STACKIT project ID to which the instance is associated.",
- "name": "Instance name.",
- "acl": "The Access Control List (ACL) for the SQLServer Flex instance.",
- "backup_schedule": `The backup schedule. Should follow the cron scheduling system format (e.g. "0 0 * * *").`,
- "options": "Custom parameters for the SQLServer Flex instance.",
- "region": "The resource region. If not defined, the provider region is used.",
- // TODO
- }
+func (d *instanceDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var data dataSourceModel
- resp.Schema = schema.Schema{
- Description: descriptions["main"],
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Description: descriptions["id"],
- Computed: true,
- },
- "instance_id": schema.StringAttribute{
- Description: descriptions["instance_id"],
- Required: true,
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "project_id": schema.StringAttribute{
- Description: descriptions["project_id"],
- Required: true,
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "name": schema.StringAttribute{
- Description: descriptions["name"],
- Computed: true,
- },
- "backup_schedule": schema.StringAttribute{
- Description: descriptions["backup_schedule"],
- Computed: true,
- },
- "flavor": schema.SingleNestedAttribute{
- Computed: true,
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Computed: true,
- },
- "description": schema.StringAttribute{
- Computed: true,
- },
- "cpu": schema.Int64Attribute{
- Computed: true,
- },
- "ram": schema.Int64Attribute{
- Computed: true,
- },
- },
- },
- "replicas": schema.Int64Attribute{
- Computed: true,
- },
- "storage": schema.SingleNestedAttribute{
- Computed: true,
- Attributes: map[string]schema.Attribute{
- "class": schema.StringAttribute{
- Computed: true,
- },
- "size": schema.Int64Attribute{
- Computed: true,
- },
- },
- },
- "version": schema.StringAttribute{
- Computed: true,
- },
- "status": schema.StringAttribute{
- Computed: true,
- },
- "edition": schema.StringAttribute{
- Computed: true,
- },
- "retention_days": schema.Int64Attribute{
- Computed: true,
- },
- "region": schema.StringAttribute{
- // the region cannot be found, so it has to be passed
- Optional: true,
- Description: descriptions["region"],
- },
- "encryption": schema.SingleNestedAttribute{
- Computed: true,
- Attributes: map[string]schema.Attribute{
- "key_id": schema.StringAttribute{
- Description: descriptions["key_id"],
- Computed: true,
- },
- "key_version": schema.StringAttribute{
- Description: descriptions["key_version"],
- Computed: true,
- },
- "keyring_id": schema.StringAttribute{
- Description: descriptions["keyring_id"],
- Computed: true,
- },
- "service_account": schema.StringAttribute{
- Description: descriptions["service_account"],
- Computed: true,
- },
- },
- Description: descriptions["encryption"],
- },
- "network": schema.SingleNestedAttribute{
- Computed: true,
- Attributes: map[string]schema.Attribute{
- "access_scope": schema.StringAttribute{
- Description: descriptions["access_scope"],
- Computed: true,
- },
- "instance_address": schema.StringAttribute{
- Description: descriptions["instance_address"],
- Computed: true,
- },
- "router_address": schema.StringAttribute{
- Description: descriptions["router_address"],
- Computed: true,
- },
- "acl": schema.ListAttribute{
- Description: descriptions["acl"],
- ElementType: types.StringType,
- Computed: true,
- },
- },
- Description: descriptions["network"],
- },
- },
- }
-}
+ // Read Terraform configuration data into the model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
-// Read refreshes the Terraform state with the latest data.
-func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
- var model Model
- diags := req.Config.Get(ctx, &model)
- resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- region := r.providerData.GetRegionWithOverride(model.Region)
+ projectId := data.ProjectId.ValueString()
+ region := d.providerData.GetRegionWithOverride(data.Region)
+ instanceId := data.InstanceId.ValueString()
+
ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
ctx = tflog.SetField(ctx, "region", region)
- instanceResp, err := r.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+
+ instanceResp, err := d.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
if err != nil {
utils.LogError(
ctx,
&resp.Diagnostics,
err,
"Reading instance",
- fmt.Sprintf("Instance with ID %q does not exist in project %q.", instanceId, projectId),
+ fmt.Sprintf("instance with ID %q does not exist in project %q.", instanceId, projectId),
map[int]string{
http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId),
},
@@ -237,59 +130,17 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
ctx = core.LogResponse(ctx)
- var flavor = &flavorModel{}
- if model.Flavor.IsNull() || model.Flavor.IsUnknown() {
- flavor.Id = types.StringValue(*instanceResp.FlavorId)
- if flavor.Id.IsNull() || flavor.Id.IsUnknown() || flavor.Id.String() == "" {
- panic("WTF FlavorId can not be null or empty string")
- }
- err = getFlavorModelById(ctx, r.client, &model, flavor)
- if err != nil {
- resp.Diagnostics.AddError(err.Error(), err.Error())
- return
- }
- if flavor.CPU.IsNull() || flavor.CPU.IsUnknown() || flavor.CPU.String() == "" {
- panic("WTF FlavorId can not be null or empty string")
- }
- }
-
- var storage = &storageModel{}
- if !(model.Storage.IsNull() || model.Storage.IsUnknown()) {
- diags = model.Storage.As(ctx, storage, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var encryption = &encryptionModel{}
- if !(model.Encryption.IsNull() || model.Encryption.IsUnknown()) {
- diags = model.Encryption.As(ctx, encryption, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var network = &networkModel{}
- if !(model.Network.IsNull() || model.Network.IsUnknown()) {
- diags = model.Network.As(ctx, network, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- err = mapFields(ctx, instanceResp, &model, flavor, storage, encryption, network, region)
+ err = mapDataResponseToModel(ctx, instanceResp, &data, resp.Diagnostics)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API payload: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ fmt.Sprintf("%s Read", errorPrefix),
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
return
}
- // Set refreshed state
- diags = resp.State.Set(ctx, model)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- tflog.Info(ctx, "SQLServer Flex instance read")
+
+ // Save data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}
diff --git a/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen/instance_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen/instance_data_source_gen.go
new file mode 100644
index 00000000..5880a392
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen/instance_data_source_gen.go
@@ -0,0 +1,1579 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func InstanceDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "backup_schedule": schema.StringAttribute{
+ Computed: true,
+ Description: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ MarkdownDescription: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ },
+ "edition": schema.StringAttribute{
+ Computed: true,
+ Description: "Edition of the MSSQL server instance",
+ MarkdownDescription: "Edition of the MSSQL server instance",
+ },
+ "encryption": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "kek_key_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The key identifier",
+ MarkdownDescription: "The key identifier",
+ },
+ "kek_key_ring_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The keyring identifier",
+ MarkdownDescription: "The keyring identifier",
+ },
+ "kek_key_version": schema.StringAttribute{
+ Computed: true,
+ Description: "The key version",
+ MarkdownDescription: "The key version",
+ },
+ "service_account": schema.StringAttribute{
+ Computed: true,
+ },
+ },
+ CustomType: EncryptionType{
+ ObjectType: types.ObjectType{
+ AttrTypes: EncryptionValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "this defines which key to use for storage encryption",
+ MarkdownDescription: "this defines which key to use for storage encryption",
+ },
+ "flavor_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "tf_original_api_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "is_deletable": schema.BoolAttribute{
+ Computed: true,
+ Description: "Whether the instance can be deleted or not.",
+ MarkdownDescription: "Whether the instance can be deleted or not.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the instance.",
+ MarkdownDescription: "The name of the instance.",
+ },
+ "network": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "access_scope": schema.StringAttribute{
+ Computed: true,
+ Description: "The network access scope of the instance\n\n⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ MarkdownDescription: "The network access scope of the instance\n\n⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ },
+ "acl": schema.ListAttribute{
+ ElementType: types.StringType,
+ Computed: true,
+ Description: "List of IPV4 cidr.",
+ MarkdownDescription: "List of IPV4 cidr.",
+ },
+ "instance_address": schema.StringAttribute{
+ Computed: true,
+ },
+ "router_address": schema.StringAttribute{
+ Computed: true,
+ },
+ },
+ CustomType: NetworkType{
+ ObjectType: types.ObjectType{
+ AttrTypes: NetworkValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "The access configuration of the instance",
+ MarkdownDescription: "The access configuration of the instance",
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "replicas": schema.Int64Attribute{
+ Computed: true,
+ Description: "How many replicas the instance should have.",
+ MarkdownDescription: "How many replicas the instance should have.",
+ },
+ "retention_days": schema.Int64Attribute{
+ Computed: true,
+ Description: "The days for how long the backup files should be stored before cleaned up. 30 to 365",
+ MarkdownDescription: "The days for how long the backup files should be stored before cleaned up. 30 to 365",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ },
+ "storage": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Computed: true,
+ Description: "The storage class for the storage.",
+ MarkdownDescription: "The storage class for the storage.",
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ Description: "The storage size in Gigabytes.",
+ MarkdownDescription: "The storage size in Gigabytes.",
+ },
+ },
+ CustomType: StorageType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "The object containing information about the storage size and class.",
+ MarkdownDescription: "The object containing information about the storage size and class.",
+ },
+ "version": schema.StringAttribute{
+ Computed: true,
+ Description: "The sqlserver version used for the instance.",
+ MarkdownDescription: "The sqlserver version used for the instance.",
+ },
+ },
+ }
+}
+
+type InstanceModel struct {
+ BackupSchedule types.String `tfsdk:"backup_schedule"`
+ Edition types.String `tfsdk:"edition"`
+ Encryption EncryptionValue `tfsdk:"encryption"`
+ FlavorId types.String `tfsdk:"flavor_id"`
+ Id types.String `tfsdk:"tf_original_api_id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ IsDeletable types.Bool `tfsdk:"is_deletable"`
+ Name types.String `tfsdk:"name"`
+ Network NetworkValue `tfsdk:"network"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Replicas types.Int64 `tfsdk:"replicas"`
+ RetentionDays types.Int64 `tfsdk:"retention_days"`
+ Status types.String `tfsdk:"status"`
+ Storage StorageValue `tfsdk:"storage"`
+ Version types.String `tfsdk:"version"`
+}
+
+var _ basetypes.ObjectTypable = EncryptionType{}
+
+type EncryptionType struct {
+ basetypes.ObjectType
+}
+
+func (t EncryptionType) Equal(o attr.Type) bool {
+ other, ok := o.(EncryptionType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t EncryptionType) String() string {
+ return "EncryptionType"
+}
+
+func (t EncryptionType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return nil, diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueNull() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewEncryptionValueUnknown() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewEncryptionValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (EncryptionValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, a missing attribute value was detected. "+
+ "A EncryptionValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid EncryptionValue Attribute Type",
+ "While creating a EncryptionValue value, an invalid attribute value was detected. "+
+ "A EncryptionValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, an extra attribute value was detected. "+
+ "A EncryptionValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra EncryptionValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) EncryptionValue {
+ object, diags := NewEncryptionValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewEncryptionValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t EncryptionType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewEncryptionValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewEncryptionValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewEncryptionValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewEncryptionValueMust(EncryptionValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t EncryptionType) ValueType(ctx context.Context) attr.Value {
+ return EncryptionValue{}
+}
+
+var _ basetypes.ObjectValuable = EncryptionValue{}
+
+type EncryptionValue struct {
+ KekKeyId basetypes.StringValue `tfsdk:"kek_key_id"`
+ KekKeyRingId basetypes.StringValue `tfsdk:"kek_key_ring_id"`
+ KekKeyVersion basetypes.StringValue `tfsdk:"kek_key_version"`
+ ServiceAccount basetypes.StringValue `tfsdk:"service_account"`
+ state attr.ValueState
+}
+
+func (v EncryptionValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["kek_key_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_ring_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_version"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["service_account"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.KekKeyId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_id"] = val
+
+ val, err = v.KekKeyRingId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_ring_id"] = val
+
+ val, err = v.KekKeyVersion.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_version"] = val
+
+ val, err = v.ServiceAccount.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["service_account"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v EncryptionValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v EncryptionValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v EncryptionValue) String() string {
+ return "EncryptionValue"
+}
+
+func (v EncryptionValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "kek_key_id": v.KekKeyId,
+ "kek_key_ring_id": v.KekKeyRingId,
+ "kek_key_version": v.KekKeyVersion,
+ "service_account": v.ServiceAccount,
+ })
+
+ return objVal, diags
+}
+
+func (v EncryptionValue) Equal(o attr.Value) bool {
+ other, ok := o.(EncryptionValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.KekKeyId.Equal(other.KekKeyId) {
+ return false
+ }
+
+ if !v.KekKeyRingId.Equal(other.KekKeyRingId) {
+ return false
+ }
+
+ if !v.KekKeyVersion.Equal(other.KekKeyVersion) {
+ return false
+ }
+
+ if !v.ServiceAccount.Equal(other.ServiceAccount) {
+ return false
+ }
+
+ return true
+}
+
+func (v EncryptionValue) Type(ctx context.Context) attr.Type {
+ return EncryptionType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v EncryptionValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = NetworkType{}
+
+type NetworkType struct {
+ basetypes.ObjectType
+}
+
+func (t NetworkType) Equal(o attr.Type) bool {
+ other, ok := o.(NetworkType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t NetworkType) String() string {
+ return "NetworkType"
+}
+
+func (t NetworkType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return nil, diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return nil, diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return nil, diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return nil, diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueNull() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewNetworkValueUnknown() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewNetworkValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (NetworkValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing NetworkValue Attribute Value",
+ "While creating a NetworkValue value, a missing attribute value was detected. "+
+ "A NetworkValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid NetworkValue Attribute Type",
+ "While creating a NetworkValue value, an invalid attribute value was detected. "+
+ "A NetworkValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra NetworkValue Attribute Value",
+ "While creating a NetworkValue value, an extra attribute value was detected. "+
+ "A NetworkValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra NetworkValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) NetworkValue {
+ object, diags := NewNetworkValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewNetworkValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t NetworkType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewNetworkValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewNetworkValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewNetworkValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewNetworkValueMust(NetworkValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t NetworkType) ValueType(ctx context.Context) attr.Value {
+ return NetworkValue{}
+}
+
+var _ basetypes.ObjectValuable = NetworkValue{}
+
+type NetworkValue struct {
+ AccessScope basetypes.StringValue `tfsdk:"access_scope"`
+ Acl basetypes.ListValue `tfsdk:"acl"`
+ InstanceAddress basetypes.StringValue `tfsdk:"instance_address"`
+ RouterAddress basetypes.StringValue `tfsdk:"router_address"`
+ state attr.ValueState
+}
+
+func (v NetworkValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["access_scope"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["acl"] = basetypes.ListType{
+ ElemType: types.StringType,
+ }.TerraformType(ctx)
+ attrTypes["instance_address"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["router_address"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.AccessScope.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["access_scope"] = val
+
+ val, err = v.Acl.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["acl"] = val
+
+ val, err = v.InstanceAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["instance_address"] = val
+
+ val, err = v.RouterAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["router_address"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v NetworkValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v NetworkValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v NetworkValue) String() string {
+ return "NetworkValue"
+}
+
+func (v NetworkValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ var aclVal basetypes.ListValue
+ switch {
+ case v.Acl.IsUnknown():
+ aclVal = types.ListUnknown(types.StringType)
+ case v.Acl.IsNull():
+ aclVal = types.ListNull(types.StringType)
+ default:
+ var d diag.Diagnostics
+ aclVal, d = types.ListValue(types.StringType, v.Acl.Elements())
+ diags.Append(d...)
+ }
+
+ if diags.HasError() {
+ return types.ObjectUnknown(map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }), diags
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "access_scope": v.AccessScope,
+ "acl": aclVal,
+ "instance_address": v.InstanceAddress,
+ "router_address": v.RouterAddress,
+ })
+
+ return objVal, diags
+}
+
+func (v NetworkValue) Equal(o attr.Value) bool {
+ other, ok := o.(NetworkValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.AccessScope.Equal(other.AccessScope) {
+ return false
+ }
+
+ if !v.Acl.Equal(other.Acl) {
+ return false
+ }
+
+ if !v.InstanceAddress.Equal(other.InstanceAddress) {
+ return false
+ }
+
+ if !v.RouterAddress.Equal(other.RouterAddress) {
+ return false
+ }
+
+ return true
+}
+
+func (v NetworkValue) Type(ctx context.Context) attr.Type {
+ return NetworkType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v NetworkValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageType{}
+
+type StorageType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageType) String() string {
+ return "StorageType"
+}
+
+func (t StorageType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return nil, diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageValue{
+ Class: classVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueNull() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageValueUnknown() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageValue Attribute Value",
+ "While creating a StorageValue value, a missing attribute value was detected. "+
+ "A StorageValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageValue Attribute Type",
+ "While creating a StorageValue value, an invalid attribute value was detected. "+
+ "A StorageValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageValue Attribute Value",
+ "While creating a StorageValue value, an extra attribute value was detected. "+
+ "A StorageValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ return StorageValue{
+ Class: classVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageValue {
+ object, diags := NewStorageValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageValueMust(StorageValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageType) ValueType(ctx context.Context) attr.Value {
+ return StorageValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageValue{}
+
+type StorageValue struct {
+ Class basetypes.StringValue `tfsdk:"class"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ state attr.ValueState
+}
+
+func (v StorageValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 2)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 2)
+
+ val, err = v.Class.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["class"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageValue) String() string {
+ return "StorageValue"
+}
+
+func (v StorageValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "class": v.Class,
+ "size": v.Size,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Class.Equal(other.Class) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageValue) Type(ctx context.Context) attr.Type {
+ return StorageType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen/instances_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen/instances_data_source_gen.go
new file mode 100644
index 00000000..33df0a5d
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen/instances_data_source_gen.go
@@ -0,0 +1,1172 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func InstancesDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "instances": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "is_deletable": schema.BoolAttribute{
+ Computed: true,
+ Description: "Whether the instance can be deleted or not.",
+ MarkdownDescription: "Whether the instance can be deleted or not.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the instance.",
+ MarkdownDescription: "The name of the instance.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ },
+ },
+ CustomType: InstancesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: InstancesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of owned instances and their current status.",
+ MarkdownDescription: "List of owned instances and their current status.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the items to be returned on each page.",
+ MarkdownDescription: "Sorting of the items to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "index.desc",
+ "index.asc",
+ "id.desc",
+ "id.asc",
+ "is_deletable.desc",
+ "is_deletable.asc",
+ "name.asc",
+ "name.desc",
+ "status.asc",
+ "status.desc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type InstancesModel struct {
+ Instances types.List `tfsdk:"instances"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = InstancesType{}
+
+type InstancesType struct {
+ basetypes.ObjectType
+}
+
+func (t InstancesType) Equal(o attr.Type) bool {
+ other, ok := o.(InstancesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t InstancesType) String() string {
+ return "InstancesType"
+}
+
+func (t InstancesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ isDeletableAttribute, ok := attributes["is_deletable"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `is_deletable is missing from object`)
+
+ return nil, diags
+ }
+
+ isDeletableVal, ok := isDeletableAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`is_deletable expected to be basetypes.BoolValue, was: %T`, isDeletableAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return nil, diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return nil, diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return InstancesValue{
+ Id: idVal,
+ IsDeletable: isDeletableVal,
+ Name: nameVal,
+ Status: statusVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewInstancesValueNull() InstancesValue {
+ return InstancesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewInstancesValueUnknown() InstancesValue {
+ return InstancesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewInstancesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (InstancesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing InstancesValue Attribute Value",
+ "While creating a InstancesValue value, a missing attribute value was detected. "+
+ "A InstancesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("InstancesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid InstancesValue Attribute Type",
+ "While creating a InstancesValue value, an invalid attribute value was detected. "+
+ "A InstancesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("InstancesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("InstancesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra InstancesValue Attribute Value",
+ "While creating a InstancesValue value, an extra attribute value was detected. "+
+ "A InstancesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra InstancesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewInstancesValueUnknown(), diags
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ isDeletableAttribute, ok := attributes["is_deletable"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `is_deletable is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ isDeletableVal, ok := isDeletableAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`is_deletable expected to be basetypes.BoolValue, was: %T`, isDeletableAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ if diags.HasError() {
+ return NewInstancesValueUnknown(), diags
+ }
+
+ return InstancesValue{
+ Id: idVal,
+ IsDeletable: isDeletableVal,
+ Name: nameVal,
+ Status: statusVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewInstancesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) InstancesValue {
+ object, diags := NewInstancesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewInstancesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t InstancesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewInstancesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewInstancesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewInstancesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewInstancesValueMust(InstancesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t InstancesType) ValueType(ctx context.Context) attr.Value {
+ return InstancesValue{}
+}
+
+var _ basetypes.ObjectValuable = InstancesValue{}
+
+type InstancesValue struct {
+ Id basetypes.StringValue `tfsdk:"id"`
+ IsDeletable basetypes.BoolValue `tfsdk:"is_deletable"`
+ Name basetypes.StringValue `tfsdk:"name"`
+ Status basetypes.StringValue `tfsdk:"status"`
+ state attr.ValueState
+}
+
+func (v InstancesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["is_deletable"] = basetypes.BoolType{}.TerraformType(ctx)
+ attrTypes["name"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["status"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.IsDeletable.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["is_deletable"] = val
+
+ val, err = v.Name.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["name"] = val
+
+ val, err = v.Status.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["status"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v InstancesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v InstancesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v InstancesValue) String() string {
+ return "InstancesValue"
+}
+
+func (v InstancesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "id": basetypes.StringType{},
+ "is_deletable": basetypes.BoolType{},
+ "name": basetypes.StringType{},
+ "status": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "id": v.Id,
+ "is_deletable": v.IsDeletable,
+ "name": v.Name,
+ "status": v.Status,
+ })
+
+ return objVal, diags
+}
+
+func (v InstancesValue) Equal(o attr.Value) bool {
+ other, ok := o.(InstancesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.IsDeletable.Equal(other.IsDeletable) {
+ return false
+ }
+
+ if !v.Name.Equal(other.Name) {
+ return false
+ }
+
+ if !v.Status.Equal(other.Status) {
+ return false
+ }
+
+ return true
+}
+
+func (v InstancesValue) Type(ctx context.Context) attr.Type {
+ return InstancesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v InstancesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "id": basetypes.StringType{},
+ "is_deletable": basetypes.BoolType{},
+ "name": basetypes.StringType{},
+ "status": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/instance/functions.go b/stackit/internal/services/sqlserverflexalpha/instance/functions.go
index 5675a2d9..a8567903 100644
--- a/stackit/internal/services/sqlserverflexalpha/instance/functions.go
+++ b/stackit/internal/services/sqlserverflexalpha/instance/functions.go
@@ -1,430 +1,283 @@
-package sqlserverflex
+package sqlserverflexalpha
import (
"context"
+ "errors"
"fmt"
- "strings"
+ "math"
"github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
- sqlserverflex "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ sqlserverflexalphaDataGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen"
+ sqlserverflexalphaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/resources_gen"
)
-type sqlserverflexClient interface {
- GetFlavorsRequestExecute(ctx context.Context, projectId, region string, page, size *int64, sort sqlserverflex.FlavorSort) (*sqlserverflex.GetFlavorsResponse, error)
-}
-
-func mapFields(ctx context.Context, resp *sqlserverflex.GetInstanceResponse, model *Model, flavor *flavorModel, storage *storageModel, encryption *encryptionModel, network *networkModel, region string) error {
- if resp == nil {
- return fmt.Errorf("response input is nil")
- }
- if model == nil {
- return fmt.Errorf("model input is nil")
- }
- instance := resp
-
- var instanceId string
- if model.InstanceId.ValueString() != "" {
- instanceId = model.InstanceId.ValueString()
- } else if instance.Id != nil {
- instanceId = *instance.Id
- } else {
- return fmt.Errorf("instance id not present")
- }
-
- var flavorValues map[string]attr.Value
- if instance.FlavorId == nil {
- return fmt.Errorf("instance has no flavor id")
- }
- if *instance.FlavorId != flavor.Id.ValueString() {
- return fmt.Errorf("instance has different flavor id %s - %s", *instance.FlavorId, flavor.Id.ValueString())
- }
-
- flavorValues = map[string]attr.Value{
- "id": flavor.Id,
- "description": flavor.Description,
- "cpu": flavor.CPU,
- "ram": flavor.RAM,
- "node_type": flavor.NodeType,
- }
- flavorObject, diags := types.ObjectValue(flavorTypes, flavorValues)
+func mapResponseToModel(
+ ctx context.Context,
+ resp *sqlserverflexalpha.GetInstanceResponse,
+ m *sqlserverflexalphaResGen.InstanceModel,
+ tfDiags diag.Diagnostics,
+) error {
+ m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
+ m.Edition = types.StringValue(string(resp.GetEdition()))
+ m.Encryption = handleEncryption(m, resp)
+ m.FlavorId = types.StringValue(resp.GetFlavorId())
+ m.Id = types.StringValue(resp.GetId())
+ m.InstanceId = types.StringValue(resp.GetId())
+ m.IsDeletable = types.BoolValue(resp.GetIsDeletable())
+ m.Name = types.StringValue(resp.GetName())
+ netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
+ tfDiags.Append(diags...)
if diags.HasError() {
- return fmt.Errorf("creating flavor: %w", core.DiagsToError(diags))
+ return fmt.Errorf(
+ "error converting network acl response value",
+ )
}
-
- var storageValues map[string]attr.Value
- if instance.Storage == nil {
- storageValues = map[string]attr.Value{
- "class": storage.Class,
- "size": storage.Size,
- }
- } else {
- storageValues = map[string]attr.Value{
- "class": types.StringValue(*instance.Storage.Class),
- "size": types.Int64PointerValue(instance.Storage.Size),
- }
- }
- storageObject, diags := types.ObjectValue(storageTypes, storageValues)
+ net, diags := sqlserverflexalphaResGen.NewNetworkValue(
+ sqlserverflexalphaResGen.NetworkValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "access_scope": types.StringValue(string(resp.Network.GetAccessScope())),
+ "acl": netAcl,
+ "instance_address": types.StringValue(resp.Network.GetInstanceAddress()),
+ "router_address": types.StringValue(resp.Network.GetRouterAddress()),
+ },
+ )
+ tfDiags.Append(diags...)
if diags.HasError() {
- return fmt.Errorf("creating storage: %w", core.DiagsToError(diags))
+ return errors.New("error converting network response value")
}
+ m.Network = net
+ m.Replicas = types.Int64Value(int64(resp.GetReplicas()))
+ m.RetentionDays = types.Int64Value(resp.GetRetentionDays())
+ m.Status = types.StringValue(string(resp.GetStatus()))
- var encryptionValues map[string]attr.Value
- if instance.Encryption == nil {
- encryptionValues = map[string]attr.Value{
- "keyring_id": encryption.KeyRingId,
- "key_id": encryption.KeyId,
- "key_version": encryption.KeyVersion,
- "service_account": encryption.ServiceAccount,
- }
- } else {
- encryptionValues = map[string]attr.Value{
- "keyring_id": types.StringValue(*instance.Encryption.KekKeyRingId),
- "key_id": types.StringValue(*instance.Encryption.KekKeyId),
- "key_version": types.StringValue(*instance.Encryption.KekKeyVersion),
- "service_account": types.StringValue(*instance.Encryption.ServiceAccount),
- }
- }
- encryptionObject, diags := types.ObjectValue(encryptionTypes, encryptionValues)
+ stor, diags := sqlserverflexalphaResGen.NewStorageValue(
+ sqlserverflexalphaResGen.StorageValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "class": types.StringValue(resp.Storage.GetClass()),
+ "size": types.Int64Value(resp.Storage.GetSize()),
+ },
+ )
+ tfDiags.Append(diags...)
if diags.HasError() {
- return fmt.Errorf("creating encryption: %w", core.DiagsToError(diags))
+ return fmt.Errorf("error converting storage response value")
}
+ m.Storage = stor
- var networkValues map[string]attr.Value
- if instance.Network == nil {
- networkValues = map[string]attr.Value{
- "acl": network.ACL,
- "access_scope": network.AccessScope,
- "instance_address": network.InstanceAddress,
- "router_address": network.RouterAddress,
- }
- } else {
- aclList, diags := types.ListValueFrom(ctx, types.StringType, *instance.Network.Acl)
- if diags.HasError() {
- return fmt.Errorf("creating network (acl list): %w", core.DiagsToError(diags))
- }
-
- var routerAddress string
- if instance.Network.RouterAddress != nil {
- routerAddress = *instance.Network.RouterAddress
- diags.AddWarning("field missing while mapping fields", "router_address was empty in API response")
- }
- if instance.Network.InstanceAddress == nil {
- return fmt.Errorf("creating network: no instance address returned")
- }
- networkValues = map[string]attr.Value{
- "acl": aclList,
- "access_scope": types.StringValue(string(*instance.Network.AccessScope)),
- "instance_address": types.StringValue(*instance.Network.InstanceAddress),
- "router_address": types.StringValue(routerAddress),
- }
- }
- networkObject, diags := types.ObjectValue(networkTypes, networkValues)
- if diags.HasError() {
- return fmt.Errorf("creating network: %w", core.DiagsToError(diags))
- }
-
- simplifiedModelBackupSchedule := utils.SimplifyBackupSchedule(model.BackupSchedule.ValueString())
- // If the value returned by the API is different from the one in the model after simplification,
- // we update the model so that it causes an error in Terraform
- if simplifiedModelBackupSchedule != types.StringPointerValue(instance.BackupSchedule).ValueString() {
- model.BackupSchedule = types.StringPointerValue(instance.BackupSchedule)
- }
-
- if instance.Replicas == nil {
- return fmt.Errorf("instance has no replicas set")
- }
-
- if instance.RetentionDays == nil {
- return fmt.Errorf("instance has no retention days set")
- }
-
- if instance.Version == nil {
- return fmt.Errorf("instance has no version set")
- }
-
- if instance.Edition == nil {
- return fmt.Errorf("instance has no edition set")
- }
-
- if instance.Status == nil {
- return fmt.Errorf("instance has no status set")
- }
-
- if instance.IsDeletable == nil {
- return fmt.Errorf("instance has no IsDeletable set")
- }
-
- model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), region, instanceId)
- model.InstanceId = types.StringValue(instanceId)
- model.Name = types.StringPointerValue(instance.Name)
- model.Flavor = flavorObject
- model.Replicas = types.Int64Value(int64(*instance.Replicas))
- model.Storage = storageObject
- model.Version = types.StringValue(string(*instance.Version))
- model.Edition = types.StringValue(string(*instance.Edition))
- model.Region = types.StringValue(region)
- model.Encryption = encryptionObject
- model.Network = networkObject
- model.RetentionDays = types.Int64Value(*instance.RetentionDays)
- model.Status = types.StringValue(string(*instance.Status))
- model.IsDeletable = types.BoolValue(*instance.IsDeletable)
+ m.Version = types.StringValue(string(resp.GetVersion()))
return nil
}
-func toCreatePayload(model *Model, storage *storageModel, encryption *encryptionModel, network *networkModel) (*sqlserverflex.CreateInstanceRequestPayload, error) {
+func mapDataResponseToModel(
+ ctx context.Context,
+ resp *sqlserverflexalpha.GetInstanceResponse,
+ m *dataSourceModel,
+ tfDiags diag.Diagnostics,
+) error {
+ m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
+ m.Edition = types.StringValue(string(resp.GetEdition()))
+ m.Encryption = handleDSEncryption(m, resp)
+ m.FlavorId = types.StringValue(resp.GetFlavorId())
+ m.Id = types.StringValue(resp.GetId())
+ m.InstanceId = types.StringValue(resp.GetId())
+ m.IsDeletable = types.BoolValue(resp.GetIsDeletable())
+ m.Name = types.StringValue(resp.GetName())
+ netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
+ tfDiags.Append(diags...)
+ if diags.HasError() {
+ return fmt.Errorf(
+ "error converting network acl response value",
+ )
+ }
+ net, diags := sqlserverflexalphaDataGen.NewNetworkValue(
+ sqlserverflexalphaDataGen.NetworkValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "access_scope": types.StringValue(string(resp.Network.GetAccessScope())),
+ "acl": netAcl,
+ "instance_address": types.StringValue(resp.Network.GetInstanceAddress()),
+ "router_address": types.StringValue(resp.Network.GetRouterAddress()),
+ },
+ )
+ tfDiags.Append(diags...)
+ if diags.HasError() {
+ return errors.New("error converting network response value")
+ }
+ m.Network = net
+ m.Replicas = types.Int64Value(int64(resp.GetReplicas()))
+ m.RetentionDays = types.Int64Value(resp.GetRetentionDays())
+ m.Status = types.StringValue(string(resp.GetStatus()))
+
+ stor, diags := sqlserverflexalphaDataGen.NewStorageValue(
+ sqlserverflexalphaDataGen.StorageValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "class": types.StringValue(resp.Storage.GetClass()),
+ "size": types.Int64Value(resp.Storage.GetSize()),
+ },
+ )
+ tfDiags.Append(diags...)
+ if diags.HasError() {
+ return fmt.Errorf("error converting storage response value")
+ }
+ m.Storage = stor
+
+ m.Version = types.StringValue(string(resp.GetVersion()))
+ return nil
+}
+
+func handleEncryption(
+ m *sqlserverflexalphaResGen.InstanceModel,
+ resp *sqlserverflexalpha.GetInstanceResponse,
+) sqlserverflexalphaResGen.EncryptionValue {
+ if !resp.HasEncryption() ||
+ resp.Encryption == nil ||
+ resp.Encryption.KekKeyId == nil ||
+ resp.Encryption.KekKeyRingId == nil ||
+ resp.Encryption.KekKeyVersion == nil ||
+ resp.Encryption.ServiceAccount == nil {
+ if m.Encryption.IsNull() || m.Encryption.IsUnknown() {
+ return sqlserverflexalphaResGen.NewEncryptionValueNull()
+ }
+ return m.Encryption
+ }
+
+ enc := sqlserverflexalphaResGen.NewEncryptionValueNull()
+ if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok {
+ enc.KekKeyId = types.StringValue(kVal)
+ }
+ if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok {
+ enc.KekKeyRingId = types.StringValue(kkVal)
+ }
+ if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok {
+ enc.KekKeyVersion = types.StringValue(kkvVal)
+ }
+ if sa, ok := resp.Encryption.GetServiceAccountOk(); ok {
+ enc.ServiceAccount = types.StringValue(sa)
+ }
+ return enc
+}
+
+func handleDSEncryption(
+ m *dataSourceModel,
+ resp *sqlserverflexalpha.GetInstanceResponse,
+) sqlserverflexalphaDataGen.EncryptionValue {
+ if !resp.HasEncryption() ||
+ resp.Encryption == nil ||
+ resp.Encryption.KekKeyId == nil ||
+ resp.Encryption.KekKeyRingId == nil ||
+ resp.Encryption.KekKeyVersion == nil ||
+ resp.Encryption.ServiceAccount == nil {
+ if m.Encryption.IsNull() || m.Encryption.IsUnknown() {
+ return sqlserverflexalphaDataGen.NewEncryptionValueNull()
+ }
+ return m.Encryption
+ }
+
+ enc := sqlserverflexalphaDataGen.NewEncryptionValueNull()
+ if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok {
+ enc.KekKeyId = types.StringValue(kVal)
+ }
+ if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok {
+ enc.KekKeyRingId = types.StringValue(kkVal)
+ }
+ if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok {
+ enc.KekKeyVersion = types.StringValue(kkvVal)
+ }
+ if sa, ok := resp.Encryption.GetServiceAccountOk(); ok {
+ enc.ServiceAccount = types.StringValue(sa)
+ }
+ return enc
+}
+
+func toCreatePayload(
+ ctx context.Context,
+ model *sqlserverflexalphaResGen.InstanceModel,
+) (*sqlserverflexalpha.CreateInstanceRequestPayload, error) {
if model == nil {
return nil, fmt.Errorf("nil model")
}
- if model.Flavor.IsNull() || model.Flavor.IsUnknown() {
- return nil, fmt.Errorf("nil flavor")
+ storagePayload := &sqlserverflexalpha.CreateInstanceRequestPayloadGetStorageArgType{}
+ if !model.Storage.IsNull() && !model.Storage.IsUnknown() {
+ storagePayload.Class = model.Storage.Class.ValueStringPointer()
+ storagePayload.Size = model.Storage.Size.ValueInt64Pointer()
}
- storagePayload := &sqlserverflex.CreateInstanceRequestPayloadGetStorageArgType{}
- if storage != nil {
- storagePayload.Class = conversion.StringValueToPointer(storage.Class)
- storagePayload.Size = conversion.Int64ValueToPointer(storage.Size)
- }
-
- encryptionPayload := &sqlserverflex.CreateInstanceRequestPayloadGetEncryptionArgType{}
- if encryption != nil {
- encryptionPayload.KekKeyId = conversion.StringValueToPointer(encryption.KeyId)
- encryptionPayload.KekKeyVersion = conversion.StringValueToPointer(encryption.KeyVersion)
- encryptionPayload.KekKeyRingId = conversion.StringValueToPointer(encryption.KeyRingId)
- encryptionPayload.ServiceAccount = conversion.StringValueToPointer(encryption.ServiceAccount)
- }
-
- networkPayload := &sqlserverflex.CreateInstanceRequestPayloadGetNetworkArgType{}
- if network != nil {
- networkPayload.AccessScope = sqlserverflex.CreateInstanceRequestPayloadNetworkGetAccessScopeAttributeType(conversion.StringValueToPointer(network.AccessScope))
- }
-
- flavorId := ""
- if !(model.Flavor.IsNull() || model.Flavor.IsUnknown()) {
- modelValues := model.Flavor.Attributes()
- if _, ok := modelValues["id"]; !ok {
- return nil, fmt.Errorf("flavor has not yet been created")
+ var encryptionPayload *sqlserverflexalpha.CreateInstanceRequestPayloadGetEncryptionArgType = nil
+ if !model.Encryption.IsNull() && !model.Encryption.IsUnknown() &&
+ !model.Encryption.KekKeyId.IsNull() && model.Encryption.KekKeyId.IsUnknown() && model.Encryption.KekKeyId.ValueString() != "" &&
+ !model.Encryption.KekKeyRingId.IsNull() && !model.Encryption.KekKeyRingId.IsUnknown() && model.Encryption.KekKeyRingId.ValueString() != "" &&
+ !model.Encryption.KekKeyVersion.IsNull() && !model.Encryption.KekKeyVersion.IsUnknown() && model.Encryption.KekKeyVersion.ValueString() != "" &&
+ !model.Encryption.ServiceAccount.IsNull() && !model.Encryption.ServiceAccount.IsUnknown() && model.Encryption.ServiceAccount.ValueString() != "" {
+ encryptionPayload = &sqlserverflexalpha.CreateInstanceRequestPayloadGetEncryptionArgType{
+ KekKeyId: model.Encryption.KekKeyId.ValueStringPointer(),
+ KekKeyRingId: model.Encryption.KekKeyVersion.ValueStringPointer(),
+ KekKeyVersion: model.Encryption.KekKeyRingId.ValueStringPointer(),
+ ServiceAccount: model.Encryption.ServiceAccount.ValueStringPointer(),
}
- flavorId = strings.Trim(modelValues["id"].String(), "\"")
}
- var aclElements []string
- if network != nil && !(network.ACL.IsNull() || network.ACL.IsUnknown()) {
- aclElements = make([]string, 0, len(network.ACL.Elements()))
- diags := network.ACL.ElementsAs(nil, &aclElements, false)
+ networkPayload := &sqlserverflexalpha.CreateInstanceRequestPayloadGetNetworkArgType{}
+ if !model.Network.IsNull() && !model.Network.IsUnknown() {
+ networkPayload.AccessScope = sqlserverflexalpha.CreateInstanceRequestPayloadNetworkGetAccessScopeAttributeType(
+ model.Network.AccessScope.ValueStringPointer(),
+ )
+
+ var resList []string
+ diags := model.Network.Acl.ElementsAs(ctx, &resList, false)
if diags.HasError() {
- return nil, fmt.Errorf("creating network: %w", core.DiagsToError(diags))
+ return nil, fmt.Errorf("error converting network acl list")
}
+ networkPayload.Acl = &resList
}
- return &sqlserverflex.CreateInstanceRequestPayload{
- Acl: &aclElements,
+ return &sqlserverflexalpha.CreateInstanceRequestPayload{
BackupSchedule: conversion.StringValueToPointer(model.BackupSchedule),
- FlavorId: &flavorId,
- Name: conversion.StringValueToPointer(model.Name),
- Storage: storagePayload,
- Version: sqlserverflex.CreateInstanceRequestPayloadGetVersionAttributeType(conversion.StringValueToPointer(model.Version)),
Encryption: encryptionPayload,
- RetentionDays: conversion.Int64ValueToPointer(model.RetentionDays),
- Network: networkPayload,
- }, nil
-}
-
-func toUpdatePayload(model *Model, storage *storageModel, network *networkModel) (*sqlserverflex.UpdateInstancePartiallyRequestPayload, error) {
- if model == nil {
- return nil, fmt.Errorf("nil model")
- }
- if model.Flavor.IsNull() || model.Flavor.IsUnknown() {
- return nil, fmt.Errorf("nil flavor")
- }
- var flavorMdl flavorModel
- diag := model.Flavor.As(context.Background(), &flavorMdl, basetypes.ObjectAsOptions{
- UnhandledNullAsEmpty: true,
- UnhandledUnknownAsEmpty: false,
- })
- if diag.HasError() {
- return nil, fmt.Errorf("flavor conversion error: %v", diag.Errors())
- }
-
- storagePayload := &sqlserverflex.UpdateInstanceRequestPayloadGetStorageArgType{}
- if storage != nil {
- storagePayload.Size = conversion.Int64ValueToPointer(storage.Size)
- }
-
- var aclElements []string
- if network != nil && !(network.ACL.IsNull() || network.ACL.IsUnknown()) {
- aclElements = make([]string, 0, len(network.ACL.Elements()))
- diags := network.ACL.ElementsAs(nil, &aclElements, false)
- if diags.HasError() {
- return nil, fmt.Errorf("creating network: %w", core.DiagsToError(diags))
- }
- }
-
- // TODO - implement network.ACL as soon as it becomes available
- replCount := int32(model.Replicas.ValueInt64())
- flavorId := flavorMdl.Id.ValueString()
- return &sqlserverflex.UpdateInstancePartiallyRequestPayload{
- Acl: &aclElements,
- BackupSchedule: conversion.StringValueToPointer(model.BackupSchedule),
- FlavorId: &flavorId,
+ FlavorId: conversion.StringValueToPointer(model.FlavorId),
Name: conversion.StringValueToPointer(model.Name),
- Replicas: sqlserverflex.UpdateInstancePartiallyRequestPayloadGetReplicasAttributeType(&replCount),
+ Network: networkPayload,
RetentionDays: conversion.Int64ValueToPointer(model.RetentionDays),
Storage: storagePayload,
- Version: sqlserverflex.UpdateInstancePartiallyRequestPayloadGetVersionAttributeType(conversion.StringValueToPointer(model.Version)),
+ Version: sqlserverflexalpha.CreateInstanceRequestPayloadGetVersionAttributeType(
+ conversion.StringValueToPointer(model.Version),
+ ),
}, nil
}
-func getAllFlavors(ctx context.Context, client sqlserverflexClient, projectId, region string) ([]sqlserverflex.ListFlavors, error) {
- if projectId == "" || region == "" {
- return nil, fmt.Errorf("listing sqlserverflex flavors: projectId and region are required")
+func toUpdatePayload(
+ ctx context.Context,
+ m *sqlserverflexalphaResGen.InstanceModel,
+ resp *resource.UpdateResponse,
+) (*sqlserverflexalpha.UpdateInstanceRequestPayload, error) {
+ if m == nil {
+ return nil, fmt.Errorf("nil model")
}
- var flavorList []sqlserverflex.ListFlavors
-
- page := int64(1)
- size := int64(10)
- for {
- res, err := client.GetFlavorsRequestExecute(ctx, projectId, region, &page, &size, sqlserverflex.FLAVORSORT_INDEX_ASC)
- if err != nil {
- return nil, fmt.Errorf("listing sqlserverflex flavors: %w", err)
- }
- if res.Flavors == nil {
- return nil, fmt.Errorf("finding flavors for project %s", projectId)
- }
- pagination := res.GetPagination()
- flavorList = append(flavorList, *res.Flavors...)
-
- if *pagination.TotalRows == int64(len(flavorList)) {
- break
- }
- page++
+ if m.Replicas.ValueInt64() > math.MaxUint32 {
+ return nil, fmt.Errorf("replicas value is too big for uint32")
}
- return flavorList, nil
-}
-
-func loadFlavorId(ctx context.Context, client sqlserverflexClient, model *Model, flavor *flavorModel, storage *storageModel) error {
- if model == nil {
- return fmt.Errorf("nil model")
- }
- if flavor == nil {
- return fmt.Errorf("nil flavor")
- }
- cpu := conversion.Int64ValueToPointer(flavor.CPU)
- if cpu == nil {
- return fmt.Errorf("nil CPU")
- }
- ram := conversion.Int64ValueToPointer(flavor.RAM)
- if ram == nil {
- return fmt.Errorf("nil RAM")
- }
- nodeType := conversion.StringValueToPointer(flavor.NodeType)
- if nodeType == nil {
- return fmt.Errorf("nil NodeType")
- }
- storageClass := conversion.StringValueToPointer(storage.Class)
- if storageClass == nil {
- return fmt.Errorf("nil StorageClass")
- }
- storageSize := conversion.Int64ValueToPointer(storage.Size)
- if storageSize == nil {
- return fmt.Errorf("nil StorageSize")
- }
-
- projectId := model.ProjectId.ValueString()
- region := model.Region.ValueString()
-
- flavorList, err := getAllFlavors(ctx, client, projectId, region)
- if err != nil {
- return err
- }
-
- avl := ""
- foundFlavorCount := 0
- for _, f := range flavorList {
- if f.Id == nil || f.Cpu == nil || f.Memory == nil {
- continue
- }
- if strings.ToLower(*f.NodeType) != strings.ToLower(*nodeType) {
- continue
- }
- if *f.Cpu == *cpu && *f.Memory == *ram {
- var useSc *sqlserverflex.FlavorStorageClassesStorageClass
- for _, sc := range *f.StorageClasses {
- if *sc.Class != *storageClass {
- continue
- }
- if *storageSize < *f.MinGB || *storageSize > *f.MaxGB {
- return fmt.Errorf("storage size %d out of bounds (min: %d - max: %d)", *storageSize, *f.MinGB, *f.MaxGB)
- }
- useSc = &sc
- }
- if useSc == nil {
- return fmt.Errorf("no storage class found for %s", *storageClass)
- }
-
- flavor.Id = types.StringValue(*f.Id)
- flavor.Description = types.StringValue(*f.Description)
- foundFlavorCount++
- }
- for _, cls := range *f.StorageClasses {
- avl = fmt.Sprintf("%s\n- %d CPU, %d GB RAM, storage %s (min: %d - max: %d)", avl, *f.Cpu, *f.Memory, *cls.Class, *f.MinGB, *f.MaxGB)
- }
- }
- if foundFlavorCount > 1 {
- return fmt.Errorf("multiple flavors found: %d flavors", foundFlavorCount)
- }
- if flavor.Id.ValueString() == "" {
- return fmt.Errorf("couldn't find flavor, available specs are:%s", avl)
- }
-
- return nil
-}
-
-func getFlavorModelById(ctx context.Context, client sqlserverflexClient, model *Model, flavor *flavorModel) error {
- if model == nil {
- return fmt.Errorf("nil model")
- }
- if flavor == nil {
- return fmt.Errorf("nil flavor")
- }
- id := conversion.StringValueToPointer(flavor.Id)
- if id == nil {
- return fmt.Errorf("nil flavor ID")
- }
-
- flavor.Id = types.StringValue("")
-
- projectId := model.ProjectId.ValueString()
- region := model.Region.ValueString()
-
- flavorList, err := getAllFlavors(ctx, client, projectId, region)
- if err != nil {
- return err
- }
-
- avl := ""
- for _, f := range flavorList {
- if f.Id == nil || f.Cpu == nil || f.Memory == nil {
- continue
- }
- if *f.Id == *id {
- flavor.Id = types.StringValue(*f.Id)
- flavor.Description = types.StringValue(*f.Description)
- flavor.CPU = types.Int64Value(*f.Cpu)
- flavor.RAM = types.Int64Value(*f.Memory)
- flavor.NodeType = types.StringValue(*f.NodeType)
- break
- }
- avl = fmt.Sprintf("%s\n- %d CPU, %d GB RAM", avl, *f.Cpu, *f.Memory)
- }
- if flavor.Id.ValueString() == "" {
- return fmt.Errorf("couldn't find flavor, available specs are: %s", avl)
- }
-
- return nil
+ replVal := sqlserverflexalpha.Replicas(uint32(m.Replicas.ValueInt64())) // nolint:gosec // check is performed above
+
+ var netAcl []string
+ diags := m.Network.Acl.ElementsAs(ctx, &netAcl, false)
+ resp.Diagnostics.Append(diags...)
+ if diags.HasError() {
+ return nil, fmt.Errorf("error converting model network acl value")
+ }
+ return &sqlserverflexalpha.UpdateInstanceRequestPayload{
+ BackupSchedule: m.BackupSchedule.ValueStringPointer(),
+ FlavorId: m.FlavorId.ValueStringPointer(),
+ Name: m.Name.ValueStringPointer(),
+ Network: sqlserverflexalpha.NewUpdateInstanceRequestPayloadNetwork(netAcl),
+ Replicas: &replVal,
+ RetentionDays: m.RetentionDays.ValueInt64Pointer(),
+ Storage: &sqlserverflexalpha.StorageUpdate{Size: m.Storage.Size.ValueInt64Pointer()},
+ Version: sqlserverflexalpha.UpdateInstanceRequestPayloadGetVersionAttributeType(
+ m.Version.ValueStringPointer(),
+ ),
+ }, nil
}
diff --git a/stackit/internal/services/sqlserverflexalpha/instance/planModifiers.yaml b/stackit/internal/services/sqlserverflexalpha/instance/planModifiers.yaml
new file mode 100644
index 00000000..71d4cbe4
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/instance/planModifiers.yaml
@@ -0,0 +1,124 @@
+fields:
+ - name: 'id'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'instance_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'project_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'name'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'backup_schedule'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'encryption.kek_key_id'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'encryption.kek_key_version'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'encryption.kek_key_ring_id'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'encryption.service_account'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'network.access_scope'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'network.acl'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'network.instance_address'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'network.router_address'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'status'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'region'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'retention_days'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'edition'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'version'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'replicas'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'storage'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'storage.class'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'storage.size'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'flavor_id'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'is_deletable'
+ modifiers:
+ - 'UseStateForUnknown'
diff --git a/stackit/internal/services/sqlserverflexalpha/instance/resource.go b/stackit/internal/services/sqlserverflexalpha/instance/resource.go
index a57c3480..3b1f4fd3 100644
--- a/stackit/internal/services/sqlserverflexalpha/instance/resource.go
+++ b/stackit/internal/services/sqlserverflexalpha/instance/resource.go
@@ -1,177 +1,166 @@
-package sqlserverflex
+package sqlserverflexalpha
import (
"context"
+ _ "embed"
"fmt"
"net/http"
- "regexp"
"strings"
"time"
- "github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
- "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
- "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
- sqlserverflexUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/sqlserverflexalpha/utils"
-
- "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/schema/validator"
- "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
- "github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
-
"github.com/hashicorp/terraform-plugin-framework/resource"
- "github.com/hashicorp/terraform-plugin-framework/resource/schema"
- "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
- "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/resource/identityschema"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
- sqlserverflex "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
- "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha/wait"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ wait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexalpha"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexalphaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/resources_gen"
)
-// Ensure the implementation satisfies the expected interfaces.
var (
_ resource.Resource = &instanceResource{}
_ resource.ResourceWithConfigure = &instanceResource{}
_ resource.ResourceWithImportState = &instanceResource{}
_ resource.ResourceWithModifyPlan = &instanceResource{}
+ _ resource.ResourceWithIdentity = &instanceResource{}
)
-var validNodeTypes []string = []string{
- "Single",
- "Replica",
-}
-
-type Model struct {
- Id types.String `tfsdk:"id"` // needed by TF
- InstanceId types.String `tfsdk:"instance_id"`
- ProjectId types.String `tfsdk:"project_id"`
- Name types.String `tfsdk:"name"`
- BackupSchedule types.String `tfsdk:"backup_schedule"`
- Flavor types.Object `tfsdk:"flavor"`
- Encryption types.Object `tfsdk:"encryption"`
- IsDeletable types.Bool `tfsdk:"is_deletable"`
- Storage types.Object `tfsdk:"storage"`
- Status types.String `tfsdk:"status"`
- Version types.String `tfsdk:"version"`
- Replicas types.Int64 `tfsdk:"replicas"`
- Region types.String `tfsdk:"region"`
- Network types.Object `tfsdk:"network"`
- Edition types.String `tfsdk:"edition"`
- RetentionDays types.Int64 `tfsdk:"retention_days"`
-}
-
-type encryptionModel struct {
- KeyRingId types.String `tfsdk:"keyring_id"`
- KeyId types.String `tfsdk:"key_id"`
- KeyVersion types.String `tfsdk:"key_version"`
- ServiceAccount types.String `tfsdk:"service_account"`
-}
-
-var encryptionTypes = map[string]attr.Type{
- "keyring_id": basetypes.StringType{},
- "key_id": basetypes.StringType{},
- "key_version": basetypes.StringType{},
- "service_account": basetypes.StringType{},
-}
-
-type networkModel struct {
- ACL types.List `tfsdk:"acl"`
- AccessScope types.String `tfsdk:"access_scope"`
- InstanceAddress types.String `tfsdk:"instance_address"`
- RouterAddress types.String `tfsdk:"router_address"`
-}
-
-var networkTypes = map[string]attr.Type{
- "acl": basetypes.ListType{ElemType: types.StringType},
- "access_scope": basetypes.StringType{},
- "instance_address": basetypes.StringType{},
- "router_address": basetypes.StringType{},
-}
-
-// Struct corresponding to Model.FlavorId
-type flavorModel struct {
- Id types.String `tfsdk:"id"`
- Description types.String `tfsdk:"description"`
- CPU types.Int64 `tfsdk:"cpu"`
- RAM types.Int64 `tfsdk:"ram"`
- NodeType types.String `tfsdk:"node_type"`
-}
-
-// Types corresponding to flavorModel
-var flavorTypes = map[string]attr.Type{
- "id": basetypes.StringType{},
- "description": basetypes.StringType{},
- "cpu": basetypes.Int64Type{},
- "ram": basetypes.Int64Type{},
- "node_type": basetypes.StringType{},
-}
-
-// Struct corresponding to Model.Storage
-type storageModel struct {
- Class types.String `tfsdk:"class"`
- Size types.Int64 `tfsdk:"size"`
-}
-
-// Types corresponding to storageModel
-var storageTypes = map[string]attr.Type{
- "class": basetypes.StringType{},
- "size": basetypes.Int64Type{},
-}
-
-// NewInstanceResource is a helper function to simplify the provider implementation.
func NewInstanceResource() resource.Resource {
return &instanceResource{}
}
-// instanceResource is the resource implementation.
type instanceResource struct {
- client *sqlserverflex.APIClient
+ client *sqlserverflexalpha.APIClient
providerData core.ProviderData
}
-// Metadata returns the resource type name.
-func (r *instanceResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
+// resourceModel describes the resource data model.
+type resourceModel = sqlserverflexalphaResGen.InstanceModel
+
+type InstanceResourceIdentityModel struct {
+ ProjectID types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ InstanceID types.String `tfsdk:"instance_id"`
+}
+
+func (r *instanceResource) Metadata(
+ _ context.Context,
+ req resource.MetadataRequest,
+ resp *resource.MetadataResponse,
+) {
resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_instance"
}
+//go:embed planModifiers.yaml
+var modifiersFileByte []byte
+
+func (r *instanceResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
+ s := sqlserverflexalphaResGen.InstanceResourceSchema(ctx)
+
+ fields, err := utils.ReadModifiersConfig(modifiersFileByte)
+ if err != nil {
+ resp.Diagnostics.AddError("error during read modifiers config file", err.Error())
+ return
+ }
+
+ err = utils.AddPlanModifiersToResourceSchema(fields, &s)
+ if err != nil {
+ resp.Diagnostics.AddError("error adding plan modifiers", err.Error())
+ return
+ }
+ resp.Schema = s
+}
+
+func (r *instanceResource) IdentitySchema(
+ _ context.Context,
+ _ resource.IdentitySchemaRequest,
+ resp *resource.IdentitySchemaResponse,
+) {
+ resp.IdentitySchema = identityschema.Schema{
+ Attributes: map[string]identityschema.Attribute{
+ "project_id": identityschema.StringAttribute{
+ RequiredForImport: true, // must be set during import by the practitioner
+ },
+ "region": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ "instance_id": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ },
+ }
+}
+
// Configure adds the provider configured client to the resource.
-func (r *instanceResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
+func (r *instanceResource) Configure(
+ ctx context.Context,
+ req resource.ConfigureRequest,
+ resp *resource.ConfigureResponse,
+) {
var ok bool
r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
if !ok {
return
}
- apiClient := sqlserverflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics)
- if resp.Diagnostics.HasError() {
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(r.providerData.RoundTripper),
+ utils.UserAgentConfigOption(r.providerData.Version),
+ }
+ if r.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(r.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(apiClientConfigOptions, config.WithRegion(r.providerData.GetRegion()))
+ }
+ apiClient, err := sqlserverflexalpha.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
return
}
r.client = apiClient
- tflog.Info(ctx, "SQLServer Flex instance client configured")
+ tflog.Info(ctx, "sqlserverflexalpha.Instance client configured")
}
// ModifyPlan implements resource.ResourceWithModifyPlan.
// Use the modifier to set the effective region in the current plan.
-func (r *instanceResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { // nolint:gocritic // function signature required by Terraform
- var configModel Model
+func (r *instanceResource) ModifyPlan(
+ ctx context.Context,
+ req resource.ModifyPlanRequest,
+ resp *resource.ModifyPlanResponse,
+) { // nolint:gocritic // function signature required by Terraform
// skip initial empty configuration to avoid follow-up errors
if req.Config.Raw.IsNull() {
return
}
+ var configModel resourceModel
resp.Diagnostics.Append(req.Config.Get(ctx, &configModel)...)
if resp.Diagnostics.HasError() {
return
}
- var planModel Model
+ if req.Plan.Raw.IsNull() {
+ return
+ }
+ var planModel resourceModel
resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...)
if resp.Diagnostics.HasError() {
return
@@ -188,536 +177,137 @@ func (r *instanceResource) ModifyPlan(ctx context.Context, req resource.ModifyPl
}
}
-// Schema defines the schema for the resource.
-func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
- descriptions := map[string]string{
- "main": "SQLServer Flex ALPHA instance resource schema. Must have a `region` specified in the provider configuration.",
- "id": "Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`\".",
- "instance_id": "ID of the SQLServer Flex instance.",
- "project_id": "STACKIT project ID to which the instance is associated.",
- "name": "Instance name.",
- "access_scope": "The access scope of the instance. (e.g. SNA)",
- "acl": "The Access Control List (ACL) for the SQLServer Flex instance.",
- "backup_schedule": `The backup schedule. Should follow the cron scheduling system format (e.g. "0 0 * * *")`,
- "region": "The resource region. If not defined, the provider region is used.",
- "encryption": "The encryption block.",
- "network": "The network block.",
- "keyring_id": "STACKIT KMS - KeyRing ID of the encryption key to use.",
- "key_id": "STACKIT KMS - Key ID of the encryption key to use.",
- "key_version": "STACKIT KMS - Key version to use in the encryption key.",
- "service:account": "STACKIT KMS - service account to use in the encryption key.",
- "instance_address": "The returned instance IP address of the SQLServer Flex instance.",
- "router_address": "The returned router IP address of the SQLServer Flex instance.",
- }
+func (r *instanceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
+ var data resourceModel
+ crateErr := "[SQL Server Flex BETA - Create] error"
- resp.Schema = schema.Schema{
- Description: descriptions["main"],
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Description: descriptions["id"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- "instance_id": schema.StringAttribute{
- Description: descriptions["instance_id"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "project_id": schema.StringAttribute{
- Description: descriptions["project_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "name": schema.StringAttribute{
- Description: descriptions["name"],
- Required: true,
- Validators: []validator.String{
- stringvalidator.LengthAtLeast(1),
- stringvalidator.RegexMatches(
- regexp.MustCompile("^[a-z]([-a-z0-9]*[a-z0-9])?$"),
- "must start with a letter, must have lower case letters, numbers or hyphens, and no hyphen at the end",
- ),
- },
- },
- "backup_schedule": schema.StringAttribute{
- Description: descriptions["backup_schedule"],
- Optional: true,
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- "is_deletable": schema.BoolAttribute{
- Description: descriptions["is_deletable"],
- Optional: true,
- Computed: true,
- PlanModifiers: []planmodifier.Bool{
- boolplanmodifier.UseStateForUnknown(),
- },
- },
- // TODO - make it either flavor_id or ram, cpu and node_type
- "flavor": schema.SingleNestedAttribute{
- PlanModifiers: []planmodifier.Object{
- objectplanmodifier.RequiresReplace(),
- objectplanmodifier.UseStateForUnknown(),
- },
- Required: true,
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Optional: true,
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- "description": schema.StringAttribute{
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- "node_type": schema.StringAttribute{
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- stringvalidator.ConflictsWith([]path.Expression{
- path.MatchRelative().AtParent().AtName("id"),
- }...),
- stringvalidator.OneOfCaseInsensitive(validNodeTypes...),
- stringvalidator.AlsoRequires([]path.Expression{
- path.MatchRelative().AtParent().AtName("cpu"),
- path.MatchRelative().AtParent().AtName("ram"),
- }...),
- },
- },
- "cpu": schema.Int64Attribute{
- Required: true,
- PlanModifiers: []planmodifier.Int64{
- int64planmodifier.RequiresReplace(),
- int64planmodifier.UseStateForUnknown(),
- },
- Validators: []validator.Int64{
- int64validator.ConflictsWith([]path.Expression{
- path.MatchRelative().AtParent().AtName("id"),
- }...),
- int64validator.AlsoRequires([]path.Expression{
- path.MatchRelative().AtParent().AtName("node_type"),
- path.MatchRelative().AtParent().AtName("ram"),
- }...),
- },
- },
- "ram": schema.Int64Attribute{
- Required: true,
- PlanModifiers: []planmodifier.Int64{
- int64planmodifier.RequiresReplace(),
- int64planmodifier.UseStateForUnknown(),
- },
- Validators: []validator.Int64{
- int64validator.ConflictsWith([]path.Expression{
- path.MatchRelative().AtParent().AtName("id"),
- }...),
- int64validator.AlsoRequires([]path.Expression{
- path.MatchRelative().AtParent().AtName("node_type"),
- path.MatchRelative().AtParent().AtName("cpu"),
- }...),
- },
- },
- },
- },
- "replicas": schema.Int64Attribute{
- Computed: true,
- PlanModifiers: []planmodifier.Int64{
- int64planmodifier.UseStateForUnknown(),
- },
- },
- "storage": schema.SingleNestedAttribute{
- Optional: true,
- Computed: true,
- PlanModifiers: []planmodifier.Object{
- objectplanmodifier.UseStateForUnknown(),
- },
- Attributes: map[string]schema.Attribute{
- "class": schema.StringAttribute{
- Optional: true,
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- "size": schema.Int64Attribute{
- Optional: true,
- Computed: true,
- PlanModifiers: []planmodifier.Int64{
- int64planmodifier.UseStateForUnknown(),
- },
- },
- },
- },
- "version": schema.StringAttribute{
- Optional: true,
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- "edition": schema.StringAttribute{
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- "retention_days": schema.Int64Attribute{
- Optional: true,
- Computed: true,
- PlanModifiers: []planmodifier.Int64{
- int64planmodifier.UseStateForUnknown(),
- },
- },
- "region": schema.StringAttribute{
- Optional: true,
- // must be computed to allow for storing the override value from the provider
- Computed: true,
- Description: descriptions["region"],
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- },
- "status": schema.StringAttribute{
- Optional: true,
- // must be computed to allow for storing the override value from the provider
- Computed: true,
- Description: descriptions["status"],
- },
- "encryption": schema.SingleNestedAttribute{
- Required: true,
- PlanModifiers: []planmodifier.Object{
- objectplanmodifier.RequiresReplace(),
- objectplanmodifier.UseStateForUnknown(),
- },
- Attributes: map[string]schema.Attribute{
- "key_id": schema.StringAttribute{
- Description: descriptions["key_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- "key_version": schema.StringAttribute{
- Description: descriptions["key_version"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- "keyring_id": schema.StringAttribute{
- Description: descriptions["key_ring_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- "service_account": schema.StringAttribute{
- Description: descriptions["service_account"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- },
- Description: descriptions["encryption"],
- },
- "network": schema.SingleNestedAttribute{
- Required: true,
- Attributes: map[string]schema.Attribute{
- "access_scope": schema.StringAttribute{
- Description: descriptions["access_scope"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
- },
- "acl": schema.ListAttribute{
- Description: descriptions["acl"],
- ElementType: types.StringType,
- Required: true,
- PlanModifiers: []planmodifier.List{
- listplanmodifier.UseStateForUnknown(),
- },
- },
- "instance_address": schema.StringAttribute{
- Description: descriptions["instance_address"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- "router_address": schema.StringAttribute{
- Description: descriptions["router_address"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- },
- Description: descriptions["network"],
- },
- },
- }
-}
+ // Read Terraform plan data into the model
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
-// Create creates the resource and sets the initial Terraform state.
-func (r *instanceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
- // Retrieve values from plan
- var model Model
- diags := req.Plan.Get(ctx, &model)
- resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
- projectId := model.ProjectId.ValueString()
- region := model.Region.ValueString()
+ projectId := data.ProjectId.ValueString()
+ region := data.Region.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "region", region)
- var storage = &storageModel{}
- if !(model.Storage.IsNull() || model.Storage.IsUnknown()) {
- diags = model.Storage.As(ctx, storage, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var encryption = &encryptionModel{}
- if !(model.Encryption.IsNull() || model.Encryption.IsUnknown()) {
- diags = model.Encryption.As(ctx, encryption, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var network = &networkModel{}
- if !(model.Network.IsNull() || model.Network.IsUnknown()) {
- diags = model.Network.As(ctx, network, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- flavor := &flavorModel{}
- if !(model.Flavor.IsNull() || model.Flavor.IsUnknown()) {
- diags = model.Flavor.As(ctx, flavor, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- if flavor.Id.IsNull() || flavor.Id.IsUnknown() {
- err := loadFlavorId(ctx, r.client, &model, flavor, storage)
- if err != nil {
- resp.Diagnostics.AddError(err.Error(), err.Error())
- return
- }
- flavorValues := map[string]attr.Value{
- "id": flavor.Id,
- "description": flavor.Description,
- "cpu": flavor.CPU,
- "ram": flavor.RAM,
- "node_type": flavor.NodeType,
- }
- var flavorObject basetypes.ObjectValue
- flavorObject, diags = types.ObjectValue(flavorTypes, flavorValues)
- resp.Diagnostics.Append(diags...)
- if diags.HasError() {
- return
- }
- model.Flavor = flavorObject
- }
-
// Generate API request body from model
- payload, err := toCreatePayload(&model, storage, encryption, network)
+ payload, err := toCreatePayload(ctx, &data)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Creating API payload: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ crateErr,
+ fmt.Sprintf("Creating API payload: %v", err),
+ )
return
}
- // Create new instance
- createResp, err := r.client.CreateInstanceRequest(ctx, projectId, region).CreateInstanceRequestPayload(*payload).Execute()
+ // Create new Instance
+ createResp, err := r.client.CreateInstanceRequest(
+ ctx,
+ projectId,
+ region,
+ ).CreateInstanceRequestPayload(*payload).Execute()
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Calling API: %v", err))
+ core.LogAndAddError(ctx, &resp.Diagnostics, crateErr, fmt.Sprintf("Calling API: %v", err))
return
}
ctx = core.LogResponse(ctx)
- instanceId := *createResp.Id
- utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{
- "instance_id": instanceId,
- })
+ InstanceId := *createResp.Id
+
+ // Example data value setting
+ data.InstanceId = types.StringValue("id-from-response")
+
+ identity := InstanceResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(InstanceId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
if resp.Diagnostics.HasError() {
return
}
- // The creation waiter sometimes returns an error from the API: "instance with id xxx has unexpected status Failure"
- // which can be avoided by sleeping before wait
- waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).SetSleepBeforeWait(30 * time.Second).WaitWithContext(ctx)
+ waitResp, err := wait.CreateInstanceWaitHandler(
+ ctx,
+ r.client,
+ projectId,
+ InstanceId,
+ region,
+ ).SetSleepBeforeWait(
+ 10 * time.Second,
+ ).SetTimeout(
+ 90 * time.Minute,
+ ).WaitWithContext(ctx)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Instance creation waiting: %v", err))
- return
- }
-
- if waitResp.FlavorId == nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "Instance creation waiting: returned flavor id is nil")
- return
- }
-
- if *waitResp.FlavorId != flavor.Id.ValueString() {
core.LogAndAddError(
ctx,
&resp.Diagnostics,
- "Error creating instance",
- fmt.Sprintf("Instance creation waiting: returned flavor id differs (expected: %s, current: %s)", flavor.Id.ValueString(), *waitResp.FlavorId),
+ crateErr,
+ fmt.Sprintf("Instance creation waiting: %v", err),
)
return
}
- if flavor.CPU.IsNull() || flavor.CPU.IsUnknown() {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "Instance creation waiting: flavor cpu is null or unknown")
- }
- if flavor.RAM.IsNull() || flavor.RAM.IsUnknown() {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "Instance creation waiting: flavor ram is null or unknown")
- }
- // flavorData := getFlavorModelById(ctx, r.client, &model, flavor)
-
- // Map response body to schema
- err = mapFields(ctx, waitResp, &model, flavor, storage, encryption, network, region)
- if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Processing API payload: %v", err))
+ if waitResp.Id == nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ crateErr,
+ "Instance creation waiting: returned id is nil",
+ )
return
}
- // Set state to fully populated data
- diags = resp.State.Set(ctx, model)
- resp.Diagnostics.Append(diags...)
+
+ // Map response body to schema
+ err = mapResponseToModel(ctx, waitResp, &data, resp.Diagnostics)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ crateErr,
+ fmt.Sprintf("processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Save data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+
+ tflog.Info(ctx, "sqlserverflexalpha.Instance created")
+}
+
+func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
+ var data resourceModel
+
+ // Read Terraform prior state data into the model
+ resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}
- // After the instance creation, database might not be ready to accept connections immediately.
- // That is why we add a sleep
- // TODO - can get removed?
- time.Sleep(120 * time.Second)
-
- tflog.Info(ctx, "SQLServer Flex instance created")
-}
-
-// Read refreshes the Terraform state with the latest data.
-func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
- var model Model
- diags := req.State.Get(ctx, &model)
- resp.Diagnostics.Append(diags...)
+ // Read identity data
+ var identityData InstanceResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- region := r.providerData.GetRegionWithOverride(model.Region)
-
+ projectId := data.ProjectId.ValueString()
+ region := data.Region.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
ctx = tflog.SetField(ctx, "region", region)
- var flavor = &flavorModel{}
- if !(model.Flavor.IsNull() || model.Flavor.IsUnknown()) {
- diags = model.Flavor.As(ctx, flavor, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
-
- err := getFlavorModelById(ctx, r.client, &model, flavor)
- if err != nil {
- resp.Diagnostics.AddError(err.Error(), err.Error())
- return
- }
-
- diags = model.Flavor.As(ctx, flavor, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var storage = &storageModel{}
- if !(model.Storage.IsNull() || model.Storage.IsUnknown()) {
- diags = model.Storage.As(ctx, storage, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var encryption = &encryptionModel{}
- if !(model.Encryption.IsNull() || model.Encryption.IsUnknown()) {
- diags = model.Encryption.As(ctx, encryption, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var network = &networkModel{}
- if !(model.Network.IsNull() || model.Network.IsUnknown()) {
- diags = model.Network.As(ctx, network, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
+ instanceId := data.InstanceId.ValueString()
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
instanceResp, err := r.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
if err != nil {
@@ -733,152 +323,153 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
ctx = core.LogResponse(ctx)
// Map response body to schema
- err = mapFields(ctx, instanceResp, &model, flavor, storage, encryption, network, region)
+ err = mapResponseToModel(ctx, instanceResp, &data, resp.Diagnostics)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API payload: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading instance",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
return
}
- // Set refreshed state
- diags = resp.State.Set(ctx, model)
- resp.Diagnostics.Append(diags...)
+
+ // Save identity into Terraform state
+ identity := InstanceResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
if resp.Diagnostics.HasError() {
return
}
- tflog.Info(ctx, "SQLServer Flex instance read")
+
+ // Save updated data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ tflog.Info(ctx, "sqlserverflexalpha.Instance read")
}
-// Update updates the resource and sets the updated Terraform state on success.
-func (r *instanceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
- // Retrieve values from plan
- var model Model
- diags := req.Plan.Get(ctx, &model)
- resp.Diagnostics.Append(diags...)
+func (r *instanceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
+ var data resourceModel
+ updateInstanceError := "Error updating instance"
+
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- region := model.Region.ValueString()
-
+ projectId := data.ProjectId.ValueString()
+ region := data.Region.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
ctx = tflog.SetField(ctx, "region", region)
- var storage = &storageModel{}
- if !(model.Storage.IsNull() || model.Storage.IsUnknown()) {
- diags = model.Storage.As(ctx, storage, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var encryption = &encryptionModel{}
- if !(model.Encryption.IsNull() || model.Encryption.IsUnknown()) {
- diags = model.Encryption.As(ctx, encryption, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- var network = &networkModel{}
- if !(model.Network.IsNull() || model.Network.IsUnknown()) {
- diags = model.Network.As(ctx, network, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- flavor := &flavorModel{}
- if !(model.Flavor.IsNull() || model.Flavor.IsUnknown()) {
- diags = model.Flavor.As(ctx, flavor, basetypes.ObjectAsOptions{})
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
- if flavor.Id.IsNull() || flavor.Id.IsUnknown() {
- err := loadFlavorId(ctx, r.client, &model, flavor, storage)
- if err != nil {
- resp.Diagnostics.AddError(err.Error(), err.Error())
- return
- }
- flavorValues := map[string]attr.Value{
- "id": flavor.Id,
- "description": flavor.Description,
- "cpu": flavor.CPU,
- "ram": flavor.RAM,
- "node_type": flavor.NodeType,
- }
- var flavorObject basetypes.ObjectValue
- flavorObject, diags = types.ObjectValue(flavorTypes, flavorValues)
- resp.Diagnostics.Append(diags...)
- if diags.HasError() {
- return
- }
- model.Flavor = flavorObject
- }
+ instanceId := data.InstanceId.ValueString()
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
// Generate API request body from model
- payload, err := toUpdatePayload(&model, storage, network)
+ payload, err := toUpdatePayload(ctx, &data, resp)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Creating API payload: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ updateInstanceError,
+ fmt.Sprintf("Creating API payload: %v", err),
+ )
return
}
// Update existing instance
- err = r.client.UpdateInstancePartiallyRequest(ctx, projectId, region, instanceId).UpdateInstancePartiallyRequestPayload(*payload).Execute()
+ err = r.client.UpdateInstanceRequest(
+ ctx,
+ projectId,
+ region,
+ instanceId,
+ ).UpdateInstanceRequestPayload(*payload).Execute()
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", err.Error())
+ core.LogAndAddError(ctx, &resp.Diagnostics, updateInstanceError, err.Error())
return
}
ctx = core.LogResponse(ctx)
- waitResp, err := wait.UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).WaitWithContext(ctx)
+ waitResp, err := wait.
+ UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).
+ SetSleepBeforeWait(15 * time.Second).
+ SetTimeout(45 * time.Minute).
+ WaitWithContext(ctx)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ updateInstanceError,
+ fmt.Sprintf("Instance update waiting: %v", err),
+ )
return
}
// Map response body to schema
- err = mapFields(ctx, waitResp, &model, flavor, storage, encryption, network, region)
+ err = mapResponseToModel(ctx, waitResp, &data, resp.Diagnostics)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Processing API payload: %v", err))
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ updateInstanceError,
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
return
}
- diags = resp.State.Set(ctx, model)
- resp.Diagnostics.Append(diags...)
+
+ identity := InstanceResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
if resp.Diagnostics.HasError() {
return
}
- tflog.Info(ctx, "SQLServer Flex instance updated")
+
+ // Save updated data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ tflog.Info(ctx, "sqlserverflexalpha.Instance updated")
}
-// Delete deletes the resource and removes the Terraform state on success.
-func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
- // Retrieve values from state
- var model Model
- diags := req.State.Get(ctx, &model)
- resp.Diagnostics.Append(diags...)
+func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
+ var data resourceModel
+
+ // Read Terraform prior state data into the model
+ resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Read identity data
+ var identityData InstanceResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
- projectId := model.ProjectId.ValueString()
- instanceId := model.InstanceId.ValueString()
- region := model.Region.ValueString()
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
- ctx = tflog.SetField(ctx, "instance_id", instanceId)
ctx = tflog.SetField(ctx, "region", region)
+ instanceId := identityData.InstanceID.ValueString()
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+
// Delete existing instance
err := r.client.DeleteInstanceRequest(ctx, projectId, region, instanceId).Execute()
if err != nil {
@@ -888,29 +479,76 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
ctx = core.LogResponse(ctx)
- _, err = wait.DeleteInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).WaitWithContext(ctx)
+ delResp, err := wait.DeleteInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).WaitWithContext(ctx)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Instance deletion waiting: %v", err))
- return
- }
- tflog.Info(ctx, "SQLServer Flex instance deleted")
-}
-
-// ImportState imports a resource into the Terraform state on success.
-// The expected format of the resource import identifier is: project_id,instance_id
-func (r *instanceResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
- idParts := strings.Split(req.ID, core.Separator)
-
- if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
- core.LogAndAddError(ctx, &resp.Diagnostics,
- "Error importing instance",
- fmt.Sprintf("Expected import identifier with format: [project_id],[region],[instance_id] Got: %q", req.ID),
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error deleting instance",
+ fmt.Sprintf("Instance deletion waiting: %v", err),
)
return
}
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
- tflog.Info(ctx, "SQLServer Flex instance state imported")
+ if delResp != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error deleting instance",
+ "wait handler returned non nil result",
+ )
+ return
+ }
+
+ resp.State.RemoveResource(ctx)
+
+ tflog.Info(ctx, "sqlserverflexalpha.Instance deleted")
+}
+
+// ImportState imports a resource into the Terraform state on success.
+// The expected format of the resource import identifier is: project_id,zone_id,record_set_id
+func (r *instanceResource) ImportState(
+ ctx context.Context,
+ req resource.ImportStateRequest,
+ resp *resource.ImportStateResponse,
+) {
+ ctx = core.InitProviderContext(ctx)
+
+ if req.ID != "" {
+ idParts := strings.Split(req.ID, core.Separator)
+
+ if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
+ core.LogAndAddError(
+ ctx, &resp.Diagnostics,
+ "Error importing instance",
+ fmt.Sprintf(
+ "Expected import identifier with format [project_id],[region],[instance_id] Got: %q",
+ req.ID,
+ ),
+ )
+ return
+ }
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
+ return
+ }
+
+ // If no ID is provided, attempt to read identity attributes from the import configuration
+ var identityData InstanceResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ instanceId := identityData.InstanceID.ValueString()
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), projectId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), region)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), instanceId)...)
+
+ tflog.Info(ctx, "sqlserverflexalpha instance state imported")
}
diff --git a/stackit/internal/services/sqlserverflexalpha/instance/resource_msh_test.go.bak b/stackit/internal/services/sqlserverflexalpha/instance/resource_msh_test.go.bak
deleted file mode 100644
index 2ad6eb7d..00000000
--- a/stackit/internal/services/sqlserverflexalpha/instance/resource_msh_test.go.bak
+++ /dev/null
@@ -1,282 +0,0 @@
-// Copyright (c) STACKIT
-
-package sqlserverflex
-
-import (
- "context"
- "reflect"
- "testing"
-
- "github.com/hashicorp/terraform-plugin-framework/resource"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
-
- sqlserverflex "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
-)
-
-func TestNewInstanceResource(t *testing.T) {
- tests := []struct {
- name string
- want resource.Resource
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := NewInstanceResource(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("NewInstanceResource() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func Test_instanceResource_Configure(t *testing.T) {
- type fields struct {
- client *sqlserverflex.APIClient
- providerData core.ProviderData
- }
- type args struct {
- ctx context.Context
- req resource.ConfigureRequest
- resp *resource.ConfigureResponse
- }
- tests := []struct {
- name string
- fields fields
- args args
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- r := &instanceResource{
- client: tt.fields.client,
- providerData: tt.fields.providerData,
- }
- r.Configure(tt.args.ctx, tt.args.req, tt.args.resp)
- })
- }
-}
-
-func Test_instanceResource_Create(t *testing.T) {
- type fields struct {
- client *sqlserverflex.APIClient
- providerData core.ProviderData
- }
- type args struct {
- ctx context.Context
- req resource.CreateRequest
- resp *resource.CreateResponse
- }
- tests := []struct {
- name string
- fields fields
- args args
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- r := &instanceResource{
- client: tt.fields.client,
- providerData: tt.fields.providerData,
- }
- r.Create(tt.args.ctx, tt.args.req, tt.args.resp)
- })
- }
-}
-
-func Test_instanceResource_Delete(t *testing.T) {
- type fields struct {
- client *sqlserverflex.APIClient
- providerData core.ProviderData
- }
- type args struct {
- ctx context.Context
- req resource.DeleteRequest
- resp *resource.DeleteResponse
- }
- tests := []struct {
- name string
- fields fields
- args args
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- r := &instanceResource{
- client: tt.fields.client,
- providerData: tt.fields.providerData,
- }
- r.Delete(tt.args.ctx, tt.args.req, tt.args.resp)
- })
- }
-}
-
-func Test_instanceResource_ImportState(t *testing.T) {
- type fields struct {
- client *sqlserverflex.APIClient
- providerData core.ProviderData
- }
- type args struct {
- ctx context.Context
- req resource.ImportStateRequest
- resp *resource.ImportStateResponse
- }
- tests := []struct {
- name string
- fields fields
- args args
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- r := &instanceResource{
- client: tt.fields.client,
- providerData: tt.fields.providerData,
- }
- r.ImportState(tt.args.ctx, tt.args.req, tt.args.resp)
- })
- }
-}
-
-func Test_instanceResource_Metadata(t *testing.T) {
- type fields struct {
- client *sqlserverflex.APIClient
- providerData core.ProviderData
- }
- type args struct {
- in0 context.Context
- req resource.MetadataRequest
- resp *resource.MetadataResponse
- }
- tests := []struct {
- name string
- fields fields
- args args
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- r := &instanceResource{
- client: tt.fields.client,
- providerData: tt.fields.providerData,
- }
- r.Metadata(tt.args.in0, tt.args.req, tt.args.resp)
- })
- }
-}
-
-func Test_instanceResource_ModifyPlan(t *testing.T) {
- type fields struct {
- client *sqlserverflex.APIClient
- providerData core.ProviderData
- }
- type args struct {
- ctx context.Context
- req resource.ModifyPlanRequest
- resp *resource.ModifyPlanResponse
- }
- tests := []struct {
- name string
- fields fields
- args args
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- r := &instanceResource{
- client: tt.fields.client,
- providerData: tt.fields.providerData,
- }
- r.ModifyPlan(tt.args.ctx, tt.args.req, tt.args.resp)
- })
- }
-}
-
-func Test_instanceResource_Read(t *testing.T) {
- type fields struct {
- client *sqlserverflex.APIClient
- providerData core.ProviderData
- }
- type args struct {
- ctx context.Context
- req resource.ReadRequest
- resp *resource.ReadResponse
- }
- tests := []struct {
- name string
- fields fields
- args args
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- r := &instanceResource{
- client: tt.fields.client,
- providerData: tt.fields.providerData,
- }
- r.Read(tt.args.ctx, tt.args.req, tt.args.resp)
- })
- }
-}
-
-func Test_instanceResource_Schema(t *testing.T) {
- type fields struct {
- client *sqlserverflex.APIClient
- providerData core.ProviderData
- }
- type args struct {
- in0 context.Context
- in1 resource.SchemaRequest
- resp *resource.SchemaResponse
- }
- tests := []struct {
- name string
- fields fields
- args args
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- r := &instanceResource{
- client: tt.fields.client,
- providerData: tt.fields.providerData,
- }
- r.Schema(tt.args.in0, tt.args.in1, tt.args.resp)
- })
- }
-}
-
-func Test_instanceResource_Update(t *testing.T) {
- type fields struct {
- client *sqlserverflex.APIClient
- providerData core.ProviderData
- }
- type args struct {
- ctx context.Context
- req resource.UpdateRequest
- resp *resource.UpdateResponse
- }
- tests := []struct {
- name string
- fields fields
- args args
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- r := &instanceResource{
- client: tt.fields.client,
- providerData: tt.fields.providerData,
- }
- r.Update(tt.args.ctx, tt.args.req, tt.args.resp)
- })
- }
-}
diff --git a/stackit/internal/services/sqlserverflexalpha/instance/resource_test.go b/stackit/internal/services/sqlserverflexalpha/instance/resource_test.go
deleted file mode 100644
index 601af2fa..00000000
--- a/stackit/internal/services/sqlserverflexalpha/instance/resource_test.go
+++ /dev/null
@@ -1,862 +0,0 @@
-package sqlserverflex
-
-import (
- "context"
- "fmt"
- "testing"
-
- "github.com/google/go-cmp/cmp"
- "github.com/hashicorp/terraform-plugin-framework/attr"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
- "github.com/stackitcloud/stackit-sdk-go/core/utils"
- sqlserverflex "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
-)
-
-type sqlserverflexClientMocked struct {
- returnError bool
- listFlavorsResp *sqlserverflex.GetFlavorsResponse
-}
-
-func (c *sqlserverflexClientMocked) GetFlavorsExecute(_ context.Context, _, _ string) (*sqlserverflex.GetFlavorsResponse, error) {
- if c.returnError {
- return nil, fmt.Errorf("get flavors failed")
- }
-
- return c.listFlavorsResp, nil
-}
-
-func TestMapFields(t *testing.T) {
- const testRegion = "region"
- tests := []struct {
- description string
- state Model
- input *sqlserverflex.GetInstanceResponse
- flavor *flavorModel
- storage *storageModel
- encryption *encryptionModel
- network *networkModel
- region string
- expected Model
- isValid bool
- }{
- {
- "default_values",
- Model{
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Replicas: types.Int64Value(1),
- RetentionDays: types.Int64Value(1),
- Version: types.StringValue("v1"),
- Edition: types.StringValue("edition 1"),
- Status: types.StringValue("status"),
- IsDeletable: types.BoolValue(true),
- Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
- "id": types.StringValue("flavor_id"),
- "description": types.StringNull(),
- "cpu": types.Int64Null(),
- "ram": types.Int64Null(),
- "node_type": types.StringNull(),
- }),
- },
- &sqlserverflex.GetInstanceResponse{
- FlavorId: utils.Ptr("flavor_id"),
- Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(1))),
- RetentionDays: utils.Ptr(int64(1)),
- Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("v1")),
- Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition 1")),
- Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
- IsDeletable: utils.Ptr(true),
- },
- &flavorModel{
- Id: types.StringValue("flavor_id"),
- },
- &storageModel{},
- &encryptionModel{},
- &networkModel{
- ACL: types.ListNull(basetypes.StringType{}),
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Name: types.StringNull(),
- BackupSchedule: types.StringNull(),
- Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
- "id": types.StringValue("flavor_id"),
- "description": types.StringNull(),
- "cpu": types.Int64Null(),
- "ram": types.Int64Null(),
- "node_type": types.StringNull(),
- }),
- Replicas: types.Int64Value(1),
- Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
- "class": types.StringNull(),
- "size": types.Int64Null(),
- }),
- Encryption: types.ObjectValueMust(encryptionTypes, map[string]attr.Value{
- "keyring_id": types.StringNull(),
- "key_id": types.StringNull(),
- "key_version": types.StringNull(),
- "service_account": types.StringNull(),
- }),
- Network: types.ObjectValueMust(networkTypes, map[string]attr.Value{
- "acl": types.ListNull(types.StringType),
- "access_scope": types.StringNull(),
- "instance_address": types.StringNull(),
- "router_address": types.StringNull(),
- }),
- IsDeletable: types.BoolValue(true),
- Edition: types.StringValue("edition 1"),
- Status: types.StringValue("status"),
- RetentionDays: types.Int64Value(1),
- Version: types.StringValue("v1"),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "simple_values",
- Model{
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- },
- &sqlserverflex.GetInstanceResponse{
- Acl: &[]string{
- "ip1",
- "ip2",
- "",
- },
- BackupSchedule: utils.Ptr("schedule"),
- FlavorId: utils.Ptr("flavor_id"),
- Id: utils.Ptr("iid"),
- Name: utils.Ptr("name"),
- Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
- Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
- Storage: &sqlserverflex.Storage{
- Class: utils.Ptr("class"),
- Size: utils.Ptr(int64(78)),
- },
- Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition")),
- RetentionDays: utils.Ptr(int64(1)),
- Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")),
- IsDeletable: utils.Ptr(true),
- Encryption: nil,
- },
- &flavorModel{
- Id: basetypes.NewStringValue("flavor_id"),
- Description: basetypes.NewStringValue("description"),
- CPU: basetypes.NewInt64Value(12),
- RAM: basetypes.NewInt64Value(34),
- NodeType: basetypes.NewStringValue("node_type"),
- },
- &storageModel{},
- &encryptionModel{},
- &networkModel{
- ACL: types.ListValueMust(basetypes.StringType{}, []attr.Value{
- types.StringValue("ip1"),
- types.StringValue("ip2"),
- types.StringValue(""),
- }),
- },
- testRegion,
- Model{
- Id: types.StringValue("pid,region,iid"),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Name: types.StringValue("name"),
- BackupSchedule: types.StringValue("schedule"),
- Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
- "id": types.StringValue("flavor_id"),
- "description": types.StringValue("description"),
- "cpu": types.Int64Value(12),
- "ram": types.Int64Value(34),
- "node_type": types.StringValue("node_type"),
- }),
- Replicas: types.Int64Value(56),
- Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
- "class": types.StringValue("class"),
- "size": types.Int64Value(78),
- }),
- Network: types.ObjectValueMust(networkTypes, map[string]attr.Value{
- "acl": types.ListValueMust(types.StringType, []attr.Value{
- types.StringValue("ip1"),
- types.StringValue("ip2"),
- types.StringValue(""),
- }),
- "access_scope": types.StringNull(),
- "instance_address": types.StringNull(),
- "router_address": types.StringNull(),
- }),
- Edition: types.StringValue("edition"),
- RetentionDays: types.Int64Value(1),
- Version: types.StringValue("version"),
- Region: types.StringValue(testRegion),
- IsDeletable: types.BoolValue(true),
- Encryption: types.ObjectValueMust(encryptionTypes, map[string]attr.Value{
- "keyring_id": types.StringNull(),
- "key_id": types.StringNull(),
- "key_version": types.StringNull(),
- "service_account": types.StringNull(),
- }),
- Status: types.StringValue("status"),
- },
- true,
- },
- //{
- // "simple_values_no_flavor_and_storage",
- // Model{
- // InstanceId: types.StringValue("iid"),
- // ProjectId: types.StringValue("pid"),
- // },
- // &sqlserverflex.GetInstanceResponse{
- // Acl: &[]string{
- // "ip1",
- // "ip2",
- // "",
- // },
- // BackupSchedule: utils.Ptr("schedule"),
- // FlavorId: nil,
- // Id: utils.Ptr("iid"),
- // Name: utils.Ptr("name"),
- // Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
- // Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
- // Storage: nil,
- // Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition")),
- // RetentionDays: utils.Ptr(int64(1)),
- // Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")),
- // },
- // &flavorModel{
- // CPU: types.Int64Value(12),
- // RAM: types.Int64Value(34),
- // },
- // &storageModel{
- // Class: types.StringValue("class"),
- // Size: types.Int64Value(78),
- // },
- // &optionsModel{
- // Edition: types.StringValue("edition"),
- // RetentionDays: types.Int64Value(1),
- // },
- // testRegion,
- // Model{
- // Id: types.StringValue("pid,region,iid"),
- // InstanceId: types.StringValue("iid"),
- // ProjectId: types.StringValue("pid"),
- // Name: types.StringValue("name"),
- // ACL: types.ListValueMust(types.StringType, []attr.Value{
- // types.StringValue("ip1"),
- // types.StringValue("ip2"),
- // types.StringValue(""),
- // }),
- // BackupSchedule: types.StringValue("schedule"),
- // Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
- // "id": types.StringNull(),
- // "description": types.StringNull(),
- // "cpu": types.Int64Value(12),
- // "ram": types.Int64Value(34),
- // }),
- // Replicas: types.Int64Value(56),
- // Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
- // "class": types.StringValue("class"),
- // "size": types.Int64Value(78),
- // }),
- // Options: types.ObjectValueMust(optionsTypes, map[string]attr.Value{
- // "edition": types.StringValue("edition"),
- // "retention_days": types.Int64Value(1),
- // }),
- // Version: types.StringValue("version"),
- // Region: types.StringValue(testRegion),
- // },
- // true,
- //},
- //{
- // "acls_unordered",
- // Model{
- // InstanceId: types.StringValue("iid"),
- // ProjectId: types.StringValue("pid"),
- // ACL: types.ListValueMust(types.StringType, []attr.Value{
- // types.StringValue("ip2"),
- // types.StringValue(""),
- // types.StringValue("ip1"),
- // }),
- // },
- // &sqlserverflex.GetInstanceResponse{
- // Acl: &[]string{
- // "",
- // "ip1",
- // "ip2",
- // },
- // BackupSchedule: utils.Ptr("schedule"),
- // FlavorId: nil,
- // Id: utils.Ptr("iid"),
- // Name: utils.Ptr("name"),
- // Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
- // Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
- // Storage: nil,
- // //Options: &map[string]string{
- // // "edition": "edition",
- // // "retentionDays": "1",
- // //},
- // Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")),
- // },
- // &flavorModel{
- // CPU: types.Int64Value(12),
- // RAM: types.Int64Value(34),
- // },
- // &storageModel{
- // Class: types.StringValue("class"),
- // Size: types.Int64Value(78),
- // },
- // &optionsModel{},
- // testRegion,
- // Model{
- // Id: types.StringValue("pid,region,iid"),
- // InstanceId: types.StringValue("iid"),
- // ProjectId: types.StringValue("pid"),
- // Name: types.StringValue("name"),
- // ACL: types.ListValueMust(types.StringType, []attr.Value{
- // types.StringValue("ip2"),
- // types.StringValue(""),
- // types.StringValue("ip1"),
- // }),
- // BackupSchedule: types.StringValue("schedule"),
- // Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
- // "id": types.StringNull(),
- // "description": types.StringNull(),
- // "cpu": types.Int64Value(12),
- // "ram": types.Int64Value(34),
- // }),
- // Replicas: types.Int64Value(56),
- // Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
- // "class": types.StringValue("class"),
- // "size": types.Int64Value(78),
- // }),
- // Options: types.ObjectValueMust(optionsTypes, map[string]attr.Value{
- // "edition": types.StringValue("edition"),
- // "retention_days": types.Int64Value(1),
- // }),
- // Version: types.StringValue("version"),
- // Region: types.StringValue(testRegion),
- // },
- // true,
- //},
- //{
- // "nil_response",
- // Model{
- // InstanceId: types.StringValue("iid"),
- // ProjectId: types.StringValue("pid"),
- // },
- // nil,
- // &flavorModel{},
- // &storageModel{},
- // &optionsModel{},
- // testRegion,
- // Model{},
- // false,
- //},
- //{
- // "no_resource_id",
- // Model{
- // InstanceId: types.StringValue("iid"),
- // ProjectId: types.StringValue("pid"),
- // },
- // &sqlserverflex.GetInstanceResponse{},
- // &flavorModel{},
- // &storageModel{},
- // &optionsModel{},
- // testRegion,
- // Model{},
- // false,
- //},
- }
- for _, tt := range tests {
- t.Run(tt.description, func(t *testing.T) {
- err := mapFields(context.Background(), tt.input, &tt.state, tt.flavor, tt.storage, tt.encryption, tt.network, tt.region)
- if !tt.isValid && err == nil {
- t.Fatalf("Should have failed")
- }
- if tt.isValid && err != nil {
- t.Fatalf("Should not have failed: %v", err)
- }
- if tt.isValid {
- diff := cmp.Diff(tt.state, tt.expected)
- if diff != "" {
- t.Fatalf("Data does not match: %s", diff)
- }
- }
- })
- }
-}
-
-//func TestToCreatePayload(t *testing.T) {
-// tests := []struct {
-// description string
-// input *Model
-// inputAcl []string
-// inputFlavor *flavorModel
-// inputStorage *storageModel
-// inputOptions *optionsModel
-// expected *sqlserverflex.CreateInstanceRequestPayload
-// isValid bool
-// }{
-// {
-// "default_values",
-// &Model{},
-// []string{},
-// &flavorModel{},
-// &storageModel{},
-// &optionsModel{},
-// &sqlserverflex.CreateInstanceRequestPayload{
-// Acl: &sqlserverflex.CreateInstanceRequestPayloadGetAclArgType{},
-// Storage: &sqlserverflex.CreateInstanceRequestPayloadGetStorageArgType{},
-// },
-// true,
-// },
-// {
-// "simple_values",
-// &Model{
-// BackupSchedule: types.StringValue("schedule"),
-// Name: types.StringValue("name"),
-// Replicas: types.Int64Value(12),
-// Version: types.StringValue("version"),
-// },
-// []string{
-// "ip_1",
-// "ip_2",
-// },
-// &flavorModel{
-// Id: types.StringValue("flavor_id"),
-// },
-// &storageModel{
-// Class: types.StringValue("class"),
-// Size: types.Int64Value(34),
-// },
-// &optionsModel{
-// Edition: types.StringValue("edition"),
-// RetentionDays: types.Int64Value(1),
-// },
-// &sqlserverflex.CreateInstancePayload{
-// Acl: &sqlserverflex.CreateInstancePayloadAcl{
-// Items: &[]string{
-// "ip_1",
-// "ip_2",
-// },
-// },
-// BackupSchedule: utils.Ptr("schedule"),
-// FlavorId: utils.Ptr("flavor_id"),
-// Name: utils.Ptr("name"),
-// Storage: &sqlserverflex.CreateInstancePayloadStorage{
-// Class: utils.Ptr("class"),
-// Size: utils.Ptr(int64(34)),
-// },
-// Options: &sqlserverflex.CreateInstancePayloadOptions{
-// Edition: utils.Ptr("edition"),
-// RetentionDays: utils.Ptr("1"),
-// },
-// Version: utils.Ptr("version"),
-// },
-// true,
-// },
-// {
-// "null_fields_and_int_conversions",
-// &Model{
-// BackupSchedule: types.StringNull(),
-// Name: types.StringNull(),
-// Replicas: types.Int64Value(2123456789),
-// Version: types.StringNull(),
-// },
-// []string{
-// "",
-// },
-// &flavorModel{
-// Id: types.StringNull(),
-// },
-// &storageModel{
-// Class: types.StringNull(),
-// Size: types.Int64Null(),
-// },
-// &optionsModel{
-// Edition: types.StringNull(),
-// RetentionDays: types.Int64Null(),
-// },
-// &sqlserverflex.CreateInstancePayload{
-// Acl: &sqlserverflex.CreateInstancePayloadAcl{
-// Items: &[]string{
-// "",
-// },
-// },
-// BackupSchedule: nil,
-// FlavorId: nil,
-// Name: nil,
-// Storage: &sqlserverflex.CreateInstancePayloadStorage{
-// Class: nil,
-// Size: nil,
-// },
-// Options: &sqlserverflex.CreateInstancePayloadOptions{},
-// Version: nil,
-// },
-// true,
-// },
-// {
-// "nil_model",
-// nil,
-// []string{},
-// &flavorModel{},
-// &storageModel{},
-// &optionsModel{},
-// nil,
-// false,
-// },
-// {
-// "nil_acl",
-// &Model{},
-// nil,
-// &flavorModel{},
-// &storageModel{},
-// &optionsModel{},
-// &sqlserverflex.CreateInstancePayload{
-// Acl: &sqlserverflex.CreateInstancePayloadAcl{},
-// Storage: &sqlserverflex.CreateInstancePayloadStorage{},
-// Options: &sqlserverflex.CreateInstancePayloadOptions{},
-// },
-// true,
-// },
-// {
-// "nil_flavor",
-// &Model{},
-// []string{},
-// nil,
-// &storageModel{},
-// &optionsModel{},
-// nil,
-// false,
-// },
-// {
-// "nil_storage",
-// &Model{},
-// []string{},
-// &flavorModel{},
-// nil,
-// &optionsModel{},
-// &sqlserverflex.CreateInstancePayload{
-// Acl: &sqlserverflex.CreateInstancePayloadAcl{
-// Items: &[]string{},
-// },
-// Storage: &sqlserverflex.CreateInstancePayloadStorage{},
-// Options: &sqlserverflex.CreateInstancePayloadOptions{},
-// },
-// true,
-// },
-// {
-// "nil_options",
-// &Model{},
-// []string{},
-// &flavorModel{},
-// &storageModel{},
-// nil,
-// &sqlserverflex.CreateInstancePayload{
-// Acl: &sqlserverflex.CreateInstancePayloadAcl{
-// Items: &[]string{},
-// },
-// Storage: &sqlserverflex.CreateInstancePayloadStorage{},
-// Options: &sqlserverflex.CreateInstancePayloadOptions{},
-// },
-// true,
-// },
-// }
-// for _, tt := range tests {
-// t.Run(tt.description, func(t *testing.T) {
-// output, err := toCreatePayload(tt.input, tt.inputAcl, tt.inputFlavor, tt.inputStorage, tt.inputOptions)
-// if !tt.isValid && err == nil {
-// t.Fatalf("Should have failed")
-// }
-// if tt.isValid && err != nil {
-// t.Fatalf("Should not have failed: %v", err)
-// }
-// if tt.isValid {
-// diff := cmp.Diff(output, tt.expected)
-// if diff != "" {
-// t.Fatalf("Data does not match: %s", diff)
-// }
-// }
-// })
-// }
-//}
-//
-//func TestToUpdatePayload(t *testing.T) {
-// tests := []struct {
-// description string
-// input *Model
-// inputAcl []string
-// inputFlavor *flavorModel
-// expected *sqlserverflex.PartialUpdateInstancePayload
-// isValid bool
-// }{
-// {
-// "default_values",
-// &Model{},
-// []string{},
-// &flavorModel{},
-// &sqlserverflex.PartialUpdateInstancePayload{
-// Acl: &sqlserverflex.CreateInstancePayloadAcl{
-// Items: &[]string{},
-// },
-// },
-// true,
-// },
-// {
-// "simple_values",
-// &Model{
-// BackupSchedule: types.StringValue("schedule"),
-// Name: types.StringValue("name"),
-// Replicas: types.Int64Value(12),
-// Version: types.StringValue("version"),
-// },
-// []string{
-// "ip_1",
-// "ip_2",
-// },
-// &flavorModel{
-// Id: types.StringValue("flavor_id"),
-// },
-// &sqlserverflex.PartialUpdateInstancePayload{
-// Acl: &sqlserverflex.CreateInstancePayloadAcl{
-// Items: &[]string{
-// "ip_1",
-// "ip_2",
-// },
-// },
-// BackupSchedule: utils.Ptr("schedule"),
-// FlavorId: utils.Ptr("flavor_id"),
-// Name: utils.Ptr("name"),
-// Version: utils.Ptr("version"),
-// },
-// true,
-// },
-// {
-// "null_fields_and_int_conversions",
-// &Model{
-// BackupSchedule: types.StringNull(),
-// Name: types.StringNull(),
-// Replicas: types.Int64Value(2123456789),
-// Version: types.StringNull(),
-// },
-// []string{
-// "",
-// },
-// &flavorModel{
-// Id: types.StringNull(),
-// },
-// &sqlserverflex.PartialUpdateInstancePayload{
-// Acl: &sqlserverflex.CreateInstancePayloadAcl{
-// Items: &[]string{
-// "",
-// },
-// },
-// BackupSchedule: nil,
-// FlavorId: nil,
-// Name: nil,
-// Version: nil,
-// },
-// true,
-// },
-// {
-// "nil_model",
-// nil,
-// []string{},
-// &flavorModel{},
-// nil,
-// false,
-// },
-// {
-// "nil_acl",
-// &Model{},
-// nil,
-// &flavorModel{},
-// &sqlserverflex.PartialUpdateInstancePayload{
-// Acl: &sqlserverflex.CreateInstancePayloadAcl{},
-// },
-// true,
-// },
-// {
-// "nil_flavor",
-// &Model{},
-// []string{},
-// nil,
-// nil,
-// false,
-// },
-// }
-// for _, tt := range tests {
-// t.Run(tt.description, func(t *testing.T) {
-// output, err := toUpdatePayload(tt.input, tt.inputAcl, tt.inputFlavor)
-// if !tt.isValid && err == nil {
-// t.Fatalf("Should have failed")
-// }
-// if tt.isValid && err != nil {
-// t.Fatalf("Should not have failed: %v", err)
-// }
-// if tt.isValid {
-// diff := cmp.Diff(output, tt.expected)
-// if diff != "" {
-// t.Fatalf("Data does not match: %s", diff)
-// }
-// }
-// })
-// }
-//}
-//
-//func TestLoadFlavorId(t *testing.T) {
-// tests := []struct {
-// description string
-// inputFlavor *flavorModel
-// mockedResp *sqlserverflex.ListFlavorsResponse
-// expected *flavorModel
-// getFlavorsFails bool
-// isValid bool
-// }{
-// {
-// "ok_flavor",
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// &sqlserverflex.ListFlavorsResponse{
-// Flavors: &[]sqlserverflex.InstanceFlavorEntry{
-// {
-// Id: utils.Ptr("fid-1"),
-// Cpu: utils.Ptr(int64(2)),
-// Description: utils.Ptr("description"),
-// Memory: utils.Ptr(int64(8)),
-// },
-// },
-// },
-// &flavorModel{
-// Id: types.StringValue("fid-1"),
-// Description: types.StringValue("description"),
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// false,
-// true,
-// },
-// {
-// "ok_flavor_2",
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// &sqlserverflex.ListFlavorsResponse{
-// Flavors: &[]sqlserverflex.InstanceFlavorEntry{
-// {
-// Id: utils.Ptr("fid-1"),
-// Cpu: utils.Ptr(int64(2)),
-// Description: utils.Ptr("description"),
-// Memory: utils.Ptr(int64(8)),
-// },
-// {
-// Id: utils.Ptr("fid-2"),
-// Cpu: utils.Ptr(int64(1)),
-// Description: utils.Ptr("description"),
-// Memory: utils.Ptr(int64(4)),
-// },
-// },
-// },
-// &flavorModel{
-// Id: types.StringValue("fid-1"),
-// Description: types.StringValue("description"),
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// false,
-// true,
-// },
-// {
-// "no_matching_flavor",
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// &sqlserverflex.ListFlavorsResponse{
-// Flavors: &[]sqlserverflex.InstanceFlavorEntry{
-// {
-// Id: utils.Ptr("fid-1"),
-// Cpu: utils.Ptr(int64(1)),
-// Description: utils.Ptr("description"),
-// Memory: utils.Ptr(int64(8)),
-// },
-// {
-// Id: utils.Ptr("fid-2"),
-// Cpu: utils.Ptr(int64(1)),
-// Description: utils.Ptr("description"),
-// Memory: utils.Ptr(int64(4)),
-// },
-// },
-// },
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// false,
-// false,
-// },
-// {
-// "nil_response",
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// &sqlserverflex.ListFlavorsResponse{},
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// false,
-// false,
-// },
-// {
-// "error_response",
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// &sqlserverflex.ListFlavorsResponse{},
-// &flavorModel{
-// CPU: types.Int64Value(2),
-// RAM: types.Int64Value(8),
-// },
-// true,
-// false,
-// },
-// }
-// for _, tt := range tests {
-// t.Run(tt.description, func(t *testing.T) {
-// client := &sqlserverflexClientMocked{
-// returnError: tt.getFlavorsFails,
-// listFlavorsResp: tt.mockedResp,
-// }
-// model := &Model{
-// ProjectId: types.StringValue("pid"),
-// }
-// flavorModel := &flavorModel{
-// CPU: tt.inputFlavor.CPU,
-// RAM: tt.inputFlavor.RAM,
-// }
-// err := loadFlavorId(context.Background(), client, model, flavorModel)
-// if !tt.isValid && err == nil {
-// t.Fatalf("Should have failed")
-// }
-// if tt.isValid && err != nil {
-// t.Fatalf("Should not have failed: %v", err)
-// }
-// if tt.isValid {
-// diff := cmp.Diff(flavorModel, tt.expected)
-// if diff != "" {
-// t.Fatalf("Data does not match: %s", diff)
-// }
-// }
-// })
-// }
-//}
diff --git a/stackit/internal/services/sqlserverflexalpha/instance/resources_gen/instance_resource_gen.go b/stackit/internal/services/sqlserverflexalpha/instance/resources_gen/instance_resource_gen.go
new file mode 100644
index 00000000..671c7fd3
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/instance/resources_gen/instance_resource_gen.go
@@ -0,0 +1,1597 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+)
+
+func InstanceResourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "backup_schedule": schema.StringAttribute{
+ Required: true,
+ Description: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ MarkdownDescription: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ },
+ "edition": schema.StringAttribute{
+ Computed: true,
+ Description: "Edition of the MSSQL server instance",
+ MarkdownDescription: "Edition of the MSSQL server instance",
+ },
+ "encryption": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "kek_key_id": schema.StringAttribute{
+ Required: true,
+ Description: "The key identifier",
+ MarkdownDescription: "The key identifier",
+ },
+ "kek_key_ring_id": schema.StringAttribute{
+ Required: true,
+ Description: "The keyring identifier",
+ MarkdownDescription: "The keyring identifier",
+ },
+ "kek_key_version": schema.StringAttribute{
+ Required: true,
+ Description: "The key version",
+ MarkdownDescription: "The key version",
+ },
+ "service_account": schema.StringAttribute{
+ Required: true,
+ },
+ },
+ CustomType: EncryptionType{
+ ObjectType: types.ObjectType{
+ AttrTypes: EncryptionValue{}.AttributeTypes(ctx),
+ },
+ },
+ Optional: true,
+ Computed: true,
+ Description: "this defines which key to use for storage encryption",
+ MarkdownDescription: "this defines which key to use for storage encryption",
+ },
+ "flavor_id": schema.StringAttribute{
+ Required: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "instance_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "is_deletable": schema.BoolAttribute{
+ Computed: true,
+ Description: "Whether the instance can be deleted or not.",
+ MarkdownDescription: "Whether the instance can be deleted or not.",
+ },
+ "name": schema.StringAttribute{
+ Required: true,
+ Description: "The name of the instance.",
+ MarkdownDescription: "The name of the instance.",
+ },
+ "network": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "access_scope": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The network access scope of the instance\n\n⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ MarkdownDescription: "The network access scope of the instance\n\n⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "PUBLIC",
+ "SNA",
+ ),
+ },
+ Default: stringdefault.StaticString("PUBLIC"),
+ },
+ "acl": schema.ListAttribute{
+ ElementType: types.StringType,
+ Required: true,
+ Description: "List of IPV4 cidr.",
+ MarkdownDescription: "List of IPV4 cidr.",
+ },
+ "instance_address": schema.StringAttribute{
+ Computed: true,
+ },
+ "router_address": schema.StringAttribute{
+ Computed: true,
+ },
+ },
+ CustomType: NetworkType{
+ ObjectType: types.ObjectType{
+ AttrTypes: NetworkValue{}.AttributeTypes(ctx),
+ },
+ },
+ Required: true,
+ Description: "the network configuration of the instance.",
+ MarkdownDescription: "the network configuration of the instance.",
+ },
+ "project_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "replicas": schema.Int64Attribute{
+ Computed: true,
+ Description: "How many replicas the instance should have.",
+ MarkdownDescription: "How many replicas the instance should have.",
+ },
+ "retention_days": schema.Int64Attribute{
+ Required: true,
+ Description: "The days for how long the backup files should be stored before cleaned up. 30 to 365",
+ MarkdownDescription: "The days for how long the backup files should be stored before cleaned up. 30 to 365",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ },
+ "storage": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Required: true,
+ Description: "The storage class for the storage.",
+ MarkdownDescription: "The storage class for the storage.",
+ },
+ "size": schema.Int64Attribute{
+ Required: true,
+ Description: "The storage size in Gigabytes.",
+ MarkdownDescription: "The storage size in Gigabytes.",
+ },
+ },
+ CustomType: StorageType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageValue{}.AttributeTypes(ctx),
+ },
+ },
+ Required: true,
+ Description: "The object containing information about the storage size and class.",
+ MarkdownDescription: "The object containing information about the storage size and class.",
+ },
+ "version": schema.StringAttribute{
+ Required: true,
+ Description: "The sqlserver version used for the instance.",
+ MarkdownDescription: "The sqlserver version used for the instance.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "2022",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type InstanceModel struct {
+ BackupSchedule types.String `tfsdk:"backup_schedule"`
+ Edition types.String `tfsdk:"edition"`
+ Encryption EncryptionValue `tfsdk:"encryption"`
+ FlavorId types.String `tfsdk:"flavor_id"`
+ Id types.String `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ IsDeletable types.Bool `tfsdk:"is_deletable"`
+ Name types.String `tfsdk:"name"`
+ Network NetworkValue `tfsdk:"network"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Replicas types.Int64 `tfsdk:"replicas"`
+ RetentionDays types.Int64 `tfsdk:"retention_days"`
+ Status types.String `tfsdk:"status"`
+ Storage StorageValue `tfsdk:"storage"`
+ Version types.String `tfsdk:"version"`
+}
+
+var _ basetypes.ObjectTypable = EncryptionType{}
+
+type EncryptionType struct {
+ basetypes.ObjectType
+}
+
+func (t EncryptionType) Equal(o attr.Type) bool {
+ other, ok := o.(EncryptionType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t EncryptionType) String() string {
+ return "EncryptionType"
+}
+
+func (t EncryptionType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return nil, diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueNull() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewEncryptionValueUnknown() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewEncryptionValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (EncryptionValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, a missing attribute value was detected. "+
+ "A EncryptionValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid EncryptionValue Attribute Type",
+ "While creating a EncryptionValue value, an invalid attribute value was detected. "+
+ "A EncryptionValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, an extra attribute value was detected. "+
+ "A EncryptionValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra EncryptionValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) EncryptionValue {
+ object, diags := NewEncryptionValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewEncryptionValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t EncryptionType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewEncryptionValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewEncryptionValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewEncryptionValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewEncryptionValueMust(EncryptionValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t EncryptionType) ValueType(ctx context.Context) attr.Value {
+ return EncryptionValue{}
+}
+
+var _ basetypes.ObjectValuable = EncryptionValue{}
+
+type EncryptionValue struct {
+ KekKeyId basetypes.StringValue `tfsdk:"kek_key_id"`
+ KekKeyRingId basetypes.StringValue `tfsdk:"kek_key_ring_id"`
+ KekKeyVersion basetypes.StringValue `tfsdk:"kek_key_version"`
+ ServiceAccount basetypes.StringValue `tfsdk:"service_account"`
+ state attr.ValueState
+}
+
+func (v EncryptionValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["kek_key_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_ring_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_version"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["service_account"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.KekKeyId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_id"] = val
+
+ val, err = v.KekKeyRingId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_ring_id"] = val
+
+ val, err = v.KekKeyVersion.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_version"] = val
+
+ val, err = v.ServiceAccount.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["service_account"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v EncryptionValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v EncryptionValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v EncryptionValue) String() string {
+ return "EncryptionValue"
+}
+
+func (v EncryptionValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "kek_key_id": v.KekKeyId,
+ "kek_key_ring_id": v.KekKeyRingId,
+ "kek_key_version": v.KekKeyVersion,
+ "service_account": v.ServiceAccount,
+ })
+
+ return objVal, diags
+}
+
+func (v EncryptionValue) Equal(o attr.Value) bool {
+ other, ok := o.(EncryptionValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.KekKeyId.Equal(other.KekKeyId) {
+ return false
+ }
+
+ if !v.KekKeyRingId.Equal(other.KekKeyRingId) {
+ return false
+ }
+
+ if !v.KekKeyVersion.Equal(other.KekKeyVersion) {
+ return false
+ }
+
+ if !v.ServiceAccount.Equal(other.ServiceAccount) {
+ return false
+ }
+
+ return true
+}
+
+func (v EncryptionValue) Type(ctx context.Context) attr.Type {
+ return EncryptionType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v EncryptionValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = NetworkType{}
+
+type NetworkType struct {
+ basetypes.ObjectType
+}
+
+func (t NetworkType) Equal(o attr.Type) bool {
+ other, ok := o.(NetworkType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t NetworkType) String() string {
+ return "NetworkType"
+}
+
+func (t NetworkType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return nil, diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return nil, diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return nil, diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return nil, diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueNull() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewNetworkValueUnknown() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewNetworkValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (NetworkValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing NetworkValue Attribute Value",
+ "While creating a NetworkValue value, a missing attribute value was detected. "+
+ "A NetworkValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid NetworkValue Attribute Type",
+ "While creating a NetworkValue value, an invalid attribute value was detected. "+
+ "A NetworkValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra NetworkValue Attribute Value",
+ "While creating a NetworkValue value, an extra attribute value was detected. "+
+ "A NetworkValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra NetworkValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) NetworkValue {
+ object, diags := NewNetworkValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewNetworkValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t NetworkType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewNetworkValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewNetworkValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewNetworkValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewNetworkValueMust(NetworkValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t NetworkType) ValueType(ctx context.Context) attr.Value {
+ return NetworkValue{}
+}
+
+var _ basetypes.ObjectValuable = NetworkValue{}
+
+type NetworkValue struct {
+ AccessScope basetypes.StringValue `tfsdk:"access_scope"`
+ Acl basetypes.ListValue `tfsdk:"acl"`
+ InstanceAddress basetypes.StringValue `tfsdk:"instance_address"`
+ RouterAddress basetypes.StringValue `tfsdk:"router_address"`
+ state attr.ValueState
+}
+
+func (v NetworkValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["access_scope"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["acl"] = basetypes.ListType{
+ ElemType: types.StringType,
+ }.TerraformType(ctx)
+ attrTypes["instance_address"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["router_address"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.AccessScope.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["access_scope"] = val
+
+ val, err = v.Acl.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["acl"] = val
+
+ val, err = v.InstanceAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["instance_address"] = val
+
+ val, err = v.RouterAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["router_address"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v NetworkValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v NetworkValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v NetworkValue) String() string {
+ return "NetworkValue"
+}
+
+func (v NetworkValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ var aclVal basetypes.ListValue
+ switch {
+ case v.Acl.IsUnknown():
+ aclVal = types.ListUnknown(types.StringType)
+ case v.Acl.IsNull():
+ aclVal = types.ListNull(types.StringType)
+ default:
+ var d diag.Diagnostics
+ aclVal, d = types.ListValue(types.StringType, v.Acl.Elements())
+ diags.Append(d...)
+ }
+
+ if diags.HasError() {
+ return types.ObjectUnknown(map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }), diags
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "access_scope": v.AccessScope,
+ "acl": aclVal,
+ "instance_address": v.InstanceAddress,
+ "router_address": v.RouterAddress,
+ })
+
+ return objVal, diags
+}
+
+func (v NetworkValue) Equal(o attr.Value) bool {
+ other, ok := o.(NetworkValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.AccessScope.Equal(other.AccessScope) {
+ return false
+ }
+
+ if !v.Acl.Equal(other.Acl) {
+ return false
+ }
+
+ if !v.InstanceAddress.Equal(other.InstanceAddress) {
+ return false
+ }
+
+ if !v.RouterAddress.Equal(other.RouterAddress) {
+ return false
+ }
+
+ return true
+}
+
+func (v NetworkValue) Type(ctx context.Context) attr.Type {
+ return NetworkType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v NetworkValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageType{}
+
+type StorageType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageType) String() string {
+ return "StorageType"
+}
+
+func (t StorageType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return nil, diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageValue{
+ Class: classVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueNull() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageValueUnknown() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageValue Attribute Value",
+ "While creating a StorageValue value, a missing attribute value was detected. "+
+ "A StorageValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageValue Attribute Type",
+ "While creating a StorageValue value, an invalid attribute value was detected. "+
+ "A StorageValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageValue Attribute Value",
+ "While creating a StorageValue value, an extra attribute value was detected. "+
+ "A StorageValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ return StorageValue{
+ Class: classVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageValue {
+ object, diags := NewStorageValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageValueMust(StorageValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageType) ValueType(ctx context.Context) attr.Value {
+ return StorageValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageValue{}
+
+type StorageValue struct {
+ Class basetypes.StringValue `tfsdk:"class"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ state attr.ValueState
+}
+
+func (v StorageValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 2)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 2)
+
+ val, err = v.Class.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["class"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageValue) String() string {
+ return "StorageValue"
+}
+
+func (v StorageValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "class": v.Class,
+ "size": v.Size,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Class.Equal(other.Class) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageValue) Type(ctx context.Context) attr.Type {
+ return StorageType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go b/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go
index e3b4fa2b..9eebac99 100644
--- a/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go
+++ b/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go
@@ -1,482 +1,433 @@
-// Copyright (c) STACKIT
-
-package sqlserverflex_test
+package sqlserverflexalpha_test
import (
"context"
_ "embed"
"fmt"
- "maps"
+ "log"
+ "os"
+ "strconv"
"strings"
"testing"
- "github.com/hashicorp/terraform-plugin-testing/config"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
- "github.com/hashicorp/terraform-plugin-testing/terraform"
- core_config "github.com/stackitcloud/stackit-sdk-go/core/config"
- "github.com/stackitcloud/stackit-sdk-go/core/utils"
- "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex"
- "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/wait"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/testutil"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils"
+ sqlserverflexalphaPkgGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+ sqlserverflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance"
+
+ // The fwresource import alias is so there is no collision
+ // with the more typical acceptance testing import:
+ // "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ fwresource "github.com/hashicorp/terraform-plugin-framework/resource"
)
-var (
- //go:embed testdata/resource-max.tf
- resourceMaxConfig string
- //go:embed testdata/resource-min.tf
- resourceMinConfig string
-)
-var testConfigVarsMin = config.Variables{
- "project_id": config.StringVariable(testutil.ProjectId),
- "name": config.StringVariable(fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlphaNum))),
- "flavor_cpu": config.IntegerVariable(4),
- "flavor_ram": config.IntegerVariable(16),
- "flavor_description": config.StringVariable("SQLServer-Flex-4.16-Standard-EU01"),
- "replicas": config.IntegerVariable(1),
- "flavor_id": config.StringVariable("4.16-Single"),
- "username": config.StringVariable(fmt.Sprintf("tf-acc-user-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlpha))),
- "role": config.StringVariable("##STACKIT_LoginManager##"),
-}
+const providerPrefix = "stackitprivatepreview_sqlserverflexalpha"
-var testConfigVarsMax = config.Variables{
- "project_id": config.StringVariable(testutil.ProjectId),
- "name": config.StringVariable(fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlphaNum))),
- "acl1": config.StringVariable("192.168.0.0/16"),
- "flavor_cpu": config.IntegerVariable(4),
- "flavor_ram": config.IntegerVariable(16),
- "flavor_description": config.StringVariable("SQLServer-Flex-4.16-Standard-EU01"),
- "storage_class": config.StringVariable("premium-perf2-stackit"),
- "storage_size": config.IntegerVariable(40),
- "server_version": config.StringVariable("2022"),
- "replicas": config.IntegerVariable(1),
- "options_retention_days": config.IntegerVariable(64),
- "flavor_id": config.StringVariable("4.16-Single"),
- "backup_schedule": config.StringVariable("00 6 * * *"),
- "username": config.StringVariable(fmt.Sprintf("tf-acc-user-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlpha))),
- "role": config.StringVariable("##STACKIT_LoginManager##"),
- "region": config.StringVariable(testutil.Region),
-}
+var testInstances []string
-func configVarsMinUpdated() config.Variables {
- temp := maps.Clone(testConfigVarsMax)
- temp["name"] = config.StringVariable(testutil.ConvertConfigVariable(temp["name"]) + "changed")
- return temp
-}
+func init() {
+ sweeperName := fmt.Sprintf("%s_%s", providerPrefix, "sweeper")
-func configVarsMaxUpdated() config.Variables {
- temp := maps.Clone(testConfigVarsMax)
- temp["backup_schedule"] = config.StringVariable("00 12 * * *")
- return temp
-}
+ resource.AddTestSweepers(sweeperName, &resource.Sweeper{
+ Name: sweeperName,
+ F: func(region string) error {
+ ctx := context.Background()
+ apiClientConfigOptions := []config.ConfigurationOption{}
+ apiClient, err := sqlserverflexalphaPkgGen.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ log.Fatalln(err)
+ }
-func TestAccSQLServerFlexMinResource(t *testing.T) {
- resource.Test(t, resource.TestCase{
- ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories,
- CheckDestroy: testAccChecksqlserverflexDestroy,
- Steps: []resource.TestStep{
- // Creation
- {
- Config: testutil.SQLServerFlexProviderConfig() + "\n" + resourceMinConfig,
- ConfigVariables: testConfigVarsMin,
- Check: resource.ComposeAggregateTestCheckFunc(
- // Instance
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutil.ConvertConfigVariable(testConfigVarsMin["project_id"])),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutil.ConvertConfigVariable(testConfigVarsMin["name"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.description", testutil.ConvertConfigVariable(testConfigVarsMin["flavor_description"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "replicas", testutil.ConvertConfigVariable(testConfigVarsMin["replicas"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutil.ConvertConfigVariable(testConfigVarsMin["flavor_cpu"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutil.ConvertConfigVariable(testConfigVarsMin["flavor_ram"])),
- // User
- resource.TestCheckResourceAttrPair(
- "stackit_sqlserverflex_user.user", "project_id",
- "stackit_sqlserverflex_instance.instance", "project_id",
- ),
- resource.TestCheckResourceAttrPair(
- "stackit_sqlserverflex_user.user", "instance_id",
- "stackit_sqlserverflex_instance.instance", "instance_id",
- ),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "user_id"),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "password"),
- ),
- },
- // Update
- {
- Config: testutil.SQLServerFlexProviderConfig() + "\n" + resourceMinConfig,
- ConfigVariables: testConfigVarsMin,
- Check: resource.ComposeAggregateTestCheckFunc(
- // Instance
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutil.ConvertConfigVariable(testConfigVarsMin["project_id"])),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutil.ConvertConfigVariable(testConfigVarsMin["name"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.description", testutil.ConvertConfigVariable(testConfigVarsMin["flavor_description"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutil.ConvertConfigVariable(testConfigVarsMin["flavor_cpu"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutil.ConvertConfigVariable(testConfigVarsMin["flavor_ram"])),
- // User
- resource.TestCheckResourceAttrPair(
- "stackit_sqlserverflex_user.user", "project_id",
- "stackit_sqlserverflex_instance.instance", "project_id",
- ),
- resource.TestCheckResourceAttrPair(
- "stackit_sqlserverflex_user.user", "instance_id",
- "stackit_sqlserverflex_instance.instance", "instance_id",
- ),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "user_id"),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "password"),
- ),
- },
- // data source
- {
- Config: testutil.SQLServerFlexProviderConfig() + "\n" + resourceMinConfig,
- ConfigVariables: testConfigVarsMin,
- Check: resource.ComposeAggregateTestCheckFunc(
- // Instance data
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "project_id", testutil.ConvertConfigVariable(testConfigVarsMin["project_id"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "name", testutil.ConvertConfigVariable(testConfigVarsMin["name"])),
- resource.TestCheckResourceAttrPair(
- "data.stackit_sqlserverflex_instance.instance", "project_id",
- "stackit_sqlserverflex_instance.instance", "project_id",
- ),
- resource.TestCheckResourceAttrPair(
- "data.stackit_sqlserverflex_instance.instance", "instance_id",
- "stackit_sqlserverflex_instance.instance", "instance_id",
- ),
- resource.TestCheckResourceAttrPair(
- "data.stackit_sqlserverflex_user.user", "instance_id",
- "stackit_sqlserverflex_user.user", "instance_id",
- ),
+ instances, err := apiClient.ListInstancesRequest(ctx, testutils.ProjectId, region).
+ Size(100).
+ Execute()
+ if err != nil {
+ log.Fatalln(err)
+ }
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "acl.#", "1"),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.id", testutil.ConvertConfigVariable(testConfigVarsMin["flavor_id"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.description", testutil.ConvertConfigVariable(testConfigVarsMin["flavor_description"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.cpu", testutil.ConvertConfigVariable(testConfigVarsMin["flavor_cpu"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.ram", testutil.ConvertConfigVariable(testConfigVarsMin["flavor_ram"])),
-
- // User data
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "project_id", testutil.ConvertConfigVariable(testConfigVarsMin["project_id"])),
- resource.TestCheckResourceAttrSet("data.stackit_sqlserverflex_user.user", "user_id"),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "username", testutil.ConvertConfigVariable(testConfigVarsMin["username"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "roles.#", "1"),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "roles.0", testutil.ConvertConfigVariable(testConfigVarsMax["role"])),
- ),
- },
- // Import
- {
- ConfigVariables: testConfigVarsMin,
- ResourceName: "stackit_sqlserverflex_instance.instance",
- ImportStateIdFunc: func(s *terraform.State) (string, error) {
- r, ok := s.RootModule().Resources["stackit_sqlserverflex_instance.instance"]
- if !ok {
- return "", fmt.Errorf("couldn't find resource stackit_sqlserverflex_instance.instance")
+ for _, inst := range instances.GetInstances() {
+ if strings.HasPrefix(inst.GetName(), "tf-acc-") {
+ for _, item := range testInstances {
+ if inst.GetName() == item {
+ delErr := apiClient.DeleteInstanceRequestExecute(ctx, testutils.ProjectId, region, inst.GetId())
+ if delErr != nil {
+ // TODO: maybe just warn?
+ log.Fatalln(delErr)
+ }
+ }
}
- instanceId, ok := r.Primary.Attributes["instance_id"]
- if !ok {
- return "", fmt.Errorf("couldn't find attribute instance_id")
- }
-
- return fmt.Sprintf("%s,%s,%s", testutil.ProjectId, testutil.Region, instanceId), nil
- },
- ImportState: true,
- ImportStateVerify: true,
- ImportStateVerifyIgnore: []string{"backup_schedule"},
- ImportStateCheck: func(s []*terraform.InstanceState) error {
- if len(s) != 1 {
- return fmt.Errorf("expected 1 state, got %d", len(s))
- }
- return nil
- },
- },
- {
- ResourceName: "stackit_sqlserverflex_user.user",
- ConfigVariables: testConfigVarsMin,
- ImportStateIdFunc: func(s *terraform.State) (string, error) {
- r, ok := s.RootModule().Resources["stackit_sqlserverflex_user.user"]
- if !ok {
- return "", fmt.Errorf("couldn't find resource stackit_sqlserverflex_user.user")
- }
- instanceId, ok := r.Primary.Attributes["instance_id"]
- if !ok {
- return "", fmt.Errorf("couldn't find attribute instance_id")
- }
- userId, ok := r.Primary.Attributes["user_id"]
- if !ok {
- return "", fmt.Errorf("couldn't find attribute user_id")
- }
-
- return fmt.Sprintf("%s,%s,%s,%s", testutil.ProjectId, testutil.Region, instanceId, userId), nil
- },
- ImportState: true,
- ImportStateVerify: true,
- ImportStateVerifyIgnore: []string{"password"},
- },
- // Update
- {
- Config: testutil.SQLServerFlexProviderConfig() + "\n" + resourceMinConfig,
- ConfigVariables: configVarsMinUpdated(),
- Check: resource.ComposeAggregateTestCheckFunc(
- // Instance data
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutil.ConvertConfigVariable(configVarsMinUpdated()["project_id"])),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutil.ConvertConfigVariable(configVarsMinUpdated()["name"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.description"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutil.ConvertConfigVariable(configVarsMinUpdated()["flavor_cpu"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutil.ConvertConfigVariable(configVarsMinUpdated()["flavor_ram"])),
- ),
- },
- // Deletion is done by the framework implicitly
+ }
+ }
+ return nil
},
})
}
-func TestAccSQLServerFlexMaxResource(t *testing.T) {
- resource.Test(t, resource.TestCase{
- ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories,
- CheckDestroy: testAccChecksqlserverflexDestroy,
- Steps: []resource.TestStep{
- // Creation
- {
- Config: testutil.SQLServerFlexProviderConfig() + "\n" + resourceMaxConfig,
- ConfigVariables: testConfigVarsMax,
- Check: resource.ComposeAggregateTestCheckFunc(
- // Instance
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutil.ConvertConfigVariable(testConfigVarsMax["project_id"])),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutil.ConvertConfigVariable(testConfigVarsMax["name"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.0", testutil.ConvertConfigVariable(testConfigVarsMax["acl1"])),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.description", testutil.ConvertConfigVariable(testConfigVarsMax["flavor_description"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "replicas", testutil.ConvertConfigVariable(testConfigVarsMax["replicas"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutil.ConvertConfigVariable(testConfigVarsMax["flavor_cpu"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutil.ConvertConfigVariable(testConfigVarsMax["flavor_ram"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.class", testutil.ConvertConfigVariable(testConfigVarsMax["storage_class"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.size", testutil.ConvertConfigVariable(testConfigVarsMax["storage_size"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "version", testutil.ConvertConfigVariable(testConfigVarsMax["server_version"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "options.retention_days", testutil.ConvertConfigVariable(testConfigVarsMax["options_retention_days"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "backup_schedule", testutil.ConvertConfigVariable(testConfigVarsMax["backup_schedule"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "region", testutil.Region),
- // User
- resource.TestCheckResourceAttrPair(
- "stackit_sqlserverflex_user.user", "project_id",
- "stackit_sqlserverflex_instance.instance", "project_id",
- ),
- resource.TestCheckResourceAttrPair(
- "stackit_sqlserverflex_user.user", "instance_id",
- "stackit_sqlserverflex_instance.instance", "instance_id",
- ),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "user_id"),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "password"),
- ),
- },
- // Update
- {
- Config: testutil.SQLServerFlexProviderConfig() + "\n" + resourceMaxConfig,
- ConfigVariables: testConfigVarsMax,
- Check: resource.ComposeAggregateTestCheckFunc(
- // Instance
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutil.ConvertConfigVariable(testConfigVarsMax["project_id"])),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutil.ConvertConfigVariable(testConfigVarsMax["name"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.0", testutil.ConvertConfigVariable(testConfigVarsMax["acl1"])),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.description", testutil.ConvertConfigVariable(testConfigVarsMax["flavor_description"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "replicas", testutil.ConvertConfigVariable(testConfigVarsMax["replicas"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutil.ConvertConfigVariable(testConfigVarsMax["flavor_cpu"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutil.ConvertConfigVariable(testConfigVarsMax["flavor_ram"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.class", testutil.ConvertConfigVariable(testConfigVarsMax["storage_class"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.size", testutil.ConvertConfigVariable(testConfigVarsMax["storage_size"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "version", testutil.ConvertConfigVariable(testConfigVarsMax["server_version"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "options.retention_days", testutil.ConvertConfigVariable(testConfigVarsMax["options_retention_days"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "backup_schedule", testutil.ConvertConfigVariable(testConfigVarsMax["backup_schedule"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "region", testutil.Region),
- // User
- resource.TestCheckResourceAttrPair(
- "stackit_sqlserverflex_user.user", "project_id",
- "stackit_sqlserverflex_instance.instance", "project_id",
- ),
- resource.TestCheckResourceAttrPair(
- "stackit_sqlserverflex_user.user", "instance_id",
- "stackit_sqlserverflex_instance.instance", "instance_id",
- ),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "user_id"),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "password"),
- ),
- },
- // data source
- {
- Config: testutil.SQLServerFlexProviderConfig() + "\n" + resourceMaxConfig,
- ConfigVariables: testConfigVarsMax,
- Check: resource.ComposeAggregateTestCheckFunc(
- // Instance data
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "project_id", testutil.ConvertConfigVariable(testConfigVarsMax["project_id"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "name", testutil.ConvertConfigVariable(testConfigVarsMax["name"])),
- resource.TestCheckResourceAttrPair(
- "data.stackit_sqlserverflex_instance.instance", "project_id",
- "stackit_sqlserverflex_instance.instance", "project_id",
- ),
- resource.TestCheckResourceAttrPair(
- "data.stackit_sqlserverflex_instance.instance", "instance_id",
- "stackit_sqlserverflex_instance.instance", "instance_id",
- ),
- resource.TestCheckResourceAttrPair(
- "data.stackit_sqlserverflex_user.user", "instance_id",
- "stackit_sqlserverflex_user.user", "instance_id",
- ),
+func TestInstanceResourceSchema(t *testing.T) {
+ t.Parallel()
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "acl.#", "1"),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "acl.0", testutil.ConvertConfigVariable(testConfigVarsMax["acl1"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.id", testutil.ConvertConfigVariable(testConfigVarsMax["flavor_id"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.description", testutil.ConvertConfigVariable(testConfigVarsMax["flavor_description"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.cpu", testutil.ConvertConfigVariable(testConfigVarsMax["flavor_cpu"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.ram", testutil.ConvertConfigVariable(testConfigVarsMax["flavor_ram"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "replicas", testutil.ConvertConfigVariable(testConfigVarsMax["replicas"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "options.retention_days", testutil.ConvertConfigVariable(testConfigVarsMax["options_retention_days"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "backup_schedule", testutil.ConvertConfigVariable(testConfigVarsMax["backup_schedule"])),
-
- // User data
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "project_id", testutil.ConvertConfigVariable(testConfigVarsMax["project_id"])),
- resource.TestCheckResourceAttrSet("data.stackit_sqlserverflex_user.user", "user_id"),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "username", testutil.ConvertConfigVariable(testConfigVarsMax["username"])),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "roles.#", "1"),
- resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "roles.0", testutil.ConvertConfigVariable(testConfigVarsMax["role"])),
- resource.TestCheckResourceAttrSet("data.stackit_sqlserverflex_user.user", "host"),
- resource.TestCheckResourceAttrSet("data.stackit_sqlserverflex_user.user", "port"),
- ),
- },
- // Import
- {
- ConfigVariables: testConfigVarsMax,
- ResourceName: "stackit_sqlserverflex_instance.instance",
- ImportStateIdFunc: func(s *terraform.State) (string, error) {
- r, ok := s.RootModule().Resources["stackit_sqlserverflex_instance.instance"]
- if !ok {
- return "", fmt.Errorf("couldn't find resource stackit_sqlserverflex_instance.instance")
- }
- instanceId, ok := r.Primary.Attributes["instance_id"]
- if !ok {
- return "", fmt.Errorf("couldn't find attribute instance_id")
- }
-
- return fmt.Sprintf("%s,%s,%s", testutil.ProjectId, testutil.Region, instanceId), nil
- },
- ImportState: true,
- ImportStateVerify: true,
- ImportStateVerifyIgnore: []string{"backup_schedule"},
- ImportStateCheck: func(s []*terraform.InstanceState) error {
- if len(s) != 1 {
- return fmt.Errorf("expected 1 state, got %d", len(s))
- }
- if s[0].Attributes["backup_schedule"] != testutil.ConvertConfigVariable(testConfigVarsMax["backup_schedule"]) {
- return fmt.Errorf("expected backup_schedule %s, got %s", testConfigVarsMax["backup_schedule"], s[0].Attributes["backup_schedule"])
- }
- return nil
- },
- },
- {
- ResourceName: "stackit_sqlserverflex_user.user",
- ConfigVariables: testConfigVarsMax,
- ImportStateIdFunc: func(s *terraform.State) (string, error) {
- r, ok := s.RootModule().Resources["stackit_sqlserverflex_user.user"]
- if !ok {
- return "", fmt.Errorf("couldn't find resource stackit_sqlserverflex_user.user")
- }
- instanceId, ok := r.Primary.Attributes["instance_id"]
- if !ok {
- return "", fmt.Errorf("couldn't find attribute instance_id")
- }
- userId, ok := r.Primary.Attributes["user_id"]
- if !ok {
- return "", fmt.Errorf("couldn't find attribute user_id")
- }
-
- return fmt.Sprintf("%s,%s,%s,%s", testutil.ProjectId, testutil.Region, instanceId, userId), nil
- },
- ImportState: true,
- ImportStateVerify: true,
- ImportStateVerifyIgnore: []string{"password"},
- },
- // Update
- {
- Config: testutil.SQLServerFlexProviderConfig() + "\n" + resourceMaxConfig,
- ConfigVariables: configVarsMaxUpdated(),
- Check: resource.ComposeAggregateTestCheckFunc(
- // Instance data
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutil.ConvertConfigVariable(configVarsMaxUpdated()["project_id"])),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutil.ConvertConfigVariable(configVarsMaxUpdated()["name"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.0", testutil.ConvertConfigVariable(configVarsMaxUpdated()["acl1"])),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"),
- resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.description"),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutil.ConvertConfigVariable(configVarsMaxUpdated()["flavor_cpu"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutil.ConvertConfigVariable(configVarsMaxUpdated()["flavor_ram"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "replicas", testutil.ConvertConfigVariable(configVarsMaxUpdated()["replicas"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.class", testutil.ConvertConfigVariable(configVarsMaxUpdated()["storage_class"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.size", testutil.ConvertConfigVariable(configVarsMaxUpdated()["storage_size"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "version", testutil.ConvertConfigVariable(configVarsMaxUpdated()["server_version"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "options.retention_days", testutil.ConvertConfigVariable(configVarsMaxUpdated()["options_retention_days"])),
- resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "backup_schedule", testutil.ConvertConfigVariable(configVarsMaxUpdated()["backup_schedule"])),
- ),
- },
- // Deletion is done by the framework implicitly
- },
- })
-}
-
-func testAccChecksqlserverflexDestroy(s *terraform.State) error {
ctx := context.Background()
- var client *sqlserverflex.APIClient
- var err error
- if testutil.SQLServerFlexCustomEndpoint == "" {
- client, err = sqlserverflex.NewAPIClient()
- } else {
- client, err = sqlserverflex.NewAPIClient(
- core_config.WithEndpoint(testutil.SQLServerFlexCustomEndpoint),
- )
- }
- if err != nil {
- return fmt.Errorf("creating client: %w", err)
+ schemaRequest := fwresource.SchemaRequest{}
+ schemaResponse := &fwresource.SchemaResponse{}
+
+ // Instantiate the resource.Resource and call its Schema method
+ sqlserverflexalpha.NewInstanceResource().Schema(ctx, schemaRequest, schemaResponse)
+
+ if schemaResponse.Diagnostics.HasError() {
+ t.Fatalf("Schema method diagnostics: %+v", schemaResponse.Diagnostics)
}
- instancesToDestroy := []string{}
- for _, rs := range s.RootModule().Resources {
- if rs.Type != "stackit_sqlserverflex_instance" {
- continue
- }
- // instance terraform ID: = "[project_id],[region],[instance_id]"
- instanceId := strings.Split(rs.Primary.ID, core.Separator)[2]
- instancesToDestroy = append(instancesToDestroy, instanceId)
- }
+ // Validate the schema
+ diagnostics := schemaResponse.Schema.ValidateImplementation(ctx)
- instancesResp, err := client.ListInstances(ctx, testutil.ProjectId, testutil.Region).Execute()
- if err != nil {
- return fmt.Errorf("getting instancesResp: %w", err)
+ if diagnostics.HasError() {
+ t.Fatalf("Schema validation diagnostics: %+v", diagnostics)
}
-
- items := *instancesResp.Items
- for i := range items {
- if items[i].Id == nil {
- continue
- }
- if utils.Contains(instancesToDestroy, *items[i].Id) {
- err := client.DeleteInstanceExecute(ctx, testutil.ProjectId, *items[i].Id, testutil.Region)
- if err != nil {
- return fmt.Errorf("destroying instance %s during CheckDestroy: %w", *items[i].Id, err)
- }
- _, err = wait.DeleteInstanceWaitHandler(ctx, client, testutil.ProjectId, *items[i].Id, testutil.Region).WaitWithContext(ctx)
- if err != nil {
- return fmt.Errorf("destroying instance %s during CheckDestroy: waiting for deletion %w", *items[i].Id, err)
- }
- }
- }
- return nil
+}
+
+func TestMain(m *testing.M) {
+ testutils.Setup()
+ code := m.Run()
+ // shutdown()
+ os.Exit(code)
+}
+
+func testAccPreCheck(t *testing.T) {
+ if _, ok := os.LookupEnv("TF_ACC_PROJECT_ID"); !ok {
+ t.Fatalf("could not find env var TF_ACC_PROJECT_ID")
+ }
+}
+
+type resData struct {
+ ServiceAccountFilePath string
+ ProjectId string
+ Region string
+ Name string
+ TfName string
+ FlavorId string
+ BackupSchedule string
+ UseEncryption bool
+ KekKeyId string
+ KekKeyRingId string
+ KekKeyVersion uint8
+ KekServiceAccount string
+ PerformanceClass string
+ Size uint32
+ AclString string
+ AccessScope string
+ RetentionDays uint32
+ Version string
+ Users []User
+ Databases []Database
+}
+
+type User struct {
+ Name string
+ ProjectId string
+ Roles []string
+}
+
+type Database struct {
+ Name string
+ ProjectId string
+ Owner string
+ Collation string
+ Compatibility string
+}
+
+func resName(res, name string) string {
+ return fmt.Sprintf("%s_%s.%s", providerPrefix, res, name)
+}
+
+func getExample() resData {
+ name := acctest.RandomWithPrefix("tf-acc")
+ return resData{
+ Region: os.Getenv("TF_ACC_REGION"),
+ ServiceAccountFilePath: os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE"),
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Name: name,
+ TfName: name,
+ FlavorId: "4.16-Single",
+ BackupSchedule: "0 0 * * *",
+ UseEncryption: false,
+ RetentionDays: 33,
+ PerformanceClass: "premium-perf2-stackit",
+ Size: 10,
+ AclString: "0.0.0.0/0",
+ AccessScope: "PUBLIC",
+ Version: "2022",
+ }
+}
+
+func TestAccInstance(t *testing.T) {
+ exData := getExample()
+
+ updNameData := exData
+ updNameData.Name = "name-updated"
+
+ updSizeData := exData
+ updSizeData.Size = 25
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() {
+ testAccPreCheck(t)
+ t.Logf(" ... working on instance %s", exData.TfName)
+ testInstances = append(testInstances, exData.TfName)
+ },
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ exData,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", exData.Name),
+ resource.TestCheckResourceAttrSet(resName("instance", exData.TfName), "id"),
+ // TODO: check all fields
+ ),
+ },
+ // Update name and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ updNameData,
+ ),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", updNameData.Name),
+ ),
+ },
+ // Update size and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ updSizeData,
+ ),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr(
+ testutils.ResStr(providerPrefix, "instance", exData.TfName),
+ "storage.size",
+ strconv.Itoa(int(updSizeData.Size)),
+ ),
+ ),
+ },
+ {
+ RefreshState: true,
+ },
+ //// Import test
+ //{
+ // ResourceName: resName("instance", exData.TfName),
+ // ImportState: true,
+ // ImportStateVerify: true,
+ // },
+ },
+ })
+}
+
+func TestAccInstanceNoEncryption(t *testing.T) {
+ data := getExample()
+
+ dbName := "testDb"
+ userName := "testUser"
+ data.Users = []User{
+ {
+ Name: userName,
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Roles: []string{
+ "##STACKIT_DatabaseManager##",
+ "##STACKIT_LoginManager##",
+ "##STACKIT_ProcessManager##",
+ "##STACKIT_SQLAgentManager##",
+ "##STACKIT_SQLAgentUser##",
+ "##STACKIT_ServerManager##",
+ },
+ },
+ }
+ data.Databases = []Database{
+ {
+ Name: dbName,
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Owner: userName,
+ },
+ }
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() {
+ testAccPreCheck(t)
+ t.Logf(" ... working on instance %s", data.TfName)
+ testInstances = append(testInstances, data.TfName)
+ },
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ data,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ // check instance values are set
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "backup_schedule"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "edition"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "flavor_id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "instance_id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "is_deletable"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "name"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "replicas"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "retention_days"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "status"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "version"),
+
+ resource.TestCheckNoResourceAttr(resName("instance", data.TfName), "encryption"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_id"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_version"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_ring_id"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.service_account"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.access_scope"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.acl"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.instance_address"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.router_address"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.class"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.size"),
+
+ // check instance values are correct
+ resource.TestCheckResourceAttr(resName("instance", data.TfName), "name", data.Name),
+
+ // check user values are set
+ resource.TestCheckResourceAttrSet(resName("user", userName), "id"),
+ resource.TestCheckResourceAttrSet(resName("user", userName), "username"),
+ // resource.TestCheckResourceAttrSet(resName("user", userName), "roles"),
+
+ // func(s *terraform.State) error {
+ // return nil
+ // },
+
+ // check user values are correct
+ resource.TestCheckResourceAttr(resName("user", userName), "username", userName),
+ resource.TestCheckResourceAttr(resName("user", userName), "roles.#", strconv.Itoa(len(data.Users[0].Roles))),
+
+ // check database values are set
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "id"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "name"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "owner"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "compatibility"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "collation"),
+
+ // check database values are correct
+ resource.TestCheckResourceAttr(resName("database", dbName), "name", dbName),
+ resource.TestCheckResourceAttr(resName("database", dbName), "owner", userName),
+ ),
+ },
+ },
+ })
+}
+
+func TestAccInstanceEncryption(t *testing.T) {
+ data := getExample()
+
+ dbName := "testDb"
+ userName := "testUser"
+ data.Users = []User{
+ {
+ Name: userName,
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Roles: []string{"##STACKIT_DatabaseManager##", "##STACKIT_LoginManager##"},
+ },
+ }
+ data.Databases = []Database{
+ {
+ Name: dbName,
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Owner: userName,
+ },
+ }
+
+ data.UseEncryption = true
+ data.KekKeyId = "fe039bcf-8d7b-431a-801d-9e81371a6b7b"
+ data.KekKeyRingId = "6a2d95ab-3c4c-4963-a2bb-08d17a320e27"
+ data.KekKeyVersion = 1
+ data.KekServiceAccount = "henselinm-u2v3ex1@sa.stackit.cloud"
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() {
+ testAccPreCheck(t)
+ t.Logf(" ... working on instance %s", data.TfName)
+ testInstances = append(testInstances, data.TfName)
+ },
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ data,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ // check instance values are set
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "backup_schedule"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "edition"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "flavor_id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "instance_id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "is_deletable"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "name"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "replicas"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "retention_days"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "status"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "version"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_id"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_version"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_ring_id"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.service_account"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.access_scope"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.acl"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.instance_address"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.router_address"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.class"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.size"),
+
+ // check instance values are correct
+ resource.TestCheckResourceAttr(resName("instance", data.TfName), "name", data.Name),
+
+ // check user values are set
+ resource.TestCheckResourceAttrSet(resName("user", userName), "id"),
+ resource.TestCheckResourceAttrSet(resName("user", userName), "username"),
+
+ // func(s *terraform.State) error {
+ // return nil
+ // },
+
+ // check user values are correct
+ resource.TestCheckResourceAttr(resName("user", userName), "username", userName),
+ resource.TestCheckResourceAttr(resName("user", userName), "roles.#", "2"),
+
+ // check database values are set
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "id"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "name"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "owner"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "compatibility"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "collation"),
+
+ // check database values are correct
+ resource.TestCheckResourceAttr(resName("database", dbName), "name", dbName),
+ resource.TestCheckResourceAttr(resName("database", dbName), "owner", userName),
+ ),
+ },
+ },
+ })
}
diff --git a/stackit/internal/services/sqlserverflexalpha/testdata/instance_template.gompl b/stackit/internal/services/sqlserverflexalpha/testdata/instance_template.gompl
new file mode 100644
index 00000000..0bf11c9c
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/testdata/instance_template.gompl
@@ -0,0 +1,60 @@
+provider "stackitprivatepreview" {
+ default_region = "{{ .Region }}"
+ service_account_key_path = "{{ .ServiceAccountFilePath }}"
+}
+
+resource "stackitprivatepreview_sqlserverflexalpha_instance" "{{ .TfName }}" {
+ project_id = "{{ .ProjectId }}"
+ name = "{{ .Name }}"
+ backup_schedule = "{{ .BackupSchedule }}"
+ retention_days = {{ .RetentionDays }}
+ flavor_id = "{{ .FlavorId }}"
+ storage = {
+ class = "{{ .PerformanceClass }}"
+ size = {{ .Size }}
+ }
+{{ if .UseEncryption }}
+ encryption = {
+ kek_key_id = "{{ .KekKeyId }}"
+ kek_key_ring_id = "{{ .KekKeyRingId }}"
+ kek_key_version = {{ .KekKeyVersion }}
+ service_account = "{{ .KekServiceAccount }}"
+ }
+{{ end }}
+ network = {
+ acl = ["{{ .AclString }}"]
+ access_scope = "{{ .AccessScope }}"
+ }
+ version = "{{ .Version }}"
+}
+
+{{ if .Users }}
+{{ $tfName := .TfName }}
+{{ range $user := .Users }}
+resource "stackitprivatepreview_sqlserverflexalpha_user" "{{ $user.Name }}" {
+ project_id = "{{ $user.ProjectId }}"
+ instance_id = stackitprivatepreview_sqlserverflexalpha_instance.{{ $tfName }}.instance_id
+ username = "{{ $user.Name }}"
+ roles = [{{ range $i, $v := $user.Roles }}{{if $i}},{{end}}"{{$v}}"{{end}}]
+}
+{{ end }}
+{{ end }}
+
+{{ if .Databases }}
+{{ $tfName := .TfName }}
+{{ range $db := .Databases }}
+resource "stackitprivatepreview_sqlserverflexalpha_database" "{{ $db.Name }}" {
+ depends_on = [stackitprivatepreview_sqlserverflexalpha_user.{{ $db.Owner }}]
+ project_id = "{{ $db.ProjectId }}"
+ instance_id = stackitprivatepreview_sqlserverflexalpha_instance.{{ $tfName }}.instance_id
+ name = "{{ $db.Name }}"
+ owner = "{{ $db.Owner }}"
+{{ if $db.Collation }}
+ collation = "{{ $db.Collation }}"
+{{ end }}
+{{ if $db.Compatibility }}
+ compatibility = "{{ $db.Compatibility }}"
+{{ end }}
+}
+{{ end }}
+{{ end }}
diff --git a/stackit/internal/services/sqlserverflexalpha/testdata/resource-max.tf b/stackit/internal/services/sqlserverflexalpha/testdata/resource-max.tf
deleted file mode 100644
index 1c3cdd15..00000000
--- a/stackit/internal/services/sqlserverflexalpha/testdata/resource-max.tf
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright (c) STACKIT
-
-variable "project_id" {}
-variable "name" {}
-variable "acl1" {}
-variable "flavor_cpu" {}
-variable "flavor_ram" {}
-variable "storage_class" {}
-variable "storage_size" {}
-variable "options_retention_days" {}
-variable "backup_schedule" {}
-variable "username" {}
-variable "role" {}
-variable "server_version" {}
-variable "region" {}
-
-resource "stackit_sqlserverflex_instance" "instance" {
- project_id = var.project_id
- name = var.name
- acl = [var.acl1]
- flavor = {
- cpu = var.flavor_cpu
- ram = var.flavor_ram
- }
- storage = {
- class = var.storage_class
- size = var.storage_size
- }
- version = var.server_version
- options = {
- retention_days = var.options_retention_days
- }
- backup_schedule = var.backup_schedule
- region = var.region
-}
-
-resource "stackit_sqlserverflex_user" "user" {
- project_id = stackit_sqlserverflex_instance.instance.project_id
- instance_id = stackit_sqlserverflex_instance.instance.instance_id
- username = var.username
- roles = [var.role]
-}
-
-data "stackit_sqlserverflex_instance" "instance" {
- project_id = var.project_id
- instance_id = stackit_sqlserverflex_instance.instance.instance_id
-}
-
-data "stackit_sqlserverflex_user" "user" {
- project_id = var.project_id
- instance_id = stackit_sqlserverflex_instance.instance.instance_id
- user_id = stackit_sqlserverflex_user.user.user_id
-}
diff --git a/stackit/internal/services/sqlserverflexalpha/testdata/resource-min.tf b/stackit/internal/services/sqlserverflexalpha/testdata/resource-min.tf
deleted file mode 100644
index f53ef3e6..00000000
--- a/stackit/internal/services/sqlserverflexalpha/testdata/resource-min.tf
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (c) STACKIT
-
-variable "project_id" {}
-variable "name" {}
-variable "flavor_cpu" {}
-variable "flavor_ram" {}
-variable "username" {}
-variable "role" {}
-
-resource "stackit_sqlserverflex_instance" "instance" {
- project_id = var.project_id
- name = var.name
- flavor = {
- cpu = var.flavor_cpu
- ram = var.flavor_ram
- }
-}
-
-resource "stackit_sqlserverflex_user" "user" {
- project_id = stackit_sqlserverflex_instance.instance.project_id
- instance_id = stackit_sqlserverflex_instance.instance.instance_id
- username = var.username
- roles = [var.role]
-}
-
-data "stackit_sqlserverflex_instance" "instance" {
- project_id = var.project_id
- instance_id = stackit_sqlserverflex_instance.instance.instance_id
-}
-
-data "stackit_sqlserverflex_user" "user" {
- project_id = var.project_id
- instance_id = stackit_sqlserverflex_instance.instance.instance_id
- user_id = stackit_sqlserverflex_user.user.user_id
-}
diff --git a/stackit/internal/services/sqlserverflexalpha/user/datasource.go b/stackit/internal/services/sqlserverflexalpha/user/datasource.go
index 71946c6c..e191e5a7 100644
--- a/stackit/internal/services/sqlserverflexalpha/user/datasource.go
+++ b/stackit/internal/services/sqlserverflexalpha/user/datasource.go
@@ -1,62 +1,49 @@
-// Copyright (c) STACKIT
-
package sqlserverflexalpha
import (
"context"
"fmt"
"net/http"
- "strconv"
-
- "github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
- "github.com/hashicorp/terraform-plugin-framework/attr"
- "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- sqlserverflexUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/sqlserverflexalpha/utils"
"github.com/hashicorp/terraform-plugin-framework/datasource"
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
-
- "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ sqlserverflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexalphaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+ sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user/datasources_gen"
)
-// Ensure the implementation satisfies the expected interfaces.
-var (
- _ datasource.DataSource = &userDataSource{}
-)
+var _ datasource.DataSource = (*userDataSource)(nil)
-type DataSourceModel struct {
- Id types.String `tfsdk:"id"` // needed by TF
- UserId types.Int64 `tfsdk:"user_id"`
- InstanceId types.String `tfsdk:"instance_id"`
- ProjectId types.String `tfsdk:"project_id"`
- Username types.String `tfsdk:"username"`
- Roles types.Set `tfsdk:"roles"`
- Host types.String `tfsdk:"host"`
- Port types.Int64 `tfsdk:"port"`
- Region types.String `tfsdk:"region"`
- Status types.String `tfsdk:"status"`
- DefaultDatabase types.String `tfsdk:"default_database"`
-}
-
-// NewUserDataSource is a helper function to simplify the provider implementation.
func NewUserDataSource() datasource.DataSource {
return &userDataSource{}
}
-// userDataSource is the data source implementation.
+type dataSourceModel struct {
+ DefaultDatabase types.String `tfsdk:"default_database"`
+ Host types.String `tfsdk:"host"`
+ Id types.String `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Port types.Int64 `tfsdk:"port"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Roles types.List `tfsdk:"roles"`
+ Status types.String `tfsdk:"status"`
+ UserId types.Int64 `tfsdk:"user_id"`
+ Username types.String `tfsdk:"username"`
+}
+
type userDataSource struct {
- client *sqlserverflexalpha.APIClient
+ client *sqlserverflexalphaPkg.APIClient
providerData core.ProviderData
}
-// Metadata returns the data source type name.
-func (r *userDataSource) Metadata(
+func (d *userDataSource) Metadata(
_ context.Context,
req datasource.MetadataRequest,
resp *datasource.MetadataResponse,
@@ -64,109 +51,32 @@ func (r *userDataSource) Metadata(
resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_user"
}
+func (d *userDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = sqlserverflexalphaGen.UserDataSourceSchema(ctx)
+}
+
// Configure adds the provider configured client to the data source.
-func (r *userDataSource) Configure(
+func (d *userDataSource) Configure(
ctx context.Context,
req datasource.ConfigureRequest,
resp *datasource.ConfigureResponse,
) {
var ok bool
- r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
if !ok {
return
}
- apiClient := sqlserverflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics)
+ apiClient := sqlserverflexUtils.ConfigureClient(ctx, &d.providerData, &resp.Diagnostics)
if resp.Diagnostics.HasError() {
return
}
- r.client = apiClient
- tflog.Info(ctx, "SQLServer Flex user client configured")
+ d.client = apiClient
+ tflog.Info(ctx, "SQL SERVER Flex alpha database client configured")
}
-// Schema defines the schema for the data source.
-func (r *userDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
- descriptions := map[string]string{
- "main": "SQLServer Flex user data source schema. Must have a `region` specified in the provider configuration.",
- "id": "Terraform's internal data source. ID. It is structured as \"`project_id`,`region`,`instance_id`,`user_id`\".",
- "user_id": "User ID.",
- "instance_id": "ID of the SQLServer Flex instance.",
- "project_id": "STACKIT project ID to which the instance is associated.",
- "username": "Username of the SQLServer Flex instance.",
- "roles": "Database access levels for the user.",
- "password": "Password of the user account.",
- "region": "The resource region. If not defined, the provider region is used.",
- "status": "Status of the user.",
- "default_database": "Default database of the user.",
- }
-
- resp.Schema = schema.Schema{
- Description: descriptions["main"],
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Description: descriptions["id"],
- Computed: true,
- },
- "user_id": schema.Int64Attribute{
- Description: descriptions["user_id"],
- Required: true,
- Validators: []validator.Int64{
- int64validator.AtLeast(1),
- },
- },
- "instance_id": schema.StringAttribute{
- Description: descriptions["instance_id"],
- Required: true,
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "project_id": schema.StringAttribute{
- Description: descriptions["project_id"],
- Required: true,
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "username": schema.StringAttribute{
- Description: descriptions["username"],
- Computed: true,
- },
- "roles": schema.SetAttribute{
- Description: descriptions["roles"],
- ElementType: types.StringType,
- Computed: true,
- },
- "host": schema.StringAttribute{
- Computed: true,
- },
- "port": schema.Int64Attribute{
- Computed: true,
- },
- "region": schema.StringAttribute{
- // the region cannot be found automatically, so it has to be passed
- Optional: true,
- Description: descriptions["region"],
- },
- "status": schema.StringAttribute{
- Computed: true,
- },
- "default_database": schema.StringAttribute{
- Computed: true,
- },
- },
- }
-}
-
-// Read refreshes the Terraform state with the latest data.
-func (r *userDataSource) Read(
- ctx context.Context,
- req datasource.ReadRequest,
- resp *datasource.ReadResponse,
-) { // nolint:gocritic // function signature required by Terraform
- var model DataSourceModel
+func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var model dataSourceModel
diags := req.Config.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -178,13 +88,13 @@ func (r *userDataSource) Read(
projectId := model.ProjectId.ValueString()
instanceId := model.InstanceId.ValueString()
userId := model.UserId.ValueInt64()
- region := r.providerData.GetRegionWithOverride(model.Region)
+ region := d.providerData.GetRegionWithOverride(model.Region)
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "instance_id", instanceId)
ctx = tflog.SetField(ctx, "user_id", userId)
ctx = tflog.SetField(ctx, "region", region)
- recordSetResp, err := r.client.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute()
+ recordSetResp, err := d.client.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute()
if err != nil {
utils.LogError(
ctx,
@@ -225,50 +135,5 @@ func (r *userDataSource) Read(
if resp.Diagnostics.HasError() {
return
}
- tflog.Info(ctx, "SQLServer Flex instance read")
-}
-
-func mapDataSourceFields(userResp *sqlserverflexalpha.GetUserResponse, model *DataSourceModel, region string) error {
- if userResp == nil {
- return fmt.Errorf("response is nil")
- }
- if model == nil {
- return fmt.Errorf("model input is nil")
- }
- user := userResp
-
- var userId int64
- if model.UserId.ValueInt64() != 0 {
- userId = model.UserId.ValueInt64()
- } else if user.Id != nil {
- userId = *user.Id
- } else {
- return fmt.Errorf("user id not present")
- }
- model.Id = utils.BuildInternalTerraformId(
- model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), strconv.FormatInt(userId, 10),
- )
- model.UserId = types.Int64Value(userId)
- model.Username = types.StringPointerValue(user.Username)
-
- if user.Roles == nil {
- model.Roles = types.SetNull(types.StringType)
- } else {
- var roles []attr.Value
- for _, role := range *user.Roles {
- roles = append(roles, types.StringValue(string(role)))
- }
- rolesSet, diags := types.SetValue(types.StringType, roles)
- if diags.HasError() {
- return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
- }
- model.Roles = rolesSet
- }
- model.Host = types.StringPointerValue(user.Host)
- model.Port = types.Int64PointerValue(user.Port)
- model.Region = types.StringValue(region)
- model.Status = types.StringPointerValue(user.Status)
- model.DefaultDatabase = types.StringPointerValue(user.DefaultDatabase)
-
- return nil
+ tflog.Info(ctx, "SQLServer Flex beta instance read")
}
diff --git a/stackit/internal/services/sqlserverflexalpha/user/datasource_test.go b/stackit/internal/services/sqlserverflexalpha/user/datasource_test.go
deleted file mode 100644
index 5f99a8e5..00000000
--- a/stackit/internal/services/sqlserverflexalpha/user/datasource_test.go
+++ /dev/null
@@ -1,149 +0,0 @@
-// Copyright (c) STACKIT
-
-package sqlserverflexalpha
-
-import (
- "testing"
-
- "github.com/google/go-cmp/cmp"
- "github.com/hashicorp/terraform-plugin-framework/attr"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/stackit-sdk-go/core/utils"
- "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
-)
-
-func TestMapDataSourceFields(t *testing.T) {
- const testRegion = "region"
- tests := []struct {
- description string
- input *sqlserverflexalpha.GetUserResponse
- region string
- expected DataSourceModel
- isValid bool
- }{
- {
- "default_values",
- &sqlserverflexalpha.GetUserResponse{},
- testRegion,
- DataSourceModel{
- Id: types.StringValue("pid,region,iid,1"),
- UserId: types.Int64Value(1),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringNull(),
- Roles: types.SetNull(types.StringType),
- Host: types.StringNull(),
- Port: types.Int64Null(),
- Region: types.StringValue(testRegion),
- Status: types.StringNull(),
- DefaultDatabase: types.StringNull(),
- },
- true,
- },
- {
- "simple_values",
- &sqlserverflexalpha.GetUserResponse{
-
- Roles: &[]sqlserverflexalpha.UserRole{
- "role_1",
- "role_2",
- "",
- },
- Username: utils.Ptr("username"),
- Host: utils.Ptr("host"),
- Port: utils.Ptr(int64(1234)),
- Status: utils.Ptr("active"),
- DefaultDatabase: utils.Ptr("default_db"),
- },
- testRegion,
- DataSourceModel{
- Id: types.StringValue("pid,region,iid,1"),
- UserId: types.Int64Value(1),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringValue("username"),
- Roles: types.SetValueMust(
- types.StringType, []attr.Value{
- types.StringValue("role_1"),
- types.StringValue("role_2"),
- types.StringValue(""),
- },
- ),
- Host: types.StringValue("host"),
- Port: types.Int64Value(1234),
- Region: types.StringValue(testRegion),
- Status: types.StringValue("active"),
- DefaultDatabase: types.StringValue("default_db"),
- },
- true,
- },
- {
- "null_fields_and_int_conversions",
- &sqlserverflexalpha.GetUserResponse{
- Id: utils.Ptr(int64(1)),
- Roles: &[]sqlserverflexalpha.UserRole{},
- Username: nil,
- Host: nil,
- Port: utils.Ptr(int64(2123456789)),
- },
- testRegion,
- DataSourceModel{
- Id: types.StringValue("pid,region,iid,1"),
- UserId: types.Int64Value(1),
- InstanceId: types.StringValue("iid"),
- ProjectId: types.StringValue("pid"),
- Username: types.StringNull(),
- Roles: types.SetValueMust(types.StringType, []attr.Value{}),
- Host: types.StringNull(),
- Port: types.Int64Value(2123456789),
- Region: types.StringValue(testRegion),
- },
- true,
- },
- {
- "nil_response",
- nil,
- testRegion,
- DataSourceModel{},
- false,
- },
- {
- "nil_response_2",
- &sqlserverflexalpha.GetUserResponse{},
- testRegion,
- DataSourceModel{},
- false,
- },
- {
- "no_resource_id",
- &sqlserverflexalpha.GetUserResponse{},
- testRegion,
- DataSourceModel{},
- false,
- },
- }
- for _, tt := range tests {
- t.Run(
- tt.description, func(t *testing.T) {
- state := &DataSourceModel{
- ProjectId: tt.expected.ProjectId,
- InstanceId: tt.expected.InstanceId,
- UserId: tt.expected.UserId,
- }
- err := mapDataSourceFields(tt.input, state, tt.region)
- if !tt.isValid && err == nil {
- t.Fatalf("Should have failed")
- }
- if tt.isValid && err != nil {
- t.Fatalf("Should not have failed: %v", err)
- }
- if tt.isValid {
- diff := cmp.Diff(state, &tt.expected)
- if diff != "" {
- t.Fatalf("Data does not match: %s", diff)
- }
- }
- },
- )
- }
-}
diff --git a/stackit/internal/services/sqlserverflexalpha/user/datasources_gen/user_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/user/datasources_gen/user_data_source_gen.go
new file mode 100644
index 00000000..329469ea
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/user/datasources_gen/user_data_source_gen.go
@@ -0,0 +1,1118 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func UserDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the users to be returned on each page.",
+ MarkdownDescription: "Sorting of the users to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "id.asc",
+ "id.desc",
+ "index.desc",
+ "index.asc",
+ "name.desc",
+ "name.asc",
+ "status.desc",
+ "status.asc",
+ ),
+ },
+ },
+ "users": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "tf_original_api_id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The ID of the user.",
+ MarkdownDescription: "The ID of the user.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ Description: "The current status of the user.",
+ MarkdownDescription: "The current status of the user.",
+ },
+ "username": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the user.",
+ MarkdownDescription: "The name of the user.",
+ },
+ },
+ CustomType: UsersType{
+ ObjectType: types.ObjectType{
+ AttrTypes: UsersValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of all users inside an instance",
+ MarkdownDescription: "List of all users inside an instance",
+ },
+ },
+ }
+}
+
+type UserModel struct {
+ InstanceId types.String `tfsdk:"instance_id"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+ Users types.List `tfsdk:"users"`
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
+
+var _ basetypes.ObjectTypable = UsersType{}
+
+type UsersType struct {
+ basetypes.ObjectType
+}
+
+func (t UsersType) Equal(o attr.Type) bool {
+ other, ok := o.(UsersType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t UsersType) String() string {
+ return "UsersType"
+}
+
+func (t UsersType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return nil, diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ usernameAttribute, ok := attributes["username"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `username is missing from object`)
+
+ return nil, diags
+ }
+
+ usernameVal, ok := usernameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`username expected to be basetypes.StringValue, was: %T`, usernameAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return UsersValue{
+ Id: idVal,
+ Status: statusVal,
+ Username: usernameVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewUsersValueNull() UsersValue {
+ return UsersValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewUsersValueUnknown() UsersValue {
+ return UsersValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewUsersValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (UsersValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing UsersValue Attribute Value",
+ "While creating a UsersValue value, a missing attribute value was detected. "+
+ "A UsersValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("UsersValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid UsersValue Attribute Type",
+ "While creating a UsersValue value, an invalid attribute value was detected. "+
+ "A UsersValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("UsersValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("UsersValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra UsersValue Attribute Value",
+ "While creating a UsersValue value, an extra attribute value was detected. "+
+ "A UsersValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra UsersValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewUsersValueUnknown(), diags
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewUsersValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return NewUsersValueUnknown(), diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ usernameAttribute, ok := attributes["username"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `username is missing from object`)
+
+ return NewUsersValueUnknown(), diags
+ }
+
+ usernameVal, ok := usernameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`username expected to be basetypes.StringValue, was: %T`, usernameAttribute))
+ }
+
+ if diags.HasError() {
+ return NewUsersValueUnknown(), diags
+ }
+
+ return UsersValue{
+ Id: idVal,
+ Status: statusVal,
+ Username: usernameVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewUsersValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) UsersValue {
+ object, diags := NewUsersValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewUsersValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t UsersType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewUsersValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewUsersValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewUsersValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewUsersValueMust(UsersValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t UsersType) ValueType(ctx context.Context) attr.Value {
+ return UsersValue{}
+}
+
+var _ basetypes.ObjectValuable = UsersValue{}
+
+type UsersValue struct {
+ Id basetypes.Int64Value `tfsdk:"id"`
+ Status basetypes.StringValue `tfsdk:"status"`
+ Username basetypes.StringValue `tfsdk:"username"`
+ state attr.ValueState
+}
+
+func (v UsersValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 3)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["id"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["status"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["username"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 3)
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.Status.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["status"] = val
+
+ val, err = v.Username.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["username"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v UsersValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v UsersValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v UsersValue) String() string {
+ return "UsersValue"
+}
+
+func (v UsersValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "id": basetypes.Int64Type{},
+ "status": basetypes.StringType{},
+ "username": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "id": v.Id,
+ "status": v.Status,
+ "username": v.Username,
+ })
+
+ return objVal, diags
+}
+
+func (v UsersValue) Equal(o attr.Value) bool {
+ other, ok := o.(UsersValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.Status.Equal(other.Status) {
+ return false
+ }
+
+ if !v.Username.Equal(other.Username) {
+ return false
+ }
+
+ return true
+}
+
+func (v UsersValue) Type(ctx context.Context) attr.Type {
+ return UsersType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v UsersValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "id": basetypes.Int64Type{},
+ "status": basetypes.StringType{},
+ "username": basetypes.StringType{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/user/mapper.go b/stackit/internal/services/sqlserverflexalpha/user/mapper.go
new file mode 100644
index 00000000..8e522d59
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/user/mapper.go
@@ -0,0 +1,193 @@
+package sqlserverflexalpha
+
+import (
+ "fmt"
+ "slices"
+ "strconv"
+
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+// mapDataSourceFields maps the API response to a dataSourceModel.
+func mapDataSourceFields(userResp *sqlserverflexalpha.GetUserResponse, model *dataSourceModel, region string) error {
+ if userResp == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if model == nil {
+ return fmt.Errorf("model input is nil")
+ }
+ user := userResp
+
+ // Handle user ID
+ var userId int64
+ if model.UserId.ValueInt64() != 0 {
+ userId = model.UserId.ValueInt64()
+ } else if user.Id != nil {
+ userId = *user.Id
+ } else {
+ return fmt.Errorf("user id not present")
+ }
+
+ // Set main attributes
+ model.Id = utils.BuildInternalTerraformId(
+ model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), strconv.FormatInt(userId, 10),
+ )
+ model.UserId = types.Int64Value(userId)
+ model.Username = types.StringPointerValue(user.Username)
+
+ // Map roles
+ if user.Roles == nil {
+ model.Roles = types.List(types.SetNull(types.StringType))
+ } else {
+ resRoles := *user.Roles
+ slices.Sort(resRoles)
+
+ var roles []attr.Value
+ for _, role := range resRoles {
+ roles = append(roles, types.StringValue(string(role)))
+ }
+ rolesSet, diags := types.SetValue(types.StringType, roles)
+ if diags.HasError() {
+ return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
+ }
+ model.Roles = types.List(rolesSet)
+ }
+
+ // Set remaining attributes
+ model.Host = types.StringPointerValue(user.Host)
+ model.Port = types.Int64PointerValue(user.Port)
+ model.Region = types.StringValue(region)
+ model.Status = types.StringPointerValue(user.Status)
+ model.DefaultDatabase = types.StringPointerValue(user.DefaultDatabase)
+
+ return nil
+}
+
+// mapFields maps the API response to a resourceModel.
+func mapFields(userResp *sqlserverflexalpha.GetUserResponse, model *resourceModel, region string) error {
+ if userResp == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if model == nil {
+ return fmt.Errorf("model input is nil")
+ }
+ user := userResp
+
+ // Handle user ID
+ var userId int64
+ if model.UserId.ValueInt64() != 0 {
+ userId = model.UserId.ValueInt64()
+ } else if user.Id != nil {
+ userId = *user.Id
+ } else {
+ return fmt.Errorf("user id not present")
+ }
+
+ // Set main attributes
+ model.Id = types.Int64Value(userId)
+ model.UserId = types.Int64Value(userId)
+ model.Username = types.StringPointerValue(user.Username)
+
+ // Map roles
+ if user.Roles != nil {
+ resRoles := *user.Roles
+ slices.Sort(resRoles)
+
+ var roles []attr.Value
+ for _, role := range resRoles {
+ roles = append(roles, types.StringValue(string(role)))
+ }
+ rolesSet, diags := types.SetValue(types.StringType, roles)
+ if diags.HasError() {
+ return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
+ }
+ model.Roles = types.List(rolesSet)
+ }
+
+ // Ensure roles is not null
+ if model.Roles.IsNull() || model.Roles.IsUnknown() {
+ model.Roles = types.List(types.SetNull(types.StringType))
+ }
+
+ // Set connection details
+ model.Host = types.StringPointerValue(user.Host)
+ model.Port = types.Int64PointerValue(user.Port)
+ model.Region = types.StringValue(region)
+ return nil
+}
+
+// mapFieldsCreate maps the API response from creating a user to a resourceModel.
+func mapFieldsCreate(userResp *sqlserverflexalpha.CreateUserResponse, model *resourceModel, region string) error {
+ if userResp == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if model == nil {
+ return fmt.Errorf("model input is nil")
+ }
+ user := userResp
+
+ if user.Id == nil {
+ return fmt.Errorf("user id not present")
+ }
+ userId := *user.Id
+ model.Id = types.Int64Value(userId)
+ model.UserId = types.Int64Value(userId)
+ model.Username = types.StringPointerValue(user.Username)
+
+ if user.Password == nil {
+ return fmt.Errorf("user password not present")
+ }
+ model.Password = types.StringValue(*user.Password)
+
+ if user.Roles != nil {
+ resRoles := *user.Roles
+ slices.Sort(resRoles)
+
+ var roles []attr.Value
+ for _, role := range resRoles {
+ roles = append(roles, types.StringValue(string(role)))
+ }
+ rolesSet, diags := types.SetValue(types.StringType, roles)
+ if diags.HasError() {
+ return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
+ }
+ model.Roles = types.List(rolesSet)
+ }
+
+ if model.Roles.IsNull() || model.Roles.IsUnknown() {
+ model.Roles = types.List(types.SetNull(types.StringType))
+ }
+
+ model.Password = types.StringPointerValue(user.Password)
+ model.Uri = types.StringPointerValue(user.Uri)
+
+ model.Host = types.StringPointerValue(user.Host)
+ model.Port = types.Int64PointerValue(user.Port)
+ model.Region = types.StringValue(region)
+ model.Status = types.StringPointerValue(user.Status)
+ model.DefaultDatabase = types.StringPointerValue(user.DefaultDatabase)
+
+ return nil
+}
+
+// toCreatePayload converts a resourceModel to an API CreateUserRequestPayload.
+func toCreatePayload(
+ model *resourceModel,
+ roles []string,
+) (*sqlserverflexalpha.CreateUserRequestPayload, error) {
+ if model == nil {
+ return nil, fmt.Errorf("nil model")
+ }
+
+ return &sqlserverflexalpha.CreateUserRequestPayload{
+ Username: conversion.StringValueToPointer(model.Username),
+ DefaultDatabase: conversion.StringValueToPointer(model.DefaultDatabase),
+ Roles: &roles,
+ }, nil
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/user/resource_test.go b/stackit/internal/services/sqlserverflexalpha/user/mapper_test.go
similarity index 55%
rename from stackit/internal/services/sqlserverflexalpha/user/resource_test.go
rename to stackit/internal/services/sqlserverflexalpha/user/mapper_test.go
index 8277203a..4dbe7d03 100644
--- a/stackit/internal/services/sqlserverflexalpha/user/resource_test.go
+++ b/stackit/internal/services/sqlserverflexalpha/user/mapper_test.go
@@ -1,5 +1,3 @@
-// Copyright (c) STACKIT
-
package sqlserverflexalpha
import (
@@ -9,16 +7,160 @@ import (
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/stackitcloud/stackit-sdk-go/core/utils"
- "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
)
+func TestMapDataSourceFields(t *testing.T) {
+ const testRegion = "region"
+ tests := []struct {
+ description string
+ input *sqlserverflexalpha.GetUserResponse
+ region string
+ expected dataSourceModel
+ isValid bool
+ }{
+ {
+ "default_values",
+ &sqlserverflexalpha.GetUserResponse{},
+ testRegion,
+ dataSourceModel{
+ Id: types.StringValue("pid,region,iid,1"),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringNull(),
+ Roles: types.List(types.SetNull(types.StringType)),
+ Host: types.StringNull(),
+ Port: types.Int64Null(),
+ Region: types.StringValue(testRegion),
+ Status: types.StringNull(),
+ DefaultDatabase: types.StringNull(),
+ },
+ true,
+ },
+ {
+ "simple_values",
+ &sqlserverflexalpha.GetUserResponse{
+ Roles: &[]string{
+ "##STACKIT_SQLAgentUser##",
+ "##STACKIT_DatabaseManager##",
+ "##STACKIT_LoginManager##",
+ "##STACKIT_SQLAgentManager##",
+ "##STACKIT_ProcessManager##",
+ "##STACKIT_ServerManager##",
+ },
+ Username: utils.Ptr("username"),
+ Host: utils.Ptr("host"),
+ Port: utils.Ptr(int64(1234)),
+ Status: utils.Ptr("active"),
+ DefaultDatabase: utils.Ptr("default_db"),
+ },
+ testRegion,
+ dataSourceModel{
+ Id: types.StringValue("pid,region,iid,1"),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringValue("username"),
+ Roles: types.List(
+ types.SetValueMust(
+ types.StringType, []attr.Value{
+ types.StringValue("##STACKIT_DatabaseManager##"),
+ types.StringValue("##STACKIT_LoginManager##"),
+ types.StringValue("##STACKIT_ProcessManager##"),
+ types.StringValue("##STACKIT_SQLAgentManager##"),
+ types.StringValue("##STACKIT_SQLAgentUser##"),
+ types.StringValue("##STACKIT_ServerManager##"),
+ },
+ ),
+ ),
+ Host: types.StringValue("host"),
+ Port: types.Int64Value(1234),
+ Region: types.StringValue(testRegion),
+ Status: types.StringValue("active"),
+ DefaultDatabase: types.StringValue("default_db"),
+ },
+ true,
+ },
+ {
+ "null_fields_and_int_conversions",
+ &sqlserverflexalpha.GetUserResponse{
+ Id: utils.Ptr(int64(1)),
+ Roles: &[]string{},
+ Username: nil,
+ Host: nil,
+ Port: utils.Ptr(int64(2123456789)),
+ },
+ testRegion,
+ dataSourceModel{
+ Id: types.StringValue("pid,region,iid,1"),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringNull(),
+ Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
+ Host: types.StringNull(),
+ Port: types.Int64Value(2123456789),
+ Region: types.StringValue(testRegion),
+ },
+ true,
+ },
+ {
+ "nil_response",
+ nil,
+ testRegion,
+ dataSourceModel{},
+ false,
+ },
+ {
+ "nil_response_2",
+ &sqlserverflexalpha.GetUserResponse{},
+ testRegion,
+ dataSourceModel{},
+ false,
+ },
+ {
+ "no_resource_id",
+ &sqlserverflexalpha.GetUserResponse{},
+ testRegion,
+ dataSourceModel{},
+ false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ state := &dataSourceModel{
+ ProjectId: tt.expected.ProjectId,
+ InstanceId: tt.expected.InstanceId,
+ UserId: tt.expected.UserId,
+ }
+ err := mapDataSourceFields(tt.input, state, tt.region)
+ if !tt.isValid && err == nil {
+ t.Fatalf("Should have failed")
+ }
+ if tt.isValid && err != nil {
+ t.Fatalf("Should not have failed: %v", err)
+ }
+ if tt.isValid {
+ diff := cmp.Diff(&tt.expected, state)
+ if diff != "" {
+ t.Fatalf("Data does not match: %s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
func TestMapFieldsCreate(t *testing.T) {
const testRegion = "region"
tests := []struct {
description string
input *sqlserverflexalpha.CreateUserResponse
region string
- expected Model
+ expected resourceModel
isValid bool
}{
{
@@ -28,13 +170,13 @@ func TestMapFieldsCreate(t *testing.T) {
Password: utils.Ptr(""),
},
testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,1"),
+ resourceModel{
+ Id: types.Int64Value(1),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringNull(),
- Roles: types.SetNull(types.StringType),
+ Roles: types.List(types.SetNull(types.StringType)),
Password: types.StringValue(""),
Host: types.StringNull(),
Port: types.Int64Null(),
@@ -46,9 +188,9 @@ func TestMapFieldsCreate(t *testing.T) {
"simple_values",
&sqlserverflexalpha.CreateUserResponse{
Id: utils.Ptr(int64(2)),
- Roles: &[]sqlserverflexalpha.UserRole{
- "role_1",
+ Roles: &[]string{
"role_2",
+ "role_1",
"",
},
Username: utils.Ptr("username"),
@@ -59,18 +201,20 @@ func TestMapFieldsCreate(t *testing.T) {
DefaultDatabase: utils.Ptr("default_db"),
},
testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,2"),
+ resourceModel{
+ Id: types.Int64Value(2),
UserId: types.Int64Value(2),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringValue("username"),
- Roles: types.SetValueMust(
- types.StringType, []attr.Value{
- types.StringValue("role_1"),
- types.StringValue("role_2"),
- types.StringValue(""),
- },
+ Roles: types.List(
+ types.SetValueMust(
+ types.StringType, []attr.Value{
+ types.StringValue(""),
+ types.StringValue("role_1"),
+ types.StringValue("role_2"),
+ },
+ ),
),
Password: types.StringValue("password"),
Host: types.StringValue("host"),
@@ -85,20 +229,20 @@ func TestMapFieldsCreate(t *testing.T) {
"null_fields_and_int_conversions",
&sqlserverflexalpha.CreateUserResponse{
Id: utils.Ptr(int64(3)),
- Roles: &[]sqlserverflexalpha.UserRole{},
+ Roles: &[]string{},
Username: nil,
Password: utils.Ptr(""),
Host: nil,
Port: utils.Ptr(int64(2123456789)),
},
testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,3"),
+ resourceModel{
+ Id: types.Int64Value(3),
UserId: types.Int64Value(3),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringNull(),
- Roles: types.SetValueMust(types.StringType, []attr.Value{}),
+ Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
Password: types.StringValue(""),
Host: types.StringNull(),
Port: types.Int64Value(2123456789),
@@ -112,21 +256,21 @@ func TestMapFieldsCreate(t *testing.T) {
"nil_response",
nil,
testRegion,
- Model{},
+ resourceModel{},
false,
},
{
"nil_response_2",
&sqlserverflexalpha.CreateUserResponse{},
testRegion,
- Model{},
+ resourceModel{},
false,
},
{
"no_resource_id",
&sqlserverflexalpha.CreateUserResponse{},
testRegion,
- Model{},
+ resourceModel{},
false,
},
{
@@ -135,14 +279,14 @@ func TestMapFieldsCreate(t *testing.T) {
Id: utils.Ptr(int64(1)),
},
testRegion,
- Model{},
+ resourceModel{},
false,
},
}
for _, tt := range tests {
t.Run(
tt.description, func(t *testing.T) {
- state := &Model{
+ state := &resourceModel{
ProjectId: tt.expected.ProjectId,
InstanceId: tt.expected.InstanceId,
}
@@ -154,7 +298,7 @@ func TestMapFieldsCreate(t *testing.T) {
t.Fatalf("Should not have failed: %v", err)
}
if tt.isValid {
- diff := cmp.Diff(state, &tt.expected)
+ diff := cmp.Diff(&tt.expected, state)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
}
@@ -170,20 +314,20 @@ func TestMapFields(t *testing.T) {
description string
input *sqlserverflexalpha.GetUserResponse
region string
- expected Model
+ expected resourceModel
isValid bool
}{
{
"default_values",
&sqlserverflexalpha.GetUserResponse{},
testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,1"),
+ resourceModel{
+ Id: types.Int64Value(1),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringNull(),
- Roles: types.SetNull(types.StringType),
+ Roles: types.List(types.SetNull(types.StringType)),
Host: types.StringNull(),
Port: types.Int64Null(),
Region: types.StringValue(testRegion),
@@ -193,9 +337,9 @@ func TestMapFields(t *testing.T) {
{
"simple_values",
&sqlserverflexalpha.GetUserResponse{
- Roles: &[]sqlserverflexalpha.UserRole{
- "role_1",
+ Roles: &[]string{
"role_2",
+ "role_1",
"",
},
Username: utils.Ptr("username"),
@@ -203,18 +347,20 @@ func TestMapFields(t *testing.T) {
Port: utils.Ptr(int64(1234)),
},
testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,2"),
+ resourceModel{
+ Id: types.Int64Value(2),
UserId: types.Int64Value(2),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringValue("username"),
- Roles: types.SetValueMust(
- types.StringType, []attr.Value{
- types.StringValue("role_1"),
- types.StringValue("role_2"),
- types.StringValue(""),
- },
+ Roles: types.List(
+ types.SetValueMust(
+ types.StringType, []attr.Value{
+ types.StringValue(""),
+ types.StringValue("role_1"),
+ types.StringValue("role_2"),
+ },
+ ),
),
Host: types.StringValue("host"),
Port: types.Int64Value(1234),
@@ -226,19 +372,19 @@ func TestMapFields(t *testing.T) {
"null_fields_and_int_conversions",
&sqlserverflexalpha.GetUserResponse{
Id: utils.Ptr(int64(1)),
- Roles: &[]sqlserverflexalpha.UserRole{},
+ Roles: &[]string{},
Username: nil,
Host: nil,
Port: utils.Ptr(int64(2123456789)),
},
testRegion,
- Model{
- Id: types.StringValue("pid,region,iid,1"),
+ resourceModel{
+ Id: types.Int64Value(1),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringNull(),
- Roles: types.SetValueMust(types.StringType, []attr.Value{}),
+ Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
Host: types.StringNull(),
Port: types.Int64Value(2123456789),
Region: types.StringValue(testRegion),
@@ -249,28 +395,28 @@ func TestMapFields(t *testing.T) {
"nil_response",
nil,
testRegion,
- Model{},
+ resourceModel{},
false,
},
{
"nil_response_2",
&sqlserverflexalpha.GetUserResponse{},
testRegion,
- Model{},
+ resourceModel{},
false,
},
{
"no_resource_id",
&sqlserverflexalpha.GetUserResponse{},
testRegion,
- Model{},
+ resourceModel{},
false,
},
}
for _, tt := range tests {
t.Run(
tt.description, func(t *testing.T) {
- state := &Model{
+ state := &resourceModel{
ProjectId: tt.expected.ProjectId,
InstanceId: tt.expected.InstanceId,
UserId: tt.expected.UserId,
@@ -283,7 +429,7 @@ func TestMapFields(t *testing.T) {
t.Fatalf("Should not have failed: %v", err)
}
if tt.isValid {
- diff := cmp.Diff(state, &tt.expected)
+ diff := cmp.Diff(&tt.expected, state)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
}
@@ -296,32 +442,32 @@ func TestMapFields(t *testing.T) {
func TestToCreatePayload(t *testing.T) {
tests := []struct {
description string
- input *Model
- inputRoles []sqlserverflexalpha.UserRole
+ input *resourceModel
+ inputRoles []string
expected *sqlserverflexalpha.CreateUserRequestPayload
isValid bool
}{
{
"default_values",
- &Model{},
- []sqlserverflexalpha.UserRole{},
+ &resourceModel{},
+ []string{},
&sqlserverflexalpha.CreateUserRequestPayload{
- Roles: &[]sqlserverflexalpha.UserRole{},
+ Roles: &[]string{},
Username: nil,
},
true,
},
{
"default_values",
- &Model{
+ &resourceModel{
Username: types.StringValue("username"),
},
- []sqlserverflexalpha.UserRole{
+ []string{
"role_1",
"role_2",
},
&sqlserverflexalpha.CreateUserRequestPayload{
- Roles: &[]sqlserverflexalpha.UserRole{
+ Roles: &[]string{
"role_1",
"role_2",
},
@@ -331,14 +477,14 @@ func TestToCreatePayload(t *testing.T) {
},
{
"null_fields_and_int_conversions",
- &Model{
+ &resourceModel{
Username: types.StringNull(),
},
- []sqlserverflexalpha.UserRole{
+ []string{
"",
},
&sqlserverflexalpha.CreateUserRequestPayload{
- Roles: &[]sqlserverflexalpha.UserRole{
+ Roles: &[]string{
"",
},
Username: nil,
@@ -348,18 +494,18 @@ func TestToCreatePayload(t *testing.T) {
{
"nil_model",
nil,
- []sqlserverflexalpha.UserRole{},
+ []string{},
nil,
false,
},
{
"nil_roles",
- &Model{
+ &resourceModel{
Username: types.StringValue("username"),
},
- []sqlserverflexalpha.UserRole{},
+ []string{},
&sqlserverflexalpha.CreateUserRequestPayload{
- Roles: &[]sqlserverflexalpha.UserRole{},
+ Roles: &[]string{},
Username: utils.Ptr("username"),
},
true,
@@ -376,7 +522,7 @@ func TestToCreatePayload(t *testing.T) {
t.Fatalf("Should not have failed: %v", err)
}
if tt.isValid {
- diff := cmp.Diff(output, tt.expected)
+ diff := cmp.Diff(tt.expected, output)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
}
diff --git a/stackit/internal/services/sqlserverflexalpha/user/planModifiers.yaml b/stackit/internal/services/sqlserverflexalpha/user/planModifiers.yaml
new file mode 100644
index 00000000..8ff346ab
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/user/planModifiers.yaml
@@ -0,0 +1,49 @@
+fields:
+ - name: 'id'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'instance_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'project_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'region'
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'user_id'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'username'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'roles'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'password'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'uri'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'status'
+ modifiers:
+ - 'UseStateForUnknown'
diff --git a/stackit/internal/services/sqlserverflexalpha/user/resource.go b/stackit/internal/services/sqlserverflexalpha/user/resource.go
index f52d990b..ee322fab 100644
--- a/stackit/internal/services/sqlserverflexalpha/user/resource.go
+++ b/stackit/internal/services/sqlserverflexalpha/user/resource.go
@@ -1,71 +1,63 @@
-// Copyright (c) STACKIT
-
package sqlserverflexalpha
import (
"context"
+ _ "embed"
"errors"
"fmt"
"net/http"
+ "slices"
"strconv"
"strings"
+ "time"
- "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
- sqlserverflexalphaUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/sqlserverflexalpha/utils"
-
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-log/tflog"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
-
- "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/planmodifier"
- "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier"
- "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
+ "github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ sqlserverflexalphaUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils"
+ sqlserverflexalphaWait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexalpha"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexalphaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user/resources_gen"
)
-// Ensure the implementation satisfies the expected interfaces.
var (
- _ resource.Resource = &userResource{}
- _ resource.ResourceWithConfigure = &userResource{}
- _ resource.ResourceWithImportState = &userResource{}
- _ resource.ResourceWithModifyPlan = &userResource{}
+ _ resource.Resource = &userResource{}
+ _ resource.ResourceWithConfigure = &userResource{}
+ _ resource.ResourceWithImportState = &userResource{}
+ _ resource.ResourceWithModifyPlan = &userResource{}
+ _ resource.ResourceWithIdentity = &userResource{}
+ _ resource.ResourceWithValidateConfig = &userResource{}
)
-type Model struct {
- Id types.String `tfsdk:"id"` // needed by TF
- UserId types.Int64 `tfsdk:"user_id"`
- InstanceId types.String `tfsdk:"instance_id"`
- ProjectId types.String `tfsdk:"project_id"`
- Username types.String `tfsdk:"username"`
- Roles types.Set `tfsdk:"roles"`
- Password types.String `tfsdk:"password"`
- Host types.String `tfsdk:"host"`
- Port types.Int64 `tfsdk:"port"`
- Region types.String `tfsdk:"region"`
- Status types.String `tfsdk:"status"`
- DefaultDatabase types.String `tfsdk:"default_database"`
-}
-
-// NewUserResource is a helper function to simplify the provider implementation.
func NewUserResource() resource.Resource {
return &userResource{}
}
-// userResource is the resource implementation.
+// resourceModel describes the resource data model.
+type resourceModel = sqlserverflexalphaResGen.UserModel
+
+// UserResourceIdentityModel describes the resource's identity attributes.
+type UserResourceIdentityModel struct {
+ ProjectID types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ InstanceID types.String `tfsdk:"instance_id"`
+ UserID types.Int64 `tfsdk:"user_id"`
+}
+
type userResource struct {
client *sqlserverflexalpha.APIClient
providerData core.ProviderData
}
-// Metadata returns the resource type name.
func (r *userResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_user"
}
@@ -83,7 +75,7 @@ func (r *userResource) Configure(ctx context.Context, req resource.ConfigureRequ
return
}
r.client = apiClient
- tflog.Info(ctx, "SQLServer Alpha Flex user client configured")
+ tflog.Info(ctx, "SQLServer Beta Flex user client configured")
}
// ModifyPlan implements resource.ResourceWithModifyPlan.
@@ -93,7 +85,7 @@ func (r *userResource) ModifyPlan(
req resource.ModifyPlanRequest,
resp *resource.ModifyPlanResponse,
) { // nolint:gocritic // function signature required by Terraform
- var configModel Model
+ var configModel resourceModel
// skip initial empty configuration to avoid follow-up errors
if req.Config.Raw.IsNull() {
return
@@ -103,7 +95,7 @@ func (r *userResource) ModifyPlan(
return
}
- var planModel Model
+ var planModel resourceModel
resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...)
if resp.Diagnostics.HasError() {
return
@@ -120,118 +112,91 @@ func (r *userResource) ModifyPlan(
}
}
+//go:embed planModifiers.yaml
+var modifiersFileByte []byte
+
// Schema defines the schema for the resource.
-func (r *userResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
- descriptions := map[string]string{
- "main": "SQLServer Flex user resource schema. Must have a `region` specified in the provider configuration.",
- "id": "Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`,`user_id`\".",
- "user_id": "User ID.",
- "instance_id": "ID of the SQLServer Flex instance.",
- "project_id": "STACKIT project ID to which the instance is associated.",
- "username": "Username of the SQLServer Flex instance.",
- "roles": "Database access levels for the user. The values for the default roles are: `##STACKIT_DatabaseManager##`, `##STACKIT_LoginManager##`, `##STACKIT_ProcessManager##`, `##STACKIT_ServerManager##`, `##STACKIT_SQLAgentManager##`, `##STACKIT_SQLAgentUser##`",
- "password": "Password of the user account.",
- "status": "Status of the user.",
- "default_database": "Default database of the user.",
+func (r *userResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
+ s := sqlserverflexalphaResGen.UserResourceSchema(ctx)
+
+ fields, err := utils.ReadModifiersConfig(modifiersFileByte)
+ if err != nil {
+ resp.Diagnostics.AddError("error during read modifiers config file", err.Error())
+ return
}
- resp.Schema = schema.Schema{
- Description: descriptions["main"],
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- Description: descriptions["id"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
+ err = utils.AddPlanModifiersToResourceSchema(fields, &s)
+ if err != nil {
+ resp.Diagnostics.AddError("error adding plan modifiers", err.Error())
+ return
+ }
+ resp.Schema = s
+}
+
+// IdentitySchema defines the schema for the resource's identity attributes.
+func (r *userResource) IdentitySchema(
+ _ context.Context,
+ _ resource.IdentitySchemaRequest,
+ response *resource.IdentitySchemaResponse,
+) {
+ response.IdentitySchema = identityschema.Schema{
+ Attributes: map[string]identityschema.Attribute{
+ "project_id": identityschema.StringAttribute{
+ RequiredForImport: true, // must be set during import by the practitioner
},
- "user_id": schema.StringAttribute{
- Description: descriptions["user_id"],
- Computed: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.NoSeparator(),
- },
+ "region": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
},
- "instance_id": schema.StringAttribute{
- Description: descriptions["instance_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
+ "instance_id": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
},
- "project_id": schema.StringAttribute{
- Description: descriptions["project_id"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- Validators: []validator.String{
- validate.UUID(),
- validate.NoSeparator(),
- },
- },
- "username": schema.StringAttribute{
- Description: descriptions["username"],
- Required: true,
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- stringplanmodifier.UseStateForUnknown(),
- },
- },
- "roles": schema.SetAttribute{
- Description: descriptions["roles"],
- ElementType: types.StringType,
- Required: true,
- PlanModifiers: []planmodifier.Set{
- setplanmodifier.RequiresReplace(),
- },
- },
- "password": schema.StringAttribute{
- Description: descriptions["password"],
- Computed: true,
- Sensitive: true,
- },
- "host": schema.StringAttribute{
- Computed: true,
- },
- "port": schema.Int64Attribute{
- Computed: true,
- },
- "region": schema.StringAttribute{
- Optional: true,
- // must be computed to allow for storing the override value from the provider
- Computed: true,
- Description: descriptions["region"],
- PlanModifiers: []planmodifier.String{
- stringplanmodifier.RequiresReplace(),
- },
- },
- "status": schema.StringAttribute{
- Computed: true,
- },
- "default_database": schema.StringAttribute{
- Computed: true,
+ "user_id": identityschema.Int64Attribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
},
},
}
}
+func (r *userResource) ValidateConfig(
+ ctx context.Context,
+ req resource.ValidateConfigRequest,
+ resp *resource.ValidateConfigResponse,
+) {
+ var data resourceModel
+
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ var roles []string
+ diags := data.Roles.ElementsAs(ctx, &roles, false)
+ resp.Diagnostics.Append(diags...)
+ if diags.HasError() {
+ return
+ }
+
+ var resRoles []string
+ for _, role := range roles {
+ if slices.Contains(resRoles, role) {
+ resp.Diagnostics.AddAttributeError(
+ path.Root("roles"),
+ "Attribute Configuration Error",
+ "defined roles MUST NOT contain duplicates",
+ )
+ return
+ }
+ resRoles = append(resRoles, role)
+ }
+}
+
// Create creates the resource and sets the initial Terraform state.
func (r *userResource) Create(
ctx context.Context,
req resource.CreateRequest,
resp *resource.CreateResponse,
) { // nolint:gocritic // function signature required by Terraform
- var model Model
+ var model resourceModel
diags := req.Plan.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -248,13 +213,15 @@ func (r *userResource) Create(
ctx = tflog.SetField(ctx, "instance_id", instanceId)
ctx = tflog.SetField(ctx, "region", region)
- var roles []sqlserverflexalpha.UserRole
- if !(model.Roles.IsNull() || model.Roles.IsUnknown()) {
+ var roles []string
+ if !model.Roles.IsNull() && !model.Roles.IsUnknown() {
diags = model.Roles.ElementsAs(ctx, &roles, false)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
+
+ slices.Sort(roles)
}
// Generate API request body from model
@@ -286,10 +253,22 @@ func (r *userResource) Create(
)
return
}
+
userId := *userResp.Id
ctx = tflog.SetField(ctx, "user_id", userId)
- // Map response body to schema
+ // Set data returned by API in identity
+ identity := UserResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ UserID: types.Int64Value(userId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
err = mapFieldsCreate(userResp, &model, region)
if err != nil {
core.LogAndAddError(
@@ -300,6 +279,51 @@ func (r *userResource) Create(
)
return
}
+
+ waitResp, err := sqlserverflexalphaWait.CreateUserWaitHandler(
+ ctx,
+ r.client,
+ projectId,
+ instanceId,
+ region,
+ userId,
+ ).SetSleepBeforeWait(
+ 90 * time.Second,
+ ).SetTimeout(
+ 90 * time.Minute,
+ ).WaitWithContext(ctx)
+
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "create user",
+ fmt.Sprintf("Instance creation waiting: %v", err),
+ )
+ return
+ }
+
+ if waitResp.Id == nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "create user",
+ "Instance creation waiting: returned id is nil",
+ )
+ return
+ }
+
+ // Map response body to schema
+ err = mapFields(waitResp, &model, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating user",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
// Set state to fully populated data
diags = resp.State.Set(ctx, model)
resp.Diagnostics.Append(diags...)
@@ -315,7 +339,7 @@ func (r *userResource) Read(
req resource.ReadRequest,
resp *resource.ReadResponse,
) { // nolint:gocritic // function signature required by Terraform
- var model Model
+ var model resourceModel
diags := req.State.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -363,6 +387,18 @@ func (r *userResource) Read(
return
}
+ // Set data returned by API in identity
+ identity := UserResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ UserID: types.Int64Value(userId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
// Set refreshed state
diags = resp.State.Set(ctx, model)
resp.Diagnostics.Append(diags...)
@@ -389,7 +425,7 @@ func (r *userResource) Delete(
resp *resource.DeleteResponse,
) { // nolint:gocritic // function signature required by Terraform
// Retrieve values from plan
- var model Model
+ var model resourceModel
diags := req.State.Get(ctx, &model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -408,14 +444,40 @@ func (r *userResource) Delete(
ctx = tflog.SetField(ctx, "region", region)
// Delete existing record set
- err := r.client.DeleteUserRequest(ctx, projectId, region, instanceId, userId).Execute()
+ // err := r.client.DeleteUserRequest(ctx, projectId, region, instanceId, userId).Execute()
+ err := r.client.DeleteUserRequestExecute(ctx, projectId, region, instanceId, userId)
if err != nil {
- core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting user", fmt.Sprintf("Calling API: %v", err))
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ // TODO err handling
+ return
+ }
+
+ switch oapiErr.StatusCode {
+ case http.StatusNotFound:
+ resp.State.RemoveResource(ctx)
+ return
+ // case http.StatusInternalServerError:
+ // tflog.Warn(ctx, "[delete user] Wait handler got error 500")
+ // return false, nil, nil
+ default:
+ // TODO err handling
+ return
+ }
+ }
+ // Delete existing record set
+ _, err = sqlserverflexalphaWait.DeleteUserWaitHandler(ctx, r.client, projectId, region, instanceId, userId).
+ WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "User Delete Error", fmt.Sprintf("Calling API: %v", err))
return
}
ctx = core.LogResponse(ctx)
+ resp.State.RemoveResource(ctx)
+
tflog.Info(ctx, "SQLServer Flex user deleted")
}
@@ -426,23 +488,61 @@ func (r *userResource) ImportState(
req resource.ImportStateRequest,
resp *resource.ImportStateResponse,
) {
- idParts := strings.Split(req.ID, core.Separator)
- if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" {
- core.LogAndAddError(
- ctx, &resp.Diagnostics,
- "Error importing user",
- fmt.Sprintf(
- "Expected import identifier with format [project_id],[region],[instance_id],[user_id], got %q",
- req.ID,
- ),
- )
+ ctx = core.InitProviderContext(ctx)
+
+ if req.ID != "" {
+ idParts := strings.Split(req.ID, core.Separator)
+
+ if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" {
+ core.LogAndAddError(
+ ctx, &resp.Diagnostics,
+ "Error importing user",
+ fmt.Sprintf(
+ "Expected import identifier with format [project_id],[region],[instance_id],[user_id], got %q",
+ req.ID,
+ ),
+ )
+ return
+ }
+
+ userId, err := strconv.ParseInt(idParts[3], 10, 64)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error importing user",
+ fmt.Sprintf("Invalid user_id format: %q. It must be a valid integer.", idParts[3]),
+ )
+ return
+ }
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_id"), userId)...)
+
+ tflog.Info(ctx, "SQLServer Flex user state imported")
+
return
}
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
- resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_id"), idParts[3])...)
+ // If no ID is provided, attempt to read identity attributes from the import configuration
+ var identityData UserResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ instanceId := identityData.InstanceID.ValueString()
+ userId := identityData.UserID.ValueInt64()
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), projectId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), region)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), instanceId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_id"), userId)...)
+
core.LogAndAddWarning(
ctx,
&resp.Diagnostics,
@@ -451,118 +551,3 @@ func (r *userResource) ImportState(
)
tflog.Info(ctx, "SQLServer Flex user state imported")
}
-
-func mapFieldsCreate(userResp *sqlserverflexalpha.CreateUserResponse, model *Model, region string) error {
- if userResp == nil {
- return fmt.Errorf("response is nil")
- }
- if model == nil {
- return fmt.Errorf("model input is nil")
- }
- user := userResp
-
- if user.Id == nil {
- return fmt.Errorf("user id not present")
- }
- userId := *user.Id
- model.Id = utils.BuildInternalTerraformId(
- model.ProjectId.ValueString(),
- region,
- model.InstanceId.ValueString(),
- strconv.FormatInt(userId, 10),
- )
- model.UserId = types.Int64Value(userId)
- model.Username = types.StringPointerValue(user.Username)
-
- if user.Password == nil {
- return fmt.Errorf("user password not present")
- }
- model.Password = types.StringValue(*user.Password)
-
- if user.Roles != nil {
- var roles []attr.Value
- for _, role := range *user.Roles {
- roles = append(roles, types.StringValue(string(role)))
- }
- rolesSet, diags := types.SetValue(types.StringType, roles)
- if diags.HasError() {
- return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
- }
- model.Roles = rolesSet
- }
-
- if model.Roles.IsNull() || model.Roles.IsUnknown() {
- model.Roles = types.SetNull(types.StringType)
- }
-
- model.Host = types.StringPointerValue(user.Host)
- model.Port = types.Int64PointerValue(user.Port)
- model.Region = types.StringValue(region)
- model.Status = types.StringPointerValue(user.Status)
- model.DefaultDatabase = types.StringPointerValue(user.DefaultDatabase)
-
- return nil
-}
-
-func mapFields(userResp *sqlserverflexalpha.GetUserResponse, model *Model, region string) error {
- if userResp == nil {
- return fmt.Errorf("response is nil")
- }
- if model == nil {
- return fmt.Errorf("model input is nil")
- }
- user := userResp
-
- var userId int64
- if model.UserId.ValueInt64() != 0 {
- userId = model.UserId.ValueInt64()
- } else if user.Id != nil {
- userId = *user.Id
- } else {
- return fmt.Errorf("user id not present")
- }
- model.Id = utils.BuildInternalTerraformId(
- model.ProjectId.ValueString(),
- region,
- model.InstanceId.ValueString(),
- strconv.FormatInt(userId, 10),
- )
- model.UserId = types.Int64Value(userId)
- model.Username = types.StringPointerValue(user.Username)
-
- if user.Roles != nil {
- var roles []attr.Value
- for _, role := range *user.Roles {
- roles = append(roles, types.StringValue(string(role)))
- }
- rolesSet, diags := types.SetValue(types.StringType, roles)
- if diags.HasError() {
- return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
- }
- model.Roles = rolesSet
- }
-
- if model.Roles.IsNull() || model.Roles.IsUnknown() {
- model.Roles = types.SetNull(types.StringType)
- }
-
- model.Host = types.StringPointerValue(user.Host)
- model.Port = types.Int64PointerValue(user.Port)
- model.Region = types.StringValue(region)
- return nil
-}
-
-func toCreatePayload(
- model *Model,
- roles []sqlserverflexalpha.UserRole,
-) (*sqlserverflexalpha.CreateUserRequestPayload, error) {
- if model == nil {
- return nil, fmt.Errorf("nil model")
- }
-
- return &sqlserverflexalpha.CreateUserRequestPayload{
- Username: conversion.StringValueToPointer(model.Username),
- DefaultDatabase: conversion.StringValueToPointer(model.DefaultDatabase),
- Roles: &roles,
- }, nil
-}
diff --git a/stackit/internal/services/sqlserverflexalpha/user/resources_gen/user_resource_gen.go b/stackit/internal/services/sqlserverflexalpha/user/resources_gen/user_resource_gen.go
new file mode 100644
index 00000000..b316b020
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/user/resources_gen/user_resource_gen.go
@@ -0,0 +1,111 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexalpha
+
+import (
+ "context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+)
+
+func UserResourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "default_database": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The default database for a user of the instance.",
+ MarkdownDescription: "The default database for a user of the instance.",
+ },
+ "host": schema.StringAttribute{
+ Computed: true,
+ Description: "The host of the instance in which the user belongs to.",
+ MarkdownDescription: "The host of the instance in which the user belongs to.",
+ },
+ "id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The ID of the user.",
+ MarkdownDescription: "The ID of the user.",
+ },
+ "instance_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "password": schema.StringAttribute{
+ Computed: true,
+ Description: "The password for the user.",
+ MarkdownDescription: "The password for the user.",
+ },
+ "port": schema.Int64Attribute{
+ Computed: true,
+ Description: "The port of the instance in which the user belongs to.",
+ MarkdownDescription: "The port of the instance in which the user belongs to.",
+ },
+ "project_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "roles": schema.ListAttribute{
+ ElementType: types.StringType,
+ Required: true,
+ Description: "A list containing the user roles for the instance. A list with the valid user roles can be retrieved using the List Roles endpoint.",
+ MarkdownDescription: "A list containing the user roles for the instance. A list with the valid user roles can be retrieved using the List Roles endpoint.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ Description: "The current status of the user.",
+ MarkdownDescription: "The current status of the user.",
+ },
+ "uri": schema.StringAttribute{
+ Computed: true,
+ Description: "The connection string for the user to the instance.",
+ MarkdownDescription: "The connection string for the user to the instance.",
+ },
+ "user_id": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the user.",
+ MarkdownDescription: "The ID of the user.",
+ },
+ "username": schema.StringAttribute{
+ Required: true,
+ Description: "The name of the user.",
+ MarkdownDescription: "The name of the user.",
+ },
+ },
+ }
+}
+
+type UserModel struct {
+ DefaultDatabase types.String `tfsdk:"default_database"`
+ Host types.String `tfsdk:"host"`
+ Id types.Int64 `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Password types.String `tfsdk:"password"`
+ Port types.Int64 `tfsdk:"port"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Roles types.List `tfsdk:"roles"`
+ Status types.String `tfsdk:"status"`
+ Uri types.String `tfsdk:"uri"`
+ UserId types.Int64 `tfsdk:"user_id"`
+ Username types.String `tfsdk:"username"`
+}
diff --git a/stackit/internal/services/sqlserverflexalpha/utils/util.go b/stackit/internal/services/sqlserverflexalpha/utils/util.go
index 3c49e1b9..7fbf0901 100644
--- a/stackit/internal/services/sqlserverflexalpha/utils/util.go
+++ b/stackit/internal/services/sqlserverflexalpha/utils/util.go
@@ -1,17 +1,16 @@
-// Copyright (c) STACKIT
-
package utils
import (
"context"
"fmt"
- sqlserverflex "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
+ sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/stackitcloud/stackit-sdk-go/core/config"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
)
func ConfigureClient(
diff --git a/stackit/internal/services/sqlserverflexalpha/utils/util_test.go b/stackit/internal/services/sqlserverflexalpha/utils/util_test.go
index cfa3f198..91f90030 100644
--- a/stackit/internal/services/sqlserverflexalpha/utils/util_test.go
+++ b/stackit/internal/services/sqlserverflexalpha/utils/util_test.go
@@ -1,5 +1,3 @@
-// Copyright (c) STACKIT
-
package utils
import (
@@ -11,10 +9,11 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
sdkClients "github.com/stackitcloud/stackit-sdk-go/core/clients"
"github.com/stackitcloud/stackit-sdk-go/core/config"
- "github.com/stackitcloud/terraform-provider-stackit/pkg/sqlserverflexalpha"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
+ sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
)
const (
@@ -37,7 +36,7 @@ func TestConfigureClient(t *testing.T) {
name string
args args
wantErr bool
- expected *sqlserverflexalpha.APIClient
+ expected *sqlserverflex.APIClient
}{
{
name: "default endpoint",
@@ -46,8 +45,8 @@ func TestConfigureClient(t *testing.T) {
Version: testVersion,
},
},
- expected: func() *sqlserverflexalpha.APIClient {
- apiClient, err := sqlserverflexalpha.NewAPIClient(
+ expected: func() *sqlserverflex.APIClient {
+ apiClient, err := sqlserverflex.NewAPIClient(
config.WithRegion("eu01"),
utils.UserAgentConfigOption(testVersion),
)
@@ -66,8 +65,8 @@ func TestConfigureClient(t *testing.T) {
SQLServerFlexCustomEndpoint: testCustomEndpoint,
},
},
- expected: func() *sqlserverflexalpha.APIClient {
- apiClient, err := sqlserverflexalpha.NewAPIClient(
+ expected: func() *sqlserverflex.APIClient {
+ apiClient, err := sqlserverflex.NewAPIClient(
utils.UserAgentConfigOption(testVersion),
config.WithEndpoint(testCustomEndpoint),
)
diff --git a/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/version_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/version_data_source_gen.go
new file mode 100644
index 00000000..cb9008f1
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/version_data_source_gen.go
@@ -0,0 +1,569 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexalpha
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func VersionDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "versions": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "beta": schema.BoolAttribute{
+ Computed: true,
+ Description: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.",
+ MarkdownDescription: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.",
+ },
+ "deprecated": schema.StringAttribute{
+ Computed: true,
+ Description: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.",
+ MarkdownDescription: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.",
+ },
+ "recommend": schema.BoolAttribute{
+ Computed: true,
+ Description: "Flag if the version is recommend by the STACKIT Team.",
+ MarkdownDescription: "Flag if the version is recommend by the STACKIT Team.",
+ },
+ "version": schema.StringAttribute{
+ Computed: true,
+ Description: "The sqlserver version used for the instance.",
+ MarkdownDescription: "The sqlserver version used for the instance.",
+ },
+ },
+ CustomType: VersionsType{
+ ObjectType: types.ObjectType{
+ AttrTypes: VersionsValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "A list containing available sqlserver versions.",
+ MarkdownDescription: "A list containing available sqlserver versions.",
+ },
+ },
+ }
+}
+
+type VersionModel struct {
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Versions types.List `tfsdk:"versions"`
+}
+
+var _ basetypes.ObjectTypable = VersionsType{}
+
+type VersionsType struct {
+ basetypes.ObjectType
+}
+
+func (t VersionsType) Equal(o attr.Type) bool {
+ other, ok := o.(VersionsType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t VersionsType) String() string {
+ return "VersionsType"
+}
+
+func (t VersionsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ betaAttribute, ok := attributes["beta"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `beta is missing from object`)
+
+ return nil, diags
+ }
+
+ betaVal, ok := betaAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute))
+ }
+
+ deprecatedAttribute, ok := attributes["deprecated"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `deprecated is missing from object`)
+
+ return nil, diags
+ }
+
+ deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute))
+ }
+
+ recommendAttribute, ok := attributes["recommend"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `recommend is missing from object`)
+
+ return nil, diags
+ }
+
+ recommendVal, ok := recommendAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute))
+ }
+
+ versionAttribute, ok := attributes["version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `version is missing from object`)
+
+ return nil, diags
+ }
+
+ versionVal, ok := versionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return VersionsValue{
+ Beta: betaVal,
+ Deprecated: deprecatedVal,
+ Recommend: recommendVal,
+ Version: versionVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewVersionsValueNull() VersionsValue {
+ return VersionsValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewVersionsValueUnknown() VersionsValue {
+ return VersionsValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewVersionsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (VersionsValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing VersionsValue Attribute Value",
+ "While creating a VersionsValue value, a missing attribute value was detected. "+
+ "A VersionsValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid VersionsValue Attribute Type",
+ "While creating a VersionsValue value, an invalid attribute value was detected. "+
+ "A VersionsValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("VersionsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra VersionsValue Attribute Value",
+ "While creating a VersionsValue value, an extra attribute value was detected. "+
+ "A VersionsValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra VersionsValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewVersionsValueUnknown(), diags
+ }
+
+ betaAttribute, ok := attributes["beta"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `beta is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ betaVal, ok := betaAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute))
+ }
+
+ deprecatedAttribute, ok := attributes["deprecated"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `deprecated is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute))
+ }
+
+ recommendAttribute, ok := attributes["recommend"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `recommend is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ recommendVal, ok := recommendAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute))
+ }
+
+ versionAttribute, ok := attributes["version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `version is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ versionVal, ok := versionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute))
+ }
+
+ if diags.HasError() {
+ return NewVersionsValueUnknown(), diags
+ }
+
+ return VersionsValue{
+ Beta: betaVal,
+ Deprecated: deprecatedVal,
+ Recommend: recommendVal,
+ Version: versionVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewVersionsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) VersionsValue {
+ object, diags := NewVersionsValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewVersionsValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t VersionsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewVersionsValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewVersionsValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewVersionsValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewVersionsValueMust(VersionsValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t VersionsType) ValueType(ctx context.Context) attr.Value {
+ return VersionsValue{}
+}
+
+var _ basetypes.ObjectValuable = VersionsValue{}
+
+type VersionsValue struct {
+ Beta basetypes.BoolValue `tfsdk:"beta"`
+ Deprecated basetypes.StringValue `tfsdk:"deprecated"`
+ Recommend basetypes.BoolValue `tfsdk:"recommend"`
+ Version basetypes.StringValue `tfsdk:"version"`
+ state attr.ValueState
+}
+
+func (v VersionsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["beta"] = basetypes.BoolType{}.TerraformType(ctx)
+ attrTypes["deprecated"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["recommend"] = basetypes.BoolType{}.TerraformType(ctx)
+ attrTypes["version"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.Beta.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["beta"] = val
+
+ val, err = v.Deprecated.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["deprecated"] = val
+
+ val, err = v.Recommend.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["recommend"] = val
+
+ val, err = v.Version.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["version"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v VersionsValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v VersionsValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v VersionsValue) String() string {
+ return "VersionsValue"
+}
+
+func (v VersionsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "beta": basetypes.BoolType{},
+ "deprecated": basetypes.StringType{},
+ "recommend": basetypes.BoolType{},
+ "version": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "beta": v.Beta,
+ "deprecated": v.Deprecated,
+ "recommend": v.Recommend,
+ "version": v.Version,
+ })
+
+ return objVal, diags
+}
+
+func (v VersionsValue) Equal(o attr.Value) bool {
+ other, ok := o.(VersionsValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Beta.Equal(other.Beta) {
+ return false
+ }
+
+ if !v.Deprecated.Equal(other.Deprecated) {
+ return false
+ }
+
+ if !v.Recommend.Equal(other.Recommend) {
+ return false
+ }
+
+ if !v.Version.Equal(other.Version) {
+ return false
+ }
+
+ return true
+}
+
+func (v VersionsValue) Type(ctx context.Context) attr.Type {
+ return VersionsType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v VersionsValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "beta": basetypes.BoolType{},
+ "deprecated": basetypes.StringType{},
+ "recommend": basetypes.BoolType{},
+ "version": basetypes.StringType{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/database/datasource.go b/stackit/internal/services/sqlserverflexbeta/database/datasource.go
new file mode 100644
index 00000000..c6fa31bf
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/database/datasource.go
@@ -0,0 +1,174 @@
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexbetaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+ sqlserverflexbetaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database/datasources_gen"
+)
+
+var _ datasource.DataSource = (*databaseDataSource)(nil)
+
+const errorPrefix = "[Sqlserverflexbeta - Database]"
+
+func NewDatabaseDataSource() datasource.DataSource {
+ return &databaseDataSource{}
+}
+
+type dataSourceModel struct {
+ sqlserverflexbetaGen.DatabaseModel
+ TerraformId types.String `tfsdk:"id"`
+}
+
+type databaseDataSource struct {
+ client *sqlserverflexbetaPkg.APIClient
+ providerData core.ProviderData
+}
+
+func (d *databaseDataSource) Metadata(
+ _ context.Context,
+ req datasource.MetadataRequest,
+ resp *datasource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexbeta_database"
+}
+
+func (d *databaseDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = sqlserverflexbetaGen.DatabaseDataSourceSchema(ctx)
+ resp.Schema.Attributes["id"] = schema.StringAttribute{
+ Computed: true,
+ Description: "The terraform internal identifier.",
+ MarkdownDescription: "The terraform internal identifier.",
+ }
+}
+
+// Configure adds the provider configured client to the data source.
+func (d *databaseDataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
+ var ok bool
+ d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(d.providerData.RoundTripper),
+ utils.UserAgentConfigOption(d.providerData.Version),
+ }
+ if d.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(d.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithRegion(d.providerData.GetRegion()),
+ )
+ }
+ apiClient, err := sqlserverflexbetaPkg.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ d.client = apiClient
+ tflog.Info(ctx, fmt.Sprintf("%s client configured", errorPrefix))
+}
+
+func (d *databaseDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var data dataSourceModel
+ // Read Terraform configuration data into the model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ // Extract identifiers from the plan
+ projectId := data.ProjectId.ValueString()
+ region := d.providerData.GetRegionWithOverride(data.Region)
+ instanceId := data.InstanceId.ValueString()
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+
+ databaseName := data.DatabaseName.ValueString()
+
+ databaseResp, err := d.client.GetDatabaseRequest(ctx, projectId, region, instanceId, databaseName).Execute()
+ if err != nil {
+ handleReadError(ctx, &resp.Diagnostics, err, projectId, instanceId)
+ resp.State.RemoveResource(ctx)
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+ // Map response body to schema and populate Computed attribute values
+ err = mapFields(databaseResp, &data, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading database",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Save data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+
+ tflog.Info(ctx, "SQL Server Flex beta database read")
+}
+
+// handleReadError centralizes API error handling for the Read operation.
+func handleReadError(ctx context.Context, diags *diag.Diagnostics, err error, projectId, instanceId string) {
+ utils.LogError(
+ ctx,
+ diags,
+ err,
+ "Reading database",
+ fmt.Sprintf(
+ "Could not retrieve database for instance %q in project %q.",
+ instanceId,
+ projectId,
+ ),
+ map[int]string{
+ http.StatusBadRequest: fmt.Sprintf(
+ "Invalid request parameters for project %q and instance %q.",
+ projectId,
+ instanceId,
+ ),
+ http.StatusNotFound: fmt.Sprintf(
+ "Database, instance %q, or project %q not found.",
+ instanceId,
+ projectId,
+ ),
+ http.StatusForbidden: fmt.Sprintf("Forbidden access to project %q.", projectId),
+ },
+ )
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/database_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/database_data_source_gen.go
new file mode 100644
index 00000000..92b1064e
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/database_data_source_gen.go
@@ -0,0 +1,81 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexbeta
+
+import (
+ "context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func DatabaseDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "collation_name": schema.StringAttribute{
+ Computed: true,
+ Description: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ MarkdownDescription: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ },
+ "compatibility_level": schema.Int64Attribute{
+ Computed: true,
+ Description: "CompatibilityLevel of the Database.",
+ MarkdownDescription: "CompatibilityLevel of the Database.",
+ },
+ "database_name": schema.StringAttribute{
+ Required: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "tf_original_api_id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The id of the database.",
+ MarkdownDescription: "The id of the database.",
+ },
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "owner": schema.StringAttribute{
+ Computed: true,
+ Description: "The owner of the database.",
+ MarkdownDescription: "The owner of the database.",
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type DatabaseModel struct {
+ CollationName types.String `tfsdk:"collation_name"`
+ CompatibilityLevel types.Int64 `tfsdk:"compatibility_level"`
+ DatabaseName types.String `tfsdk:"database_name"`
+ Id types.Int64 `tfsdk:"tf_original_api_id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Name types.String `tfsdk:"name"`
+ Owner types.String `tfsdk:"owner"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/databases_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/databases_data_source_gen.go
new file mode 100644
index 00000000..71ec8fb4
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/databases_data_source_gen.go
@@ -0,0 +1,1180 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func DatabasesDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "databases": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "created": schema.StringAttribute{
+ Computed: true,
+ Description: "The date when the database was created in RFC3339 format.",
+ MarkdownDescription: "The date when the database was created in RFC3339 format.",
+ },
+ "id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The id of the database.",
+ MarkdownDescription: "The id of the database.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "owner": schema.StringAttribute{
+ Computed: true,
+ Description: "The owner of the database.",
+ MarkdownDescription: "The owner of the database.",
+ },
+ },
+ CustomType: DatabasesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: DatabasesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "A list containing all databases for the instance.",
+ MarkdownDescription: "A list containing all databases for the instance.",
+ },
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the databases to be returned on each page.",
+ MarkdownDescription: "Sorting of the databases to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "created_at.desc",
+ "created_at.asc",
+ "database_id.desc",
+ "database_id.asc",
+ "database_name.desc",
+ "database_name.asc",
+ "database_owner.desc",
+ "database_owner.asc",
+ "index.asc",
+ "index.desc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type DatabasesModel struct {
+ Databases types.List `tfsdk:"databases"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = DatabasesType{}
+
+type DatabasesType struct {
+ basetypes.ObjectType
+}
+
+func (t DatabasesType) Equal(o attr.Type) bool {
+ other, ok := o.(DatabasesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t DatabasesType) String() string {
+ return "DatabasesType"
+}
+
+func (t DatabasesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ createdAttribute, ok := attributes["created"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `created is missing from object`)
+
+ return nil, diags
+ }
+
+ createdVal, ok := createdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`created expected to be basetypes.StringValue, was: %T`, createdAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return nil, diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ ownerAttribute, ok := attributes["owner"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `owner is missing from object`)
+
+ return nil, diags
+ }
+
+ ownerVal, ok := ownerAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`owner expected to be basetypes.StringValue, was: %T`, ownerAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return DatabasesValue{
+ Created: createdVal,
+ Id: idVal,
+ Name: nameVal,
+ Owner: ownerVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewDatabasesValueNull() DatabasesValue {
+ return DatabasesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewDatabasesValueUnknown() DatabasesValue {
+ return DatabasesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewDatabasesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (DatabasesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing DatabasesValue Attribute Value",
+ "While creating a DatabasesValue value, a missing attribute value was detected. "+
+ "A DatabasesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("DatabasesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid DatabasesValue Attribute Type",
+ "While creating a DatabasesValue value, an invalid attribute value was detected. "+
+ "A DatabasesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("DatabasesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("DatabasesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra DatabasesValue Attribute Value",
+ "While creating a DatabasesValue value, an extra attribute value was detected. "+
+ "A DatabasesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra DatabasesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ createdAttribute, ok := attributes["created"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `created is missing from object`)
+
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ createdVal, ok := createdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`created expected to be basetypes.StringValue, was: %T`, createdAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ ownerAttribute, ok := attributes["owner"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `owner is missing from object`)
+
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ ownerVal, ok := ownerAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`owner expected to be basetypes.StringValue, was: %T`, ownerAttribute))
+ }
+
+ if diags.HasError() {
+ return NewDatabasesValueUnknown(), diags
+ }
+
+ return DatabasesValue{
+ Created: createdVal,
+ Id: idVal,
+ Name: nameVal,
+ Owner: ownerVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewDatabasesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) DatabasesValue {
+ object, diags := NewDatabasesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewDatabasesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t DatabasesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewDatabasesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewDatabasesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewDatabasesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewDatabasesValueMust(DatabasesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t DatabasesType) ValueType(ctx context.Context) attr.Value {
+ return DatabasesValue{}
+}
+
+var _ basetypes.ObjectValuable = DatabasesValue{}
+
+type DatabasesValue struct {
+ Created basetypes.StringValue `tfsdk:"created"`
+ Id basetypes.Int64Value `tfsdk:"id"`
+ Name basetypes.StringValue `tfsdk:"name"`
+ Owner basetypes.StringValue `tfsdk:"owner"`
+ state attr.ValueState
+}
+
+func (v DatabasesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["created"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["id"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["name"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["owner"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.Created.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["created"] = val
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.Name.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["name"] = val
+
+ val, err = v.Owner.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["owner"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v DatabasesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v DatabasesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v DatabasesValue) String() string {
+ return "DatabasesValue"
+}
+
+func (v DatabasesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "created": basetypes.StringType{},
+ "id": basetypes.Int64Type{},
+ "name": basetypes.StringType{},
+ "owner": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "created": v.Created,
+ "id": v.Id,
+ "name": v.Name,
+ "owner": v.Owner,
+ })
+
+ return objVal, diags
+}
+
+func (v DatabasesValue) Equal(o attr.Value) bool {
+ other, ok := o.(DatabasesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Created.Equal(other.Created) {
+ return false
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.Name.Equal(other.Name) {
+ return false
+ }
+
+ if !v.Owner.Equal(other.Owner) {
+ return false
+ }
+
+ return true
+}
+
+func (v DatabasesValue) Type(ctx context.Context) attr.Type {
+ return DatabasesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v DatabasesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "created": basetypes.StringType{},
+ "id": basetypes.Int64Type{},
+ "name": basetypes.StringType{},
+ "owner": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/database/mapper.go b/stackit/internal/services/sqlserverflexbeta/database/mapper.go
new file mode 100644
index 00000000..43a4344f
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/database/mapper.go
@@ -0,0 +1,103 @@
+package sqlserverflexbeta
+
+import (
+ "fmt"
+
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+// mapFields maps fields from a ListDatabase API response to a resourceModel for the data source.
+func mapFields(source *sqlserverflexbeta.GetDatabaseResponse, model *dataSourceModel, region string) error {
+ if source == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if source.Id == nil || *source.Id == 0 {
+ return fmt.Errorf("id not present")
+ }
+ if model == nil {
+ return fmt.Errorf("model given is nil")
+ }
+
+ var databaseId int64
+ if model.Id.ValueInt64() != 0 {
+ databaseId = model.Id.ValueInt64()
+ } else if source.Id != nil {
+ databaseId = *source.Id
+ } else {
+ return fmt.Errorf("database id not present")
+ }
+
+ model.Id = types.Int64Value(databaseId)
+ model.DatabaseName = types.StringValue(source.GetName())
+ model.Name = types.StringValue(source.GetName())
+ model.Owner = types.StringValue(source.GetOwner())
+ model.Region = types.StringValue(region)
+ model.ProjectId = types.StringValue(model.ProjectId.ValueString())
+ model.InstanceId = types.StringValue(model.InstanceId.ValueString())
+ model.CompatibilityLevel = types.Int64Value(source.GetCompatibilityLevel())
+ model.CollationName = types.StringValue(source.GetCollationName())
+
+ model.TerraformId = utils.BuildInternalTerraformId(
+ model.ProjectId.ValueString(),
+ region,
+ model.InstanceId.ValueString(),
+ model.DatabaseName.ValueString(),
+ )
+
+ return nil
+}
+
+// mapResourceFields maps fields from a ListDatabase API response to a resourceModel for the resource.
+func mapResourceFields(source *sqlserverflexbeta.GetDatabaseResponse, model *resourceModel, region string) error {
+ if source == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if source.Id == nil || *source.Id == 0 {
+ return fmt.Errorf("id not present")
+ }
+ if model == nil {
+ return fmt.Errorf("model input is nil")
+ }
+
+ var databaseId int64
+ if model.Id.ValueInt64() != 0 {
+ databaseId = model.Id.ValueInt64()
+ } else if source.Id != nil {
+ databaseId = *source.Id
+ } else {
+ return fmt.Errorf("database id not present")
+ }
+
+ model.Id = types.Int64Value(databaseId)
+ model.DatabaseName = types.StringValue(source.GetName())
+ model.Name = types.StringValue(source.GetName())
+ model.Owner = types.StringValue(source.GetOwner())
+ model.Region = types.StringValue(region)
+ model.ProjectId = types.StringValue(model.ProjectId.ValueString())
+ model.InstanceId = types.StringValue(model.InstanceId.ValueString())
+
+ model.Compatibility = types.Int64Value(source.GetCompatibilityLevel())
+ model.CompatibilityLevel = types.Int64Value(source.GetCompatibilityLevel())
+
+ model.Collation = types.StringValue(source.GetCollationName()) // it does not come back from api
+ model.CollationName = types.StringValue(source.GetCollationName())
+
+ return nil
+}
+
+// toCreatePayload converts the resource model to an API create payload.
+func toCreatePayload(model *resourceModel) (*sqlserverflexbeta.CreateDatabaseRequestPayload, error) {
+ if model == nil {
+ return nil, fmt.Errorf("nil model")
+ }
+
+ return &sqlserverflexbeta.CreateDatabaseRequestPayload{
+ Name: model.Name.ValueStringPointer(),
+ Owner: model.Owner.ValueStringPointer(),
+ Collation: model.Collation.ValueStringPointer(),
+ Compatibility: model.Compatibility.ValueInt64Pointer(),
+ }, nil
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/database/mapper_test.go b/stackit/internal/services/sqlserverflexbeta/database/mapper_test.go
new file mode 100644
index 00000000..f865f22f
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/database/mapper_test.go
@@ -0,0 +1,232 @@
+package sqlserverflexbeta
+
+import (
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+ datasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database/datasources_gen"
+)
+
+func TestMapFields(t *testing.T) {
+ type given struct {
+ source *sqlserverflexbeta.GetDatabaseResponse
+ model *dataSourceModel
+ region string
+ }
+ type expected struct {
+ model *dataSourceModel
+ err bool
+ }
+
+ testcases := []struct {
+ name string
+ given given
+ expected expected
+ }{
+ {
+ name: "should map fields correctly",
+ given: given{
+ source: &sqlserverflexbeta.GetDatabaseResponse{
+ Id: utils.Ptr(int64(1)),
+ Name: utils.Ptr("my-db"),
+ CollationName: utils.Ptr("collation"),
+ CompatibilityLevel: utils.Ptr(int64(150)),
+ Owner: utils.Ptr("my-owner"),
+ },
+ model: &dataSourceModel{
+ DatabaseModel: datasource.DatabaseModel{
+ ProjectId: types.StringValue("my-project"),
+ InstanceId: types.StringValue("my-instance"),
+ },
+ },
+ region: "eu01",
+ },
+ expected: expected{
+ model: &dataSourceModel{
+ DatabaseModel: datasource.DatabaseModel{
+ Id: types.Int64Value(1),
+ Name: types.StringValue("my-db"),
+ DatabaseName: types.StringValue("my-db"),
+ Owner: types.StringValue("my-owner"),
+ Region: types.StringValue("eu01"),
+ InstanceId: types.StringValue("my-instance"),
+ ProjectId: types.StringValue("my-project"),
+ CompatibilityLevel: types.Int64Value(150),
+ CollationName: types.StringValue("collation"),
+ },
+ TerraformId: types.StringValue("my-project,eu01,my-instance,my-db"),
+ },
+ },
+ },
+ {
+ name: "should fail on nil source",
+ given: given{
+ source: nil,
+ model: &dataSourceModel{},
+ },
+ expected: expected{err: true},
+ },
+ {
+ name: "should fail on nil source ID",
+ given: given{
+ source: &sqlserverflexbeta.GetDatabaseResponse{Id: nil},
+ model: &dataSourceModel{},
+ },
+ expected: expected{err: true},
+ },
+ {
+ name: "should fail on nil model",
+ given: given{
+ source: &sqlserverflexbeta.GetDatabaseResponse{Id: utils.Ptr(int64(1))},
+ model: nil,
+ },
+ expected: expected{err: true},
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ err := mapFields(tc.given.source, tc.given.model, tc.given.region)
+ if (err != nil) != tc.expected.err {
+ t.Fatalf("expected error: %v, got: %v", tc.expected.err, err)
+ }
+ if err == nil {
+ if diff := cmp.Diff(tc.expected.model, tc.given.model); diff != "" {
+ t.Errorf("model mismatch (-want +got):\n%s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestMapResourceFields(t *testing.T) {
+ type given struct {
+ source *sqlserverflexbeta.GetDatabaseResponse
+ model *resourceModel
+ region string
+ }
+ type expected struct {
+ model *resourceModel
+ err bool
+ }
+
+ testcases := []struct {
+ name string
+ given given
+ expected expected
+ }{
+ {
+ name: "should map fields correctly",
+ given: given{
+ source: &sqlserverflexbeta.GetDatabaseResponse{
+ Id: utils.Ptr(int64(1)),
+ Name: utils.Ptr("my-db"),
+ Owner: utils.Ptr("my-owner"),
+ },
+ model: &resourceModel{
+ ProjectId: types.StringValue("my-project"),
+ InstanceId: types.StringValue("my-instance"),
+ },
+ region: "eu01",
+ },
+ expected: expected{
+ model: &resourceModel{
+ Id: types.Int64Value(1),
+ Name: types.StringValue("my-db"),
+ Compatibility: types.Int64Value(0),
+ CompatibilityLevel: types.Int64Value(0),
+ Collation: types.StringValue(""),
+ CollationName: types.StringValue(""),
+ DatabaseName: types.StringValue("my-db"),
+ InstanceId: types.StringValue("my-instance"),
+ ProjectId: types.StringValue("my-project"),
+ Region: types.StringValue("eu01"),
+ Owner: types.StringValue("my-owner"),
+ },
+ },
+ },
+ {
+ name: "should fail on nil source",
+ given: given{
+ source: nil,
+ model: &resourceModel{},
+ },
+ expected: expected{err: true},
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ err := mapResourceFields(tc.given.source, tc.given.model, tc.given.region)
+ if (err != nil) != tc.expected.err {
+ t.Fatalf("expected error: %v, got: %v", tc.expected.err, err)
+ }
+ if err == nil {
+ if diff := cmp.Diff(tc.expected.model, tc.given.model); diff != "" {
+ t.Errorf("model mismatch (-want +got):\n%s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestToCreatePayload(t *testing.T) {
+ type given struct {
+ model *resourceModel
+ }
+ type expected struct {
+ payload *sqlserverflexbeta.CreateDatabaseRequestPayload
+ err bool
+ }
+
+ testcases := []struct {
+ name string
+ given given
+ expected expected
+ }{
+ {
+ name: "should convert model to payload",
+ given: given{
+ model: &resourceModel{
+ Name: types.StringValue("my-db"),
+ Owner: types.StringValue("my-owner"),
+ },
+ },
+ expected: expected{
+ payload: &sqlserverflexbeta.CreateDatabaseRequestPayload{
+ Name: utils.Ptr("my-db"),
+ Owner: utils.Ptr("my-owner"),
+ },
+ },
+ },
+ {
+ name: "should fail on nil model",
+ given: given{model: nil},
+ expected: expected{err: true},
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ actual, err := toCreatePayload(tc.given.model)
+ if (err != nil) != tc.expected.err {
+ t.Fatalf("expected error: %v, got: %v", tc.expected.err, err)
+ }
+ if err == nil {
+ if diff := cmp.Diff(tc.expected.payload, actual); diff != "" {
+ t.Errorf("payload mismatch (-want +got):\n%s", diff)
+ }
+ }
+ },
+ )
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/database/planModifiers.yaml b/stackit/internal/services/sqlserverflexbeta/database/planModifiers.yaml
new file mode 100644
index 00000000..08d7e6cf
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/database/planModifiers.yaml
@@ -0,0 +1,56 @@
+fields:
+ - name: 'id'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'instance_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'project_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'region'
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'name'
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'collation'
+ modifiers:
+ - 'RequiresReplace'
+
+ - name: 'owner'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'database_name'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'collation_name'
+ modifiers:
+ - 'RequiresReplace'
+ - 'UseStateForUnknown'
+
+ - name: 'compatibility'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'compatibility_level'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
diff --git a/stackit/internal/services/sqlserverflexbeta/database/resource.go b/stackit/internal/services/sqlserverflexbeta/database/resource.go
new file mode 100644
index 00000000..9862ca57
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/database/resource.go
@@ -0,0 +1,559 @@
+package sqlserverflexbeta
+
+import (
+ "context"
+ _ "embed"
+ "errors"
+ "fmt"
+ "net/http"
+ "strings"
+ "time"
+
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+ "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ wait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexbeta"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexbetaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database/resources_gen"
+)
+
+var (
+ _ resource.Resource = &databaseResource{}
+ _ resource.ResourceWithConfigure = &databaseResource{}
+ _ resource.ResourceWithImportState = &databaseResource{}
+ _ resource.ResourceWithModifyPlan = &databaseResource{}
+ _ resource.ResourceWithIdentity = &databaseResource{}
+
+ // Define errors
+ errDatabaseNotFound = errors.New("database not found")
+)
+
+func NewDatabaseResource() resource.Resource {
+ return &databaseResource{}
+}
+
+// resourceModel describes the resource data model.
+type resourceModel = sqlserverflexbetaResGen.DatabaseModel
+
+type databaseResource struct {
+ client *sqlserverflexbeta.APIClient
+ providerData core.ProviderData
+}
+
+type DatabaseResourceIdentityModel struct {
+ ProjectID types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ InstanceID types.String `tfsdk:"instance_id"`
+ DatabaseName types.String `tfsdk:"database_name"`
+}
+
+func (r *databaseResource) Metadata(
+ _ context.Context,
+ req resource.MetadataRequest,
+ resp *resource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexbeta_database"
+}
+
+//go:embed planModifiers.yaml
+var modifiersFileByte []byte
+
+func (r *databaseResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
+ s := sqlserverflexbetaResGen.DatabaseResourceSchema(ctx)
+
+ fields, err := utils.ReadModifiersConfig(modifiersFileByte)
+ if err != nil {
+ resp.Diagnostics.AddError("error during read modifiers config file", err.Error())
+ return
+ }
+
+ err = utils.AddPlanModifiersToResourceSchema(fields, &s)
+ if err != nil {
+ resp.Diagnostics.AddError("error adding plan modifiers", err.Error())
+ return
+ }
+ resp.Schema = s
+}
+
+func (r *databaseResource) IdentitySchema(
+ _ context.Context,
+ _ resource.IdentitySchemaRequest,
+ resp *resource.IdentitySchemaResponse,
+) {
+ resp.IdentitySchema = identityschema.Schema{
+ Attributes: map[string]identityschema.Attribute{
+ "project_id": identityschema.StringAttribute{
+ RequiredForImport: true, // must be set during import by the practitioner
+ },
+ "region": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ "instance_id": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ "database_name": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ },
+ }
+}
+
+// Configure adds the provider configured client to the resource.
+func (r *databaseResource) Configure(
+ ctx context.Context,
+ req resource.ConfigureRequest,
+ resp *resource.ConfigureResponse,
+) {
+ var ok bool
+ r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(r.providerData.RoundTripper),
+ utils.UserAgentConfigOption(r.providerData.Version),
+ }
+ if r.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(r.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(apiClientConfigOptions, config.WithRegion(r.providerData.GetRegion()))
+ }
+ apiClient, err := sqlserverflexbeta.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ r.client = apiClient
+ tflog.Info(ctx, "sqlserverflexbeta.Database client configured")
+}
+
+func (r *databaseResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
+ var data resourceModel
+ createErr := "DB create error"
+
+ // Read Terraform plan data into the model
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := data.ProjectId.ValueString()
+ region := data.Region.ValueString()
+ instanceId := data.InstanceId.ValueString()
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+
+ databaseName := data.Name.ValueString()
+ ctx = tflog.SetField(ctx, "database_name", databaseName)
+
+ payLoad := sqlserverflexbeta.CreateDatabaseRequestPayload{}
+ if !data.Collation.IsNull() && !data.Collation.IsUnknown() {
+ payLoad.Collation = data.Collation.ValueStringPointer()
+ }
+
+ if !data.Compatibility.IsNull() && !data.Compatibility.IsUnknown() {
+ payLoad.Compatibility = data.Compatibility.ValueInt64Pointer()
+ }
+
+ payLoad.Name = data.Name.ValueStringPointer()
+ payLoad.Owner = data.Owner.ValueStringPointer()
+
+ _, err := wait.WaitForUserWaitHandler(
+ ctx,
+ r.client,
+ projectId,
+ instanceId,
+ region,
+ data.Owner.ValueString(),
+ ).
+ SetSleepBeforeWait(10 * time.Second).
+ WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ fmt.Sprintf("Calling API: %v", err),
+ )
+ return
+ }
+
+ createResp, err := r.client.CreateDatabaseRequest(ctx, projectId, region, instanceId).
+ CreateDatabaseRequestPayload(payLoad).
+ Execute()
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ fmt.Sprintf("Calling API: %v", err),
+ )
+ return
+ }
+
+ if createResp == nil || createResp.Id == nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating database",
+ "API didn't return database Id. A database might have been created",
+ )
+ return
+ }
+
+ databaseId := *createResp.Id
+
+ ctx = tflog.SetField(ctx, "database_id", databaseId)
+
+ ctx = core.LogResponse(ctx)
+
+ // Set data returned by API in identity
+ identity := DatabaseResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ DatabaseName: types.StringValue(databaseName),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ waitResp, err := wait.CreateDatabaseWaitHandler(
+ ctx,
+ r.client,
+ projectId,
+ instanceId,
+ region,
+ databaseName,
+ ).SetSleepBeforeWait(
+ 30 * time.Second,
+ ).SetTimeout(
+ 15 * time.Minute,
+ ).WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ fmt.Sprintf("Database creation waiting: %v", err),
+ )
+ return
+ }
+
+ if waitResp.Id == nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ "Database creation waiting: returned id is nil",
+ )
+ return
+ }
+
+ if *waitResp.Id != databaseId {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ "Database creation waiting: returned id is different",
+ )
+ return
+ }
+
+ if *waitResp.Owner != data.Owner.ValueString() {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ "Database creation waiting: returned owner is different",
+ )
+ return
+ }
+
+ if *waitResp.Name != data.Name.ValueString() {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ createErr,
+ "Database creation waiting: returned name is different",
+ )
+ return
+ }
+
+ // Map response body to schema
+ err = mapResourceFields(waitResp, &data, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating database",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Set state to fully populated data
+ resp.Diagnostics.Append(resp.State.Set(ctx, data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Save data into Terraform state
+
+ tflog.Info(ctx, "sqlserverflexbeta.Database created")
+}
+
+func (r *databaseResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
+ var model resourceModel
+ diags := req.State.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ region := model.Region.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ databaseName := model.DatabaseName.ValueString()
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "database_name", databaseName)
+
+ databaseResp, err := r.client.GetDatabaseRequest(ctx, projectId, region, instanceId, databaseName).Execute()
+ if err != nil {
+ oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
+ if (ok && oapiErr.StatusCode == http.StatusNotFound) || errors.Is(err, errDatabaseNotFound) {
+ resp.State.RemoveResource(ctx)
+ return
+ }
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading database", fmt.Sprintf("Calling API: %v", err))
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ // Map response body to schema
+ err = mapResourceFields(databaseResp, &model, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading database",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Save identity into Terraform state
+ identity := DatabaseResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ DatabaseName: types.StringValue(databaseName),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Set refreshed state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &model)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ tflog.Info(ctx, "sqlserverflexbeta.Database read")
+}
+
+func (r *databaseResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) {
+ // TODO: Check update api endpoint - not available at the moment, so return an error for now
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating database", "there is no way to update a database")
+}
+
+func (r *databaseResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
+ // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
+ diags := req.State.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ projectId := model.ProjectId.ValueString()
+ region := model.Region.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ databaseName := model.DatabaseName.ValueString()
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "database_name", databaseName)
+
+ // Delete existing record set
+ err := r.client.DeleteDatabaseRequestExecute(ctx, projectId, region, instanceId, databaseName)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error deleting database",
+ fmt.Sprintf(
+ "Calling API: %v\nname: %s, region: %s, instanceId: %s", err, databaseName, region, instanceId,
+ ),
+ )
+ return
+ }
+
+ // TODO: wait handler??
+
+ ctx = core.LogResponse(ctx)
+ resp.State.RemoveResource(ctx)
+
+ tflog.Info(ctx, "sqlserverflexbeta.Database deleted")
+}
+
+// ModifyPlan implements resource.ResourceWithModifyPlan.
+// Use the modifier to set the effective region in the current plan.
+func (r *databaseResource) ModifyPlan(
+ ctx context.Context,
+ req resource.ModifyPlanRequest,
+ resp *resource.ModifyPlanResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ // skip initial empty configuration to avoid follow-up errors
+ if req.Config.Raw.IsNull() {
+ return
+ }
+
+ var configModel resourceModel
+ resp.Diagnostics.Append(req.Config.Get(ctx, &configModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ var planModel resourceModel
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ var identityModel DatabaseResourceIdentityModel
+ identityModel.ProjectID = planModel.ProjectId
+ identityModel.Region = planModel.Region
+
+ if !planModel.InstanceId.IsNull() && !planModel.InstanceId.IsUnknown() {
+ identityModel.InstanceID = planModel.InstanceId
+ }
+
+ if !planModel.Name.IsNull() && !planModel.Name.IsUnknown() {
+ identityModel.DatabaseName = planModel.Name
+ }
+
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identityModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+}
+
+// ImportState imports a resource into the Terraform state on success.
+// The expected format of the resource import identifier is: project_id,zone_id,record_set_id
+func (r *databaseResource) ImportState(
+ ctx context.Context,
+ req resource.ImportStateRequest,
+ resp *resource.ImportStateResponse,
+) {
+ ctx = core.InitProviderContext(ctx)
+
+ if req.ID != "" {
+ idParts := strings.Split(req.ID, core.Separator)
+
+ if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" {
+ core.LogAndAddError(
+ ctx, &resp.Diagnostics,
+ "Error importing database",
+ fmt.Sprintf(
+ "Expected import identifier with format [project_id],[region],[instance_id],[database_name] Got: %q",
+ req.ID,
+ ),
+ )
+ return
+ }
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("database_name"), idParts[3])...)
+
+ var identityData DatabaseResourceIdentityModel
+ identityData.ProjectID = types.StringValue(idParts[0])
+ identityData.Region = types.StringValue(idParts[1])
+ identityData.InstanceID = types.StringValue(idParts[2])
+ identityData.DatabaseName = types.StringValue(idParts[3])
+
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ tflog.Info(ctx, "Sqlserverflexbeta database state imported")
+ return
+ }
+
+ // If no ID is provided, attempt to read identity attributes from the import configuration
+ var identityData DatabaseResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ instanceId := identityData.InstanceID.ValueString()
+ databaseName := identityData.DatabaseName.ValueString()
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), projectId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), region)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), instanceId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("database_name"), databaseName)...)
+
+ tflog.Info(ctx, "Sqlserverflexbeta database state imported")
+}
+
+// extractIdentityData extracts essential identifiers from the resource model, falling back to the identity mode
diff --git a/stackit/internal/services/sqlserverflexbeta/database/resources_gen/database_resource_gen.go b/stackit/internal/services/sqlserverflexbeta/database/resources_gen/database_resource_gen.go
new file mode 100644
index 00000000..dccae0c4
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/database/resources_gen/database_resource_gen.go
@@ -0,0 +1,99 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexbeta
+
+import (
+ "context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+)
+
+func DatabaseResourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "collation": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ MarkdownDescription: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ },
+ "collation_name": schema.StringAttribute{
+ Computed: true,
+ Description: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ MarkdownDescription: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
+ },
+ "compatibility": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "CompatibilityLevel of the Database.",
+ MarkdownDescription: "CompatibilityLevel of the Database.",
+ },
+ "compatibility_level": schema.Int64Attribute{
+ Computed: true,
+ Description: "CompatibilityLevel of the Database.",
+ MarkdownDescription: "CompatibilityLevel of the Database.",
+ },
+ "database_name": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The id of the database.",
+ MarkdownDescription: "The id of the database.",
+ },
+ "instance_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "name": schema.StringAttribute{
+ Required: true,
+ Description: "The name of the database.",
+ MarkdownDescription: "The name of the database.",
+ },
+ "owner": schema.StringAttribute{
+ Required: true,
+ Description: "The owner of the database.",
+ MarkdownDescription: "The owner of the database.",
+ },
+ "project_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type DatabaseModel struct {
+ Collation types.String `tfsdk:"collation"`
+ CollationName types.String `tfsdk:"collation_name"`
+ Compatibility types.Int64 `tfsdk:"compatibility"`
+ CompatibilityLevel types.Int64 `tfsdk:"compatibility_level"`
+ DatabaseName types.String `tfsdk:"database_name"`
+ Id types.Int64 `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Name types.String `tfsdk:"name"`
+ Owner types.String `tfsdk:"owner"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/flavor/datasource.go b/stackit/internal/services/sqlserverflexbeta/flavor/datasource.go
new file mode 100644
index 00000000..06e055f2
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/flavor/datasource.go
@@ -0,0 +1,355 @@
+package sqlserverFlexBetaFlavor
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexbetaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+ sqlserverflexbetaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/flavor/datasources_gen"
+)
+
+// Ensure the implementation satisfies the expected interfaces.
+var (
+ _ datasource.DataSource = &flavorDataSource{}
+ _ datasource.DataSourceWithConfigure = &flavorDataSource{}
+)
+
+type FlavorModel struct {
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ StorageClass types.String `tfsdk:"storage_class"`
+ Cpu types.Int64 `tfsdk:"cpu"`
+ Description types.String `tfsdk:"description"`
+ Id types.String `tfsdk:"id"`
+ FlavorId types.String `tfsdk:"flavor_id"`
+ MaxGb types.Int64 `tfsdk:"max_gb"`
+ Memory types.Int64 `tfsdk:"ram"`
+ MinGb types.Int64 `tfsdk:"min_gb"`
+ NodeType types.String `tfsdk:"node_type"`
+ StorageClasses types.List `tfsdk:"storage_classes"`
+}
+
+// NewFlavorDataSource is a helper function to simplify the provider implementation.
+func NewFlavorDataSource() datasource.DataSource {
+ return &flavorDataSource{}
+}
+
+// flavorDataSource is the data source implementation.
+type flavorDataSource struct {
+ client *sqlserverflexbetaPkg.APIClient
+ providerData core.ProviderData
+}
+
+// Metadata returns the data source type name.
+func (r *flavorDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexbeta_flavor"
+}
+
+// Configure adds the provider configured client to the data source.
+func (r *flavorDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
+ var ok bool
+ r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(r.providerData.RoundTripper),
+ utils.UserAgentConfigOption(r.providerData.Version),
+ }
+ if r.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(r.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithRegion(r.providerData.GetRegion()),
+ )
+ }
+ apiClient, err := sqlserverflexbetaPkg.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ r.client = apiClient
+ tflog.Info(ctx, "SQL Server Flex instance client configured")
+}
+
+func (r *flavorDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The project ID of the flavor.",
+ MarkdownDescription: "The project ID of the flavor.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region of the flavor.",
+ MarkdownDescription: "The region of the flavor.",
+ },
+ "cpu": schema.Int64Attribute{
+ Required: true,
+ Description: "The cpu count of the instance.",
+ MarkdownDescription: "The cpu count of the instance.",
+ },
+ "ram": schema.Int64Attribute{
+ Required: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "storage_class": schema.StringAttribute{
+ Required: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "node_type": schema.StringAttribute{
+ Required: true,
+ Description: "defines the nodeType it can be either single or HA",
+ MarkdownDescription: "defines the nodeType it can be either single or HA",
+ },
+ "flavor_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "description": schema.StringAttribute{
+ Computed: true,
+ Description: "The flavor description.",
+ MarkdownDescription: "The flavor description.",
+ },
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "max_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ "min_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "minimum storage which is required to order in Gigabyte.",
+ MarkdownDescription: "minimum storage which is required to order in Gigabyte.",
+ },
+ "storage_classes": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Computed: true,
+ },
+ "max_io_per_sec": schema.Int64Attribute{
+ Computed: true,
+ },
+ "max_through_in_mb": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: sqlserverflexbetaGen.StorageClassesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: sqlserverflexbetaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ },
+ //Attributes: map[string]schema.Attribute{
+ // "project_id": schema.StringAttribute{
+ // Required: true,
+ // Description: "The cpu count of the instance.",
+ // MarkdownDescription: "The cpu count of the instance.",
+ // },
+ // "region": schema.StringAttribute{
+ // Required: true,
+ // Description: "The flavor description.",
+ // MarkdownDescription: "The flavor description.",
+ // },
+ // "cpu": schema.Int64Attribute{
+ // Required: true,
+ // Description: "The cpu count of the instance.",
+ // MarkdownDescription: "The cpu count of the instance.",
+ // },
+ // "ram": schema.Int64Attribute{
+ // Required: true,
+ // Description: "The memory of the instance in Gibibyte.",
+ // MarkdownDescription: "The memory of the instance in Gibibyte.",
+ // },
+ // "storage_class": schema.StringAttribute{
+ // Required: true,
+ // Description: "The memory of the instance in Gibibyte.",
+ // MarkdownDescription: "The memory of the instance in Gibibyte.",
+ // },
+ // "description": schema.StringAttribute{
+ // Computed: true,
+ // Description: "The flavor description.",
+ // MarkdownDescription: "The flavor description.",
+ // },
+ // "id": schema.StringAttribute{
+ // Computed: true,
+ // Description: "The terraform id of the instance flavor.",
+ // MarkdownDescription: "The terraform id of the instance flavor.",
+ // },
+ // "flavor_id": schema.StringAttribute{
+ // Computed: true,
+ // Description: "The flavor id of the instance flavor.",
+ // MarkdownDescription: "The flavor id of the instance flavor.",
+ // },
+ // "max_gb": schema.Int64Attribute{
+ // Computed: true,
+ // Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ // MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ // },
+ // "min_gb": schema.Int64Attribute{
+ // Computed: true,
+ // Description: "minimum storage which is required to order in Gigabyte.",
+ // MarkdownDescription: "minimum storage which is required to order in Gigabyte.",
+ // },
+ // "node_type": schema.StringAttribute{
+ // Required: true,
+ // Description: "defines the nodeType it can be either single or replica",
+ // MarkdownDescription: "defines the nodeType it can be either single or replica",
+ // },
+ // "storage_classes": schema.ListNestedAttribute{
+ // Computed: true,
+ // NestedObject: schema.NestedAttributeObject{
+ // Attributes: map[string]schema.Attribute{
+ // "class": schema.StringAttribute{
+ // Computed: true,
+ // },
+ // "max_io_per_sec": schema.Int64Attribute{
+ // Computed: true,
+ // },
+ // "max_through_in_mb": schema.Int64Attribute{
+ // Computed: true,
+ // },
+ // },
+ // CustomType: sqlserverflexalphaGen.StorageClassesType{
+ // ObjectType: types.ObjectType{
+ // AttrTypes: sqlserverflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ // },
+ // },
+ // },
+ // },
+ // },
+ }
+}
+
+func (r *flavorDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var model FlavorModel
+ diags := req.Config.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ region := r.providerData.GetRegionWithOverride(model.Region)
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ flavors, err := getAllFlavors(ctx, r.client, projectId, region)
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading flavors", fmt.Sprintf("getAllFlavors: %v", err))
+ return
+ }
+
+ var foundFlavors []sqlserverflexbetaPkg.ListFlavors
+ for _, flavor := range flavors {
+ if model.Cpu.ValueInt64() != *flavor.Cpu {
+ continue
+ }
+ if model.Memory.ValueInt64() != *flavor.Memory {
+ continue
+ }
+ if model.NodeType.ValueString() != *flavor.NodeType {
+ continue
+ }
+ for _, sc := range *flavor.StorageClasses {
+ if model.StorageClass.ValueString() != *sc.Class {
+ continue
+ }
+ foundFlavors = append(foundFlavors, flavor)
+ }
+ }
+ if len(foundFlavors) == 0 {
+ resp.Diagnostics.AddError("get flavor", "could not find requested flavor")
+ return
+ }
+ if len(foundFlavors) > 1 {
+ resp.Diagnostics.AddError("get flavor", "found too many matching flavors")
+ return
+ }
+
+ f := foundFlavors[0]
+ model.Description = types.StringValue(*f.Description)
+ model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), region, *f.Id)
+ model.FlavorId = types.StringValue(*f.Id)
+ model.MaxGb = types.Int64Value(*f.MaxGB)
+ model.MinGb = types.Int64Value(*f.MinGB)
+
+ if f.StorageClasses == nil {
+ model.StorageClasses = types.ListNull(sqlserverflexbetaGen.StorageClassesType{
+ ObjectType: basetypes.ObjectType{
+ AttrTypes: sqlserverflexbetaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ })
+ } else {
+ var scList []attr.Value
+ for _, sc := range *f.StorageClasses {
+ scList = append(
+ scList,
+ sqlserverflexbetaGen.NewStorageClassesValueMust(
+ sqlserverflexbetaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "class": types.StringValue(*sc.Class),
+ "max_io_per_sec": types.Int64Value(*sc.MaxIoPerSec),
+ "max_through_in_mb": types.Int64Value(*sc.MaxThroughInMb),
+ },
+ ),
+ )
+ }
+ storageClassesList := types.ListValueMust(
+ sqlserverflexbetaGen.StorageClassesType{
+ ObjectType: basetypes.ObjectType{
+ AttrTypes: sqlserverflexbetaGen.StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ scList,
+ )
+ model.StorageClasses = storageClassesList
+ }
+
+ // Set refreshed state
+ diags = resp.State.Set(ctx, model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ tflog.Info(ctx, "SQL Server Flex flavors read")
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/flavor/datasources_gen/flavor_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/flavor/datasources_gen/flavor_data_source_gen.go
new file mode 100644
index 00000000..a766197e
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/flavor/datasources_gen/flavor_data_source_gen.go
@@ -0,0 +1,1909 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func FlavorDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "flavors": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "cpu": schema.Int64Attribute{
+ Computed: true,
+ Description: "The cpu count of the instance.",
+ MarkdownDescription: "The cpu count of the instance.",
+ },
+ "description": schema.StringAttribute{
+ Computed: true,
+ Description: "The flavor description.",
+ MarkdownDescription: "The flavor description.",
+ },
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "max_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ "memory": schema.Int64Attribute{
+ Computed: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "min_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "minimum storage which is required to order in Gigabyte.",
+ MarkdownDescription: "minimum storage which is required to order in Gigabyte.",
+ },
+ "node_type": schema.StringAttribute{
+ Computed: true,
+ Description: "defines the nodeType it can be either single or HA",
+ MarkdownDescription: "defines the nodeType it can be either single or HA",
+ },
+ "storage_classes": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Computed: true,
+ },
+ "max_io_per_sec": schema.Int64Attribute{
+ Computed: true,
+ },
+ "max_through_in_mb": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: StorageClassesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ },
+ CustomType: FlavorsType{
+ ObjectType: types.ObjectType{
+ AttrTypes: FlavorsValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of flavors available for the project.",
+ MarkdownDescription: "List of flavors available for the project.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the flavors to be returned on each page.",
+ MarkdownDescription: "Sorting of the flavors to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "index.desc",
+ "index.asc",
+ "cpu.desc",
+ "cpu.asc",
+ "flavor_description.asc",
+ "flavor_description.desc",
+ "id.desc",
+ "id.asc",
+ "size_max.desc",
+ "size_max.asc",
+ "ram.desc",
+ "ram.asc",
+ "size_min.desc",
+ "size_min.asc",
+ "storage_class.asc",
+ "storage_class.desc",
+ "node_type.asc",
+ "node_type.desc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type FlavorModel struct {
+ Flavors types.List `tfsdk:"flavors"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = FlavorsType{}
+
+type FlavorsType struct {
+ basetypes.ObjectType
+}
+
+func (t FlavorsType) Equal(o attr.Type) bool {
+ other, ok := o.(FlavorsType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t FlavorsType) String() string {
+ return "FlavorsType"
+}
+
+func (t FlavorsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return nil, diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return nil, diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return nil, diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return nil, diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return nil, diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueNull() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewFlavorsValueUnknown() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewFlavorsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (FlavorsValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, a missing attribute value was detected. "+
+ "A FlavorsValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid FlavorsValue Attribute Type",
+ "While creating a FlavorsValue value, an invalid attribute value was detected. "+
+ "A FlavorsValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, an extra attribute value was detected. "+
+ "A FlavorsValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra FlavorsValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) FlavorsValue {
+ object, diags := NewFlavorsValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewFlavorsValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t FlavorsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewFlavorsValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewFlavorsValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewFlavorsValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewFlavorsValueMust(FlavorsValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t FlavorsType) ValueType(ctx context.Context) attr.Value {
+ return FlavorsValue{}
+}
+
+var _ basetypes.ObjectValuable = FlavorsValue{}
+
+type FlavorsValue struct {
+ Cpu basetypes.Int64Value `tfsdk:"cpu"`
+ Description basetypes.StringValue `tfsdk:"description"`
+ Id basetypes.StringValue `tfsdk:"id"`
+ MaxGb basetypes.Int64Value `tfsdk:"max_gb"`
+ Memory basetypes.Int64Value `tfsdk:"memory"`
+ MinGb basetypes.Int64Value `tfsdk:"min_gb"`
+ NodeType basetypes.StringValue `tfsdk:"node_type"`
+ StorageClasses basetypes.ListValue `tfsdk:"storage_classes"`
+ state attr.ValueState
+}
+
+func (v FlavorsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 8)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["cpu"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["description"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["memory"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["min_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["node_type"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["storage_classes"] = basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ }.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 8)
+
+ val, err = v.Cpu.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["cpu"] = val
+
+ val, err = v.Description.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["description"] = val
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.MaxGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_gb"] = val
+
+ val, err = v.Memory.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["memory"] = val
+
+ val, err = v.MinGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["min_gb"] = val
+
+ val, err = v.NodeType.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["node_type"] = val
+
+ val, err = v.StorageClasses.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["storage_classes"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v FlavorsValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v FlavorsValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v FlavorsValue) String() string {
+ return "FlavorsValue"
+}
+
+func (v FlavorsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ storageClasses := types.ListValueMust(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ v.StorageClasses.Elements(),
+ )
+
+ if v.StorageClasses.IsNull() {
+ storageClasses = types.ListNull(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ if v.StorageClasses.IsUnknown() {
+ storageClasses = types.ListUnknown(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "cpu": v.Cpu,
+ "description": v.Description,
+ "id": v.Id,
+ "max_gb": v.MaxGb,
+ "memory": v.Memory,
+ "min_gb": v.MinGb,
+ "node_type": v.NodeType,
+ "storage_classes": storageClasses,
+ })
+
+ return objVal, diags
+}
+
+func (v FlavorsValue) Equal(o attr.Value) bool {
+ other, ok := o.(FlavorsValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Cpu.Equal(other.Cpu) {
+ return false
+ }
+
+ if !v.Description.Equal(other.Description) {
+ return false
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.MaxGb.Equal(other.MaxGb) {
+ return false
+ }
+
+ if !v.Memory.Equal(other.Memory) {
+ return false
+ }
+
+ if !v.MinGb.Equal(other.MinGb) {
+ return false
+ }
+
+ if !v.NodeType.Equal(other.NodeType) {
+ return false
+ }
+
+ if !v.StorageClasses.Equal(other.StorageClasses) {
+ return false
+ }
+
+ return true
+}
+
+func (v FlavorsValue) Type(ctx context.Context) attr.Type {
+ return FlavorsType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v FlavorsValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageClassesType{}
+
+type StorageClassesType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageClassesType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageClassesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageClassesType) String() string {
+ return "StorageClassesType"
+}
+
+func (t StorageClassesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return nil, diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return nil, diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueNull() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageClassesValueUnknown() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageClassesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageClassesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, a missing attribute value was detected. "+
+ "A StorageClassesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageClassesValue Attribute Type",
+ "While creating a StorageClassesValue value, an invalid attribute value was detected. "+
+ "A StorageClassesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, an extra attribute value was detected. "+
+ "A StorageClassesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageClassesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageClassesValue {
+ object, diags := NewStorageClassesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageClassesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageClassesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageClassesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageClassesValueMust(StorageClassesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageClassesType) ValueType(ctx context.Context) attr.Value {
+ return StorageClassesValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageClassesValue{}
+
+type StorageClassesValue struct {
+ Class basetypes.StringValue `tfsdk:"class"`
+ MaxIoPerSec basetypes.Int64Value `tfsdk:"max_io_per_sec"`
+ MaxThroughInMb basetypes.Int64Value `tfsdk:"max_through_in_mb"`
+ state attr.ValueState
+}
+
+func (v StorageClassesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 3)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_io_per_sec"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["max_through_in_mb"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 3)
+
+ val, err = v.Class.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["class"] = val
+
+ val, err = v.MaxIoPerSec.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_io_per_sec"] = val
+
+ val, err = v.MaxThroughInMb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_through_in_mb"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageClassesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageClassesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageClassesValue) String() string {
+ return "StorageClassesValue"
+}
+
+func (v StorageClassesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "class": v.Class,
+ "max_io_per_sec": v.MaxIoPerSec,
+ "max_through_in_mb": v.MaxThroughInMb,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageClassesValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageClassesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Class.Equal(other.Class) {
+ return false
+ }
+
+ if !v.MaxIoPerSec.Equal(other.MaxIoPerSec) {
+ return false
+ }
+
+ if !v.MaxThroughInMb.Equal(other.MaxThroughInMb) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageClassesValue) Type(ctx context.Context) attr.Type {
+ return StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageClassesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/flavor/functions.go b/stackit/internal/services/sqlserverflexbeta/flavor/functions.go
new file mode 100644
index 00000000..8c06da73
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/flavor/functions.go
@@ -0,0 +1,65 @@
+package sqlserverFlexBetaFlavor
+
+import (
+ "context"
+ "fmt"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+)
+
+type flavorsClientReader interface {
+ GetFlavorsRequest(
+ ctx context.Context,
+ projectId, region string,
+ ) sqlserverflexbeta.ApiGetFlavorsRequestRequest
+}
+
+func getAllFlavors(ctx context.Context, client flavorsClientReader, projectId, region string) (
+ []sqlserverflexbeta.ListFlavors,
+ error,
+) {
+ getAllFilter := func(_ sqlserverflexbeta.ListFlavors) bool { return true }
+ flavorList, err := getFlavorsByFilter(ctx, client, projectId, region, getAllFilter)
+ if err != nil {
+ return nil, err
+ }
+ return flavorList, nil
+}
+
+// getFlavorsByFilter is a helper function to retrieve flavors using a filtern function.
+// Hint: The API does not have a GetFlavors endpoint, only ListFlavors
+func getFlavorsByFilter(
+ ctx context.Context,
+ client flavorsClientReader,
+ projectId, region string,
+ filter func(db sqlserverflexbeta.ListFlavors) bool,
+) ([]sqlserverflexbeta.ListFlavors, error) {
+ if projectId == "" || region == "" {
+ return nil, fmt.Errorf("listing sqlserverflexbeta flavors: projectId and region are required")
+ }
+
+ const pageSize = 25
+
+ var result = make([]sqlserverflexbeta.ListFlavors, 0)
+
+ for page := int64(1); ; page++ {
+ res, err := client.GetFlavorsRequest(ctx, projectId, region).
+ Page(page).Size(pageSize).Sort(sqlserverflexbeta.FLAVORSORT_INDEX_ASC).Execute()
+ if err != nil {
+ return nil, fmt.Errorf("requesting flavors list (page %d): %w", page, err)
+ }
+
+ // If the API returns no flavors, we have reached the end of the list.
+ if res.Flavors == nil || len(*res.Flavors) == 0 {
+ break
+ }
+
+ for _, flavor := range *res.Flavors {
+ if filter(flavor) {
+ result = append(result, flavor)
+ }
+ }
+ }
+
+ return result, nil
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/flavor/functions_test.go b/stackit/internal/services/sqlserverflexbeta/flavor/functions_test.go
new file mode 100644
index 00000000..fb666253
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/flavor/functions_test.go
@@ -0,0 +1,135 @@
+package sqlserverFlexBetaFlavor
+
+import (
+ "context"
+ "testing"
+
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+)
+
+type mockRequest struct {
+ executeFunc func() (*sqlserverflexbeta.GetFlavorsResponse, error)
+}
+
+func (m *mockRequest) Page(_ int64) sqlserverflexbeta.ApiGetFlavorsRequestRequest { return m }
+func (m *mockRequest) Size(_ int64) sqlserverflexbeta.ApiGetFlavorsRequestRequest { return m }
+func (m *mockRequest) Sort(_ sqlserverflexbeta.FlavorSort) sqlserverflexbeta.ApiGetFlavorsRequestRequest {
+ return m
+}
+func (m *mockRequest) Execute() (*sqlserverflexbeta.GetFlavorsResponse, error) {
+ return m.executeFunc()
+}
+
+type mockFlavorsClient struct {
+ executeRequest func() sqlserverflexbeta.ApiGetFlavorsRequestRequest
+}
+
+func (m *mockFlavorsClient) GetFlavorsRequest(_ context.Context, _, _ string) sqlserverflexbeta.ApiGetFlavorsRequestRequest {
+ return m.executeRequest()
+}
+
+var mockResp = func(page int64) (*sqlserverflexbeta.GetFlavorsResponse, error) {
+ if page == 1 {
+ return &sqlserverflexbeta.GetFlavorsResponse{
+ Flavors: &[]sqlserverflexbeta.ListFlavors{
+ {Id: utils.Ptr("flavor-1"), Description: utils.Ptr("first")},
+ {Id: utils.Ptr("flavor-2"), Description: utils.Ptr("second")},
+ },
+ }, nil
+ }
+ if page == 2 {
+ return &sqlserverflexbeta.GetFlavorsResponse{
+ Flavors: &[]sqlserverflexbeta.ListFlavors{
+ {Id: utils.Ptr("flavor-3"), Description: utils.Ptr("three")},
+ },
+ }, nil
+ }
+
+ return &sqlserverflexbeta.GetFlavorsResponse{
+ Flavors: &[]sqlserverflexbeta.ListFlavors{},
+ }, nil
+}
+
+func TestGetFlavorsByFilter(t *testing.T) {
+ tests := []struct {
+ description string
+ projectId string
+ region string
+ mockErr error
+ filter func(sqlserverflexbeta.ListFlavors) bool
+ wantCount int
+ wantErr bool
+ }{
+ {
+ description: "Success - Get all flavors (2 pages)",
+ projectId: "pid", region: "reg",
+ filter: func(_ sqlserverflexbeta.ListFlavors) bool { return true },
+ wantCount: 3,
+ wantErr: false,
+ },
+ {
+ description: "Success - Filter flavors by description",
+ projectId: "pid", region: "reg",
+ filter: func(f sqlserverflexbeta.ListFlavors) bool { return *f.Description == "first" },
+ wantCount: 1,
+ wantErr: false,
+ },
+ {
+ description: "Error - Missing parameters",
+ projectId: "", region: "reg",
+ wantErr: true,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ var currentPage int64
+ client := &mockFlavorsClient{
+ executeRequest: func() sqlserverflexbeta.ApiGetFlavorsRequestRequest {
+ return &mockRequest{
+ executeFunc: func() (*sqlserverflexbeta.GetFlavorsResponse, error) {
+ currentPage++
+ return mockResp(currentPage)
+ },
+ }
+ },
+ }
+ actual, err := getFlavorsByFilter(context.Background(), client, tt.projectId, tt.region, tt.filter)
+
+ if (err != nil) != tt.wantErr {
+ t.Errorf("getFlavorsByFilter() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+
+ if !tt.wantErr && len(actual) != tt.wantCount {
+ t.Errorf("getFlavorsByFilter() got %d flavors, want %d", len(actual), tt.wantCount)
+ }
+ },
+ )
+ }
+}
+
+func TestGetAllFlavors(t *testing.T) {
+ var currentPage int64
+ client := &mockFlavorsClient{
+ executeRequest: func() sqlserverflexbeta.ApiGetFlavorsRequestRequest {
+ return &mockRequest{
+ executeFunc: func() (*sqlserverflexbeta.GetFlavorsResponse, error) {
+ currentPage++
+ return mockResp(currentPage)
+ },
+ }
+ },
+ }
+
+ res, err := getAllFlavors(context.Background(), client, "pid", "reg")
+ if err != nil {
+ t.Errorf("getAllFlavors() unexpected error: %v", err)
+ }
+ if len(res) != 3 {
+ t.Errorf("getAllFlavors() expected 3 flavor, got %d", len(res))
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/flavors/datasource.go b/stackit/internal/services/sqlserverflexbeta/flavors/datasource.go
new file mode 100644
index 00000000..b6be1dd4
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/flavors/datasource.go
@@ -0,0 +1,156 @@
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexbetaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+
+ sqlserverflexbetaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/flavors/datasources_gen"
+)
+
+var _ datasource.DataSource = (*flavorsDataSource)(nil)
+
+const errorPrefix = "[Sqlserverflexbeta - Flavors]"
+
+func NewFlavorsDataSource() datasource.DataSource {
+ return &flavorsDataSource{}
+}
+
+type dataSourceModel struct {
+ sqlserverflexbetaGen.FlavorsModel
+ TerraformId types.String `tfsdk:"id"`
+}
+
+type flavorsDataSource struct {
+ client *sqlserverflexbetaPkg.APIClient
+ providerData core.ProviderData
+}
+
+func (d *flavorsDataSource) Metadata(
+ _ context.Context,
+ req datasource.MetadataRequest,
+ resp *datasource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexbeta_flavors"
+}
+
+func (d *flavorsDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = sqlserverflexbetaGen.FlavorsDataSourceSchema(ctx)
+ resp.Schema.Attributes["id"] = schema.StringAttribute{
+ Computed: true,
+ Description: "The terraform internal identifier.",
+ MarkdownDescription: "The terraform internal identifier.",
+ }
+}
+
+// Configure adds the provider configured client to the data source.
+func (d *flavorsDataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
+ var ok bool
+ d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(d.providerData.RoundTripper),
+ utils.UserAgentConfigOption(d.providerData.Version),
+ }
+ if d.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(d.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithRegion(d.providerData.GetRegion()),
+ )
+ }
+ apiClient, err := sqlserverflexbetaPkg.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ d.client = apiClient
+ tflog.Info(ctx, fmt.Sprintf("%s client configured", errorPrefix))
+}
+
+func (d *flavorsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var data dataSourceModel
+
+ // Read Terraform configuration data into the model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := data.ProjectId.ValueString()
+ region := d.providerData.GetRegionWithOverride(data.Region)
+ // TODO: implement right identifier for flavors
+ flavorsId := data.Flavors
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ // TODO: implement needed fields
+ ctx = tflog.SetField(ctx, "flavors_id", flavorsId)
+
+ // TODO: refactor to correct implementation
+ _, err := d.client.GetFlavorsRequest(ctx, projectId, region).Execute()
+ if err != nil {
+ utils.LogError(
+ ctx,
+ &resp.Diagnostics,
+ err,
+ "Reading flavors",
+ fmt.Sprintf("flavors with ID %q does not exist in project %q.", flavorsId, projectId),
+ map[int]string{
+ http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId),
+ },
+ )
+ resp.State.RemoveResource(ctx)
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ // TODO: refactor to correct implementation of internal tf id
+ data.TerraformId = utils.BuildInternalTerraformId(projectId, region)
+
+ // TODO: fill remaining fields
+ // data.Flavors = types.Sometype(apiResponse.GetFlavors())
+ // data.Page = types.Sometype(apiResponse.GetPage())
+ // data.Pagination = types.Sometype(apiResponse.GetPagination())
+ // data.ProjectId = types.Sometype(apiResponse.GetProjectId())
+ // data.Region = types.Sometype(apiResponse.GetRegion())
+ // data.Size = types.Sometype(apiResponse.GetSize())
+ // data.Sort = types.Sometype(apiResponse.GetSort())// Save data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+
+ tflog.Info(ctx, fmt.Sprintf("%s read successful", errorPrefix))
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/flavors/datasources_gen/flavors_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/flavors/datasources_gen/flavors_data_source_gen.go
new file mode 100644
index 00000000..a9d35ba1
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/flavors/datasources_gen/flavors_data_source_gen.go
@@ -0,0 +1,1909 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func FlavorsDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "flavors": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "cpu": schema.Int64Attribute{
+ Computed: true,
+ Description: "The cpu count of the instance.",
+ MarkdownDescription: "The cpu count of the instance.",
+ },
+ "description": schema.StringAttribute{
+ Computed: true,
+ Description: "The flavor description.",
+ MarkdownDescription: "The flavor description.",
+ },
+ "tf_original_api_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "max_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ "memory": schema.Int64Attribute{
+ Computed: true,
+ Description: "The memory of the instance in Gibibyte.",
+ MarkdownDescription: "The memory of the instance in Gibibyte.",
+ },
+ "min_gb": schema.Int64Attribute{
+ Computed: true,
+ Description: "minimum storage which is required to order in Gigabyte.",
+ MarkdownDescription: "minimum storage which is required to order in Gigabyte.",
+ },
+ "node_type": schema.StringAttribute{
+ Computed: true,
+ Description: "defines the nodeType it can be either single or HA",
+ MarkdownDescription: "defines the nodeType it can be either single or HA",
+ },
+ "storage_classes": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Computed: true,
+ },
+ "max_io_per_sec": schema.Int64Attribute{
+ Computed: true,
+ },
+ "max_through_in_mb": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: StorageClassesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.",
+ },
+ },
+ CustomType: FlavorsType{
+ ObjectType: types.ObjectType{
+ AttrTypes: FlavorsValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of flavors available for the project.",
+ MarkdownDescription: "List of flavors available for the project.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the flavors to be returned on each page.",
+ MarkdownDescription: "Sorting of the flavors to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "index.desc",
+ "index.asc",
+ "cpu.desc",
+ "cpu.asc",
+ "flavor_description.asc",
+ "flavor_description.desc",
+ "id.desc",
+ "id.asc",
+ "size_max.desc",
+ "size_max.asc",
+ "ram.desc",
+ "ram.asc",
+ "size_min.desc",
+ "size_min.asc",
+ "storage_class.asc",
+ "storage_class.desc",
+ "node_type.asc",
+ "node_type.desc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type FlavorsModel struct {
+ Flavors types.List `tfsdk:"flavors"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = FlavorsType{}
+
+type FlavorsType struct {
+ basetypes.ObjectType
+}
+
+func (t FlavorsType) Equal(o attr.Type) bool {
+ other, ok := o.(FlavorsType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t FlavorsType) String() string {
+ return "FlavorsType"
+}
+
+func (t FlavorsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return nil, diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return nil, diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return nil, diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return nil, diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return nil, diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return nil, diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueNull() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewFlavorsValueUnknown() FlavorsValue {
+ return FlavorsValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewFlavorsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (FlavorsValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, a missing attribute value was detected. "+
+ "A FlavorsValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid FlavorsValue Attribute Type",
+ "While creating a FlavorsValue value, an invalid attribute value was detected. "+
+ "A FlavorsValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("FlavorsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra FlavorsValue Attribute Value",
+ "While creating a FlavorsValue value, an extra attribute value was detected. "+
+ "A FlavorsValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra FlavorsValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuAttribute, ok := attributes["cpu"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `cpu is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ cpuVal, ok := cpuAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`cpu expected to be basetypes.Int64Value, was: %T`, cpuAttribute))
+ }
+
+ descriptionAttribute, ok := attributes["description"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `description is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ descriptionVal, ok := descriptionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute))
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ maxGbAttribute, ok := attributes["max_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ maxGbVal, ok := maxGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_gb expected to be basetypes.Int64Value, was: %T`, maxGbAttribute))
+ }
+
+ memoryAttribute, ok := attributes["memory"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `memory is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ memoryVal, ok := memoryAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`memory expected to be basetypes.Int64Value, was: %T`, memoryAttribute))
+ }
+
+ minGbAttribute, ok := attributes["min_gb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `min_gb is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ minGbVal, ok := minGbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`min_gb expected to be basetypes.Int64Value, was: %T`, minGbAttribute))
+ }
+
+ nodeTypeAttribute, ok := attributes["node_type"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `node_type is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ nodeTypeVal, ok := nodeTypeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`node_type expected to be basetypes.StringValue, was: %T`, nodeTypeAttribute))
+ }
+
+ storageClassesAttribute, ok := attributes["storage_classes"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `storage_classes is missing from object`)
+
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ storageClassesVal, ok := storageClassesAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`storage_classes expected to be basetypes.ListValue, was: %T`, storageClassesAttribute))
+ }
+
+ if diags.HasError() {
+ return NewFlavorsValueUnknown(), diags
+ }
+
+ return FlavorsValue{
+ Cpu: cpuVal,
+ Description: descriptionVal,
+ Id: idVal,
+ MaxGb: maxGbVal,
+ Memory: memoryVal,
+ MinGb: minGbVal,
+ NodeType: nodeTypeVal,
+ StorageClasses: storageClassesVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewFlavorsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) FlavorsValue {
+ object, diags := NewFlavorsValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewFlavorsValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t FlavorsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewFlavorsValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewFlavorsValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewFlavorsValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewFlavorsValueMust(FlavorsValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t FlavorsType) ValueType(ctx context.Context) attr.Value {
+ return FlavorsValue{}
+}
+
+var _ basetypes.ObjectValuable = FlavorsValue{}
+
+type FlavorsValue struct {
+ Cpu basetypes.Int64Value `tfsdk:"cpu"`
+ Description basetypes.StringValue `tfsdk:"description"`
+ Id basetypes.StringValue `tfsdk:"id"`
+ MaxGb basetypes.Int64Value `tfsdk:"max_gb"`
+ Memory basetypes.Int64Value `tfsdk:"memory"`
+ MinGb basetypes.Int64Value `tfsdk:"min_gb"`
+ NodeType basetypes.StringValue `tfsdk:"node_type"`
+ StorageClasses basetypes.ListValue `tfsdk:"storage_classes"`
+ state attr.ValueState
+}
+
+func (v FlavorsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 8)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["cpu"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["description"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["memory"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["min_gb"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["node_type"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["storage_classes"] = basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ }.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 8)
+
+ val, err = v.Cpu.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["cpu"] = val
+
+ val, err = v.Description.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["description"] = val
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.MaxGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_gb"] = val
+
+ val, err = v.Memory.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["memory"] = val
+
+ val, err = v.MinGb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["min_gb"] = val
+
+ val, err = v.NodeType.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["node_type"] = val
+
+ val, err = v.StorageClasses.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["storage_classes"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v FlavorsValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v FlavorsValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v FlavorsValue) String() string {
+ return "FlavorsValue"
+}
+
+func (v FlavorsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ storageClasses := types.ListValueMust(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ v.StorageClasses.Elements(),
+ )
+
+ if v.StorageClasses.IsNull() {
+ storageClasses = types.ListNull(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ if v.StorageClasses.IsUnknown() {
+ storageClasses = types.ListUnknown(
+ StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: StorageClassesValue{}.AttributeTypes(ctx),
+ },
+ },
+ )
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "cpu": v.Cpu,
+ "description": v.Description,
+ "id": v.Id,
+ "max_gb": v.MaxGb,
+ "memory": v.Memory,
+ "min_gb": v.MinGb,
+ "node_type": v.NodeType,
+ "storage_classes": storageClasses,
+ })
+
+ return objVal, diags
+}
+
+func (v FlavorsValue) Equal(o attr.Value) bool {
+ other, ok := o.(FlavorsValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Cpu.Equal(other.Cpu) {
+ return false
+ }
+
+ if !v.Description.Equal(other.Description) {
+ return false
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.MaxGb.Equal(other.MaxGb) {
+ return false
+ }
+
+ if !v.Memory.Equal(other.Memory) {
+ return false
+ }
+
+ if !v.MinGb.Equal(other.MinGb) {
+ return false
+ }
+
+ if !v.NodeType.Equal(other.NodeType) {
+ return false
+ }
+
+ if !v.StorageClasses.Equal(other.StorageClasses) {
+ return false
+ }
+
+ return true
+}
+
+func (v FlavorsValue) Type(ctx context.Context) attr.Type {
+ return FlavorsType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v FlavorsValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "cpu": basetypes.Int64Type{},
+ "description": basetypes.StringType{},
+ "id": basetypes.StringType{},
+ "max_gb": basetypes.Int64Type{},
+ "memory": basetypes.Int64Type{},
+ "min_gb": basetypes.Int64Type{},
+ "node_type": basetypes.StringType{},
+ "storage_classes": basetypes.ListType{
+ ElemType: StorageClassesValue{}.Type(ctx),
+ },
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageClassesType{}
+
+type StorageClassesType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageClassesType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageClassesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageClassesType) String() string {
+ return "StorageClassesType"
+}
+
+func (t StorageClassesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return nil, diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return nil, diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return nil, diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueNull() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageClassesValueUnknown() StorageClassesValue {
+ return StorageClassesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageClassesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageClassesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, a missing attribute value was detected. "+
+ "A StorageClassesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageClassesValue Attribute Type",
+ "While creating a StorageClassesValue value, an invalid attribute value was detected. "+
+ "A StorageClassesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageClassesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageClassesValue Attribute Value",
+ "While creating a StorageClassesValue value, an extra attribute value was detected. "+
+ "A StorageClassesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageClassesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ maxIoPerSecAttribute, ok := attributes["max_io_per_sec"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_io_per_sec is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxIoPerSecVal, ok := maxIoPerSecAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_io_per_sec expected to be basetypes.Int64Value, was: %T`, maxIoPerSecAttribute))
+ }
+
+ maxThroughInMbAttribute, ok := attributes["max_through_in_mb"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `max_through_in_mb is missing from object`)
+
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ maxThroughInMbVal, ok := maxThroughInMbAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`max_through_in_mb expected to be basetypes.Int64Value, was: %T`, maxThroughInMbAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageClassesValueUnknown(), diags
+ }
+
+ return StorageClassesValue{
+ Class: classVal,
+ MaxIoPerSec: maxIoPerSecVal,
+ MaxThroughInMb: maxThroughInMbVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageClassesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageClassesValue {
+ object, diags := NewStorageClassesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageClassesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageClassesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageClassesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageClassesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageClassesValueMust(StorageClassesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageClassesType) ValueType(ctx context.Context) attr.Value {
+ return StorageClassesValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageClassesValue{}
+
+type StorageClassesValue struct {
+ Class basetypes.StringValue `tfsdk:"class"`
+ MaxIoPerSec basetypes.Int64Value `tfsdk:"max_io_per_sec"`
+ MaxThroughInMb basetypes.Int64Value `tfsdk:"max_through_in_mb"`
+ state attr.ValueState
+}
+
+func (v StorageClassesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 3)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["max_io_per_sec"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["max_through_in_mb"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 3)
+
+ val, err = v.Class.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["class"] = val
+
+ val, err = v.MaxIoPerSec.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_io_per_sec"] = val
+
+ val, err = v.MaxThroughInMb.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["max_through_in_mb"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageClassesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageClassesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageClassesValue) String() string {
+ return "StorageClassesValue"
+}
+
+func (v StorageClassesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "class": v.Class,
+ "max_io_per_sec": v.MaxIoPerSec,
+ "max_through_in_mb": v.MaxThroughInMb,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageClassesValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageClassesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Class.Equal(other.Class) {
+ return false
+ }
+
+ if !v.MaxIoPerSec.Equal(other.MaxIoPerSec) {
+ return false
+ }
+
+ if !v.MaxThroughInMb.Equal(other.MaxThroughInMb) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageClassesValue) Type(ctx context.Context) attr.Type {
+ return StorageClassesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageClassesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "max_io_per_sec": basetypes.Int64Type{},
+ "max_through_in_mb": basetypes.Int64Type{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/instance/datasource.go b/stackit/internal/services/sqlserverflexbeta/instance/datasource.go
new file mode 100644
index 00000000..2830ac62
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/instance/datasource.go
@@ -0,0 +1,146 @@
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexbetaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+
+ sqlserverflexbetaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen"
+)
+
+var _ datasource.DataSource = (*instanceDataSource)(nil)
+
+const errorPrefix = "[Sqlserverflexbeta - Instance]"
+
+func NewInstanceDataSource() datasource.DataSource {
+ return &instanceDataSource{}
+}
+
+// dataSourceModel maps the data source schema data.
+type dataSourceModel struct {
+ sqlserverflexbetaGen.InstanceModel
+ TerraformID types.String `tfsdk:"id"`
+}
+
+type instanceDataSource struct {
+ client *sqlserverflexbetaPkg.APIClient
+ providerData core.ProviderData
+}
+
+func (d *instanceDataSource) Metadata(
+ _ context.Context,
+ req datasource.MetadataRequest,
+ resp *datasource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexbeta_instance"
+}
+
+func (d *instanceDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = sqlserverflexbetaGen.InstanceDataSourceSchema(ctx)
+}
+
+// Configure adds the provider configured client to the data source.
+func (d *instanceDataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
+ var ok bool
+ d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(d.providerData.RoundTripper),
+ utils.UserAgentConfigOption(d.providerData.Version),
+ }
+ if d.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(d.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithRegion(d.providerData.GetRegion()),
+ )
+ }
+ apiClient, err := sqlserverflexbetaPkg.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ d.client = apiClient
+ tflog.Info(ctx, fmt.Sprintf("%s client configured", errorPrefix))
+}
+
+func (d *instanceDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var data dataSourceModel
+
+ // Read Terraform configuration data into the model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := data.ProjectId.ValueString()
+ region := d.providerData.GetRegionWithOverride(data.Region)
+ instanceId := data.InstanceId.ValueString()
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+
+ instanceResp, err := d.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
+ if err != nil {
+ utils.LogError(
+ ctx,
+ &resp.Diagnostics,
+ err,
+ "Reading instance",
+ fmt.Sprintf("instance with ID %q does not exist in project %q.", instanceId, projectId),
+ map[int]string{
+ http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId),
+ },
+ )
+ resp.State.RemoveResource(ctx)
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ err = mapDataResponseToModel(ctx, instanceResp, &data, resp.Diagnostics)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ fmt.Sprintf("%s Read", errorPrefix),
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Save data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen/instance_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen/instance_data_source_gen.go
new file mode 100644
index 00000000..f3226581
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen/instance_data_source_gen.go
@@ -0,0 +1,1579 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func InstanceDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "backup_schedule": schema.StringAttribute{
+ Computed: true,
+ Description: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ MarkdownDescription: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ },
+ "edition": schema.StringAttribute{
+ Computed: true,
+ Description: "Edition of the MSSQL server instance",
+ MarkdownDescription: "Edition of the MSSQL server instance",
+ },
+ "encryption": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "kek_key_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The key identifier",
+ MarkdownDescription: "The key identifier",
+ },
+ "kek_key_ring_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The keyring identifier",
+ MarkdownDescription: "The keyring identifier",
+ },
+ "kek_key_version": schema.StringAttribute{
+ Computed: true,
+ Description: "The key version",
+ MarkdownDescription: "The key version",
+ },
+ "service_account": schema.StringAttribute{
+ Computed: true,
+ },
+ },
+ CustomType: EncryptionType{
+ ObjectType: types.ObjectType{
+ AttrTypes: EncryptionValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "this defines which key to use for storage encryption",
+ MarkdownDescription: "this defines which key to use for storage encryption",
+ },
+ "flavor_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "tf_original_api_id": schema.StringAttribute{
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "is_deletable": schema.BoolAttribute{
+ Computed: true,
+ Description: "Whether the instance can be deleted or not.",
+ MarkdownDescription: "Whether the instance can be deleted or not.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the instance.",
+ MarkdownDescription: "The name of the instance.",
+ },
+ "network": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "access_scope": schema.StringAttribute{
+ Computed: true,
+ Description: "The network access scope of the instance\n\n⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ MarkdownDescription: "The network access scope of the instance\n\n⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ },
+ "acl": schema.ListAttribute{
+ ElementType: types.StringType,
+ Computed: true,
+ Description: "List of IPV4 cidr.",
+ MarkdownDescription: "List of IPV4 cidr.",
+ },
+ "instance_address": schema.StringAttribute{
+ Computed: true,
+ },
+ "router_address": schema.StringAttribute{
+ Computed: true,
+ },
+ },
+ CustomType: NetworkType{
+ ObjectType: types.ObjectType{
+ AttrTypes: NetworkValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "The access configuration of the instance",
+ MarkdownDescription: "The access configuration of the instance",
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "replicas": schema.Int64Attribute{
+ Computed: true,
+ Description: "How many replicas the instance should have.",
+ MarkdownDescription: "How many replicas the instance should have.",
+ },
+ "retention_days": schema.Int64Attribute{
+ Computed: true,
+ Description: "The days for how long the backup files should be stored before cleaned up. 30 to 365",
+ MarkdownDescription: "The days for how long the backup files should be stored before cleaned up. 30 to 365",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ },
+ "storage": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Computed: true,
+ Description: "The storage class for the storage.",
+ MarkdownDescription: "The storage class for the storage.",
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ Description: "The storage size in Gigabytes.",
+ MarkdownDescription: "The storage size in Gigabytes.",
+ },
+ },
+ CustomType: StorageType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ Description: "The object containing information about the storage size and class.",
+ MarkdownDescription: "The object containing information about the storage size and class.",
+ },
+ "version": schema.StringAttribute{
+ Computed: true,
+ Description: "The sqlserver version used for the instance.",
+ MarkdownDescription: "The sqlserver version used for the instance.",
+ },
+ },
+ }
+}
+
+type InstanceModel struct {
+ BackupSchedule types.String `tfsdk:"backup_schedule"`
+ Edition types.String `tfsdk:"edition"`
+ Encryption EncryptionValue `tfsdk:"encryption"`
+ FlavorId types.String `tfsdk:"flavor_id"`
+ Id types.String `tfsdk:"tf_original_api_id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ IsDeletable types.Bool `tfsdk:"is_deletable"`
+ Name types.String `tfsdk:"name"`
+ Network NetworkValue `tfsdk:"network"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Replicas types.Int64 `tfsdk:"replicas"`
+ RetentionDays types.Int64 `tfsdk:"retention_days"`
+ Status types.String `tfsdk:"status"`
+ Storage StorageValue `tfsdk:"storage"`
+ Version types.String `tfsdk:"version"`
+}
+
+var _ basetypes.ObjectTypable = EncryptionType{}
+
+type EncryptionType struct {
+ basetypes.ObjectType
+}
+
+func (t EncryptionType) Equal(o attr.Type) bool {
+ other, ok := o.(EncryptionType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t EncryptionType) String() string {
+ return "EncryptionType"
+}
+
+func (t EncryptionType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return nil, diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueNull() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewEncryptionValueUnknown() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewEncryptionValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (EncryptionValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, a missing attribute value was detected. "+
+ "A EncryptionValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid EncryptionValue Attribute Type",
+ "While creating a EncryptionValue value, an invalid attribute value was detected. "+
+ "A EncryptionValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, an extra attribute value was detected. "+
+ "A EncryptionValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra EncryptionValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) EncryptionValue {
+ object, diags := NewEncryptionValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewEncryptionValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t EncryptionType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewEncryptionValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewEncryptionValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewEncryptionValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewEncryptionValueMust(EncryptionValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t EncryptionType) ValueType(ctx context.Context) attr.Value {
+ return EncryptionValue{}
+}
+
+var _ basetypes.ObjectValuable = EncryptionValue{}
+
+type EncryptionValue struct {
+ KekKeyId basetypes.StringValue `tfsdk:"kek_key_id"`
+ KekKeyRingId basetypes.StringValue `tfsdk:"kek_key_ring_id"`
+ KekKeyVersion basetypes.StringValue `tfsdk:"kek_key_version"`
+ ServiceAccount basetypes.StringValue `tfsdk:"service_account"`
+ state attr.ValueState
+}
+
+func (v EncryptionValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["kek_key_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_ring_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_version"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["service_account"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.KekKeyId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_id"] = val
+
+ val, err = v.KekKeyRingId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_ring_id"] = val
+
+ val, err = v.KekKeyVersion.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_version"] = val
+
+ val, err = v.ServiceAccount.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["service_account"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v EncryptionValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v EncryptionValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v EncryptionValue) String() string {
+ return "EncryptionValue"
+}
+
+func (v EncryptionValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "kek_key_id": v.KekKeyId,
+ "kek_key_ring_id": v.KekKeyRingId,
+ "kek_key_version": v.KekKeyVersion,
+ "service_account": v.ServiceAccount,
+ })
+
+ return objVal, diags
+}
+
+func (v EncryptionValue) Equal(o attr.Value) bool {
+ other, ok := o.(EncryptionValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.KekKeyId.Equal(other.KekKeyId) {
+ return false
+ }
+
+ if !v.KekKeyRingId.Equal(other.KekKeyRingId) {
+ return false
+ }
+
+ if !v.KekKeyVersion.Equal(other.KekKeyVersion) {
+ return false
+ }
+
+ if !v.ServiceAccount.Equal(other.ServiceAccount) {
+ return false
+ }
+
+ return true
+}
+
+func (v EncryptionValue) Type(ctx context.Context) attr.Type {
+ return EncryptionType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v EncryptionValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = NetworkType{}
+
+type NetworkType struct {
+ basetypes.ObjectType
+}
+
+func (t NetworkType) Equal(o attr.Type) bool {
+ other, ok := o.(NetworkType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t NetworkType) String() string {
+ return "NetworkType"
+}
+
+func (t NetworkType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return nil, diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return nil, diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return nil, diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return nil, diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueNull() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewNetworkValueUnknown() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewNetworkValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (NetworkValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing NetworkValue Attribute Value",
+ "While creating a NetworkValue value, a missing attribute value was detected. "+
+ "A NetworkValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid NetworkValue Attribute Type",
+ "While creating a NetworkValue value, an invalid attribute value was detected. "+
+ "A NetworkValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra NetworkValue Attribute Value",
+ "While creating a NetworkValue value, an extra attribute value was detected. "+
+ "A NetworkValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra NetworkValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) NetworkValue {
+ object, diags := NewNetworkValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewNetworkValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t NetworkType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewNetworkValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewNetworkValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewNetworkValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewNetworkValueMust(NetworkValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t NetworkType) ValueType(ctx context.Context) attr.Value {
+ return NetworkValue{}
+}
+
+var _ basetypes.ObjectValuable = NetworkValue{}
+
+type NetworkValue struct {
+ AccessScope basetypes.StringValue `tfsdk:"access_scope"`
+ Acl basetypes.ListValue `tfsdk:"acl"`
+ InstanceAddress basetypes.StringValue `tfsdk:"instance_address"`
+ RouterAddress basetypes.StringValue `tfsdk:"router_address"`
+ state attr.ValueState
+}
+
+func (v NetworkValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["access_scope"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["acl"] = basetypes.ListType{
+ ElemType: types.StringType,
+ }.TerraformType(ctx)
+ attrTypes["instance_address"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["router_address"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.AccessScope.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["access_scope"] = val
+
+ val, err = v.Acl.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["acl"] = val
+
+ val, err = v.InstanceAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["instance_address"] = val
+
+ val, err = v.RouterAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["router_address"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v NetworkValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v NetworkValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v NetworkValue) String() string {
+ return "NetworkValue"
+}
+
+func (v NetworkValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ var aclVal basetypes.ListValue
+ switch {
+ case v.Acl.IsUnknown():
+ aclVal = types.ListUnknown(types.StringType)
+ case v.Acl.IsNull():
+ aclVal = types.ListNull(types.StringType)
+ default:
+ var d diag.Diagnostics
+ aclVal, d = types.ListValue(types.StringType, v.Acl.Elements())
+ diags.Append(d...)
+ }
+
+ if diags.HasError() {
+ return types.ObjectUnknown(map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }), diags
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "access_scope": v.AccessScope,
+ "acl": aclVal,
+ "instance_address": v.InstanceAddress,
+ "router_address": v.RouterAddress,
+ })
+
+ return objVal, diags
+}
+
+func (v NetworkValue) Equal(o attr.Value) bool {
+ other, ok := o.(NetworkValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.AccessScope.Equal(other.AccessScope) {
+ return false
+ }
+
+ if !v.Acl.Equal(other.Acl) {
+ return false
+ }
+
+ if !v.InstanceAddress.Equal(other.InstanceAddress) {
+ return false
+ }
+
+ if !v.RouterAddress.Equal(other.RouterAddress) {
+ return false
+ }
+
+ return true
+}
+
+func (v NetworkValue) Type(ctx context.Context) attr.Type {
+ return NetworkType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v NetworkValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageType{}
+
+type StorageType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageType) String() string {
+ return "StorageType"
+}
+
+func (t StorageType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return nil, diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageValue{
+ Class: classVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueNull() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageValueUnknown() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageValue Attribute Value",
+ "While creating a StorageValue value, a missing attribute value was detected. "+
+ "A StorageValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageValue Attribute Type",
+ "While creating a StorageValue value, an invalid attribute value was detected. "+
+ "A StorageValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageValue Attribute Value",
+ "While creating a StorageValue value, an extra attribute value was detected. "+
+ "A StorageValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ return StorageValue{
+ Class: classVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageValue {
+ object, diags := NewStorageValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageValueMust(StorageValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageType) ValueType(ctx context.Context) attr.Value {
+ return StorageValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageValue{}
+
+type StorageValue struct {
+ Class basetypes.StringValue `tfsdk:"class"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ state attr.ValueState
+}
+
+func (v StorageValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 2)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 2)
+
+ val, err = v.Class.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["class"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageValue) String() string {
+ return "StorageValue"
+}
+
+func (v StorageValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "class": v.Class,
+ "size": v.Size,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Class.Equal(other.Class) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageValue) Type(ctx context.Context) attr.Type {
+ return StorageType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen/instances_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen/instances_data_source_gen.go
new file mode 100644
index 00000000..04fff1f6
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen/instances_data_source_gen.go
@@ -0,0 +1,1172 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func InstancesDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "instances": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "is_deletable": schema.BoolAttribute{
+ Computed: true,
+ Description: "Whether the instance can be deleted or not.",
+ MarkdownDescription: "Whether the instance can be deleted or not.",
+ },
+ "name": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the instance.",
+ MarkdownDescription: "The name of the instance.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ },
+ },
+ CustomType: InstancesType{
+ ObjectType: types.ObjectType{
+ AttrTypes: InstancesValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of owned instances and their current status.",
+ MarkdownDescription: "List of owned instances and their current status.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the items to be returned on each page.",
+ MarkdownDescription: "Sorting of the items to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "index.desc",
+ "index.asc",
+ "id.desc",
+ "id.asc",
+ "is_deletable.desc",
+ "is_deletable.asc",
+ "name.asc",
+ "name.desc",
+ "status.asc",
+ "status.desc",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type InstancesModel struct {
+ Instances types.List `tfsdk:"instances"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+}
+
+var _ basetypes.ObjectTypable = InstancesType{}
+
+type InstancesType struct {
+ basetypes.ObjectType
+}
+
+func (t InstancesType) Equal(o attr.Type) bool {
+ other, ok := o.(InstancesType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t InstancesType) String() string {
+ return "InstancesType"
+}
+
+func (t InstancesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ isDeletableAttribute, ok := attributes["is_deletable"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `is_deletable is missing from object`)
+
+ return nil, diags
+ }
+
+ isDeletableVal, ok := isDeletableAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`is_deletable expected to be basetypes.BoolValue, was: %T`, isDeletableAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return nil, diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return nil, diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return InstancesValue{
+ Id: idVal,
+ IsDeletable: isDeletableVal,
+ Name: nameVal,
+ Status: statusVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewInstancesValueNull() InstancesValue {
+ return InstancesValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewInstancesValueUnknown() InstancesValue {
+ return InstancesValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewInstancesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (InstancesValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing InstancesValue Attribute Value",
+ "While creating a InstancesValue value, a missing attribute value was detected. "+
+ "A InstancesValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("InstancesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid InstancesValue Attribute Type",
+ "While creating a InstancesValue value, an invalid attribute value was detected. "+
+ "A InstancesValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("InstancesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("InstancesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra InstancesValue Attribute Value",
+ "While creating a InstancesValue value, an extra attribute value was detected. "+
+ "A InstancesValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra InstancesValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewInstancesValueUnknown(), diags
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.StringValue, was: %T`, idAttribute))
+ }
+
+ isDeletableAttribute, ok := attributes["is_deletable"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `is_deletable is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ isDeletableVal, ok := isDeletableAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`is_deletable expected to be basetypes.BoolValue, was: %T`, isDeletableAttribute))
+ }
+
+ nameAttribute, ok := attributes["name"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `name is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ nameVal, ok := nameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return NewInstancesValueUnknown(), diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ if diags.HasError() {
+ return NewInstancesValueUnknown(), diags
+ }
+
+ return InstancesValue{
+ Id: idVal,
+ IsDeletable: isDeletableVal,
+ Name: nameVal,
+ Status: statusVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewInstancesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) InstancesValue {
+ object, diags := NewInstancesValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewInstancesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t InstancesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewInstancesValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewInstancesValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewInstancesValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewInstancesValueMust(InstancesValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t InstancesType) ValueType(ctx context.Context) attr.Value {
+ return InstancesValue{}
+}
+
+var _ basetypes.ObjectValuable = InstancesValue{}
+
+type InstancesValue struct {
+ Id basetypes.StringValue `tfsdk:"id"`
+ IsDeletable basetypes.BoolValue `tfsdk:"is_deletable"`
+ Name basetypes.StringValue `tfsdk:"name"`
+ Status basetypes.StringValue `tfsdk:"status"`
+ state attr.ValueState
+}
+
+func (v InstancesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["is_deletable"] = basetypes.BoolType{}.TerraformType(ctx)
+ attrTypes["name"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["status"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.IsDeletable.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["is_deletable"] = val
+
+ val, err = v.Name.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["name"] = val
+
+ val, err = v.Status.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["status"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v InstancesValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v InstancesValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v InstancesValue) String() string {
+ return "InstancesValue"
+}
+
+func (v InstancesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "id": basetypes.StringType{},
+ "is_deletable": basetypes.BoolType{},
+ "name": basetypes.StringType{},
+ "status": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "id": v.Id,
+ "is_deletable": v.IsDeletable,
+ "name": v.Name,
+ "status": v.Status,
+ })
+
+ return objVal, diags
+}
+
+func (v InstancesValue) Equal(o attr.Value) bool {
+ other, ok := o.(InstancesValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.IsDeletable.Equal(other.IsDeletable) {
+ return false
+ }
+
+ if !v.Name.Equal(other.Name) {
+ return false
+ }
+
+ if !v.Status.Equal(other.Status) {
+ return false
+ }
+
+ return true
+}
+
+func (v InstancesValue) Type(ctx context.Context) attr.Type {
+ return InstancesType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v InstancesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "id": basetypes.StringType{},
+ "is_deletable": basetypes.BoolType{},
+ "name": basetypes.StringType{},
+ "status": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/instance/functions.go b/stackit/internal/services/sqlserverflexbeta/instance/functions.go
new file mode 100644
index 00000000..77791ee6
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/instance/functions.go
@@ -0,0 +1,272 @@
+package sqlserverflexbeta
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "math"
+
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ sqlserverflexbetaDataGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen"
+ sqlserverflexbetaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance/resources_gen"
+)
+
+func mapResponseToModel(
+ ctx context.Context,
+ resp *sqlserverflexbeta.GetInstanceResponse,
+ m *sqlserverflexbetaResGen.InstanceModel,
+ tfDiags diag.Diagnostics,
+) error {
+ m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
+ m.Edition = types.StringValue(string(resp.GetEdition()))
+ m.Encryption = handleEncryption(ctx, m, resp)
+ m.FlavorId = types.StringValue(resp.GetFlavorId())
+ m.Id = types.StringValue(resp.GetId())
+ m.InstanceId = types.StringValue(resp.GetId())
+ m.IsDeletable = types.BoolValue(resp.GetIsDeletable())
+ m.Name = types.StringValue(resp.GetName())
+ netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
+ tfDiags.Append(diags...)
+ if diags.HasError() {
+ return fmt.Errorf(
+ "error converting network acl response value",
+ )
+ }
+ net, diags := sqlserverflexbetaResGen.NewNetworkValue(
+ sqlserverflexbetaResGen.NetworkValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "access_scope": types.StringValue(string(resp.Network.GetAccessScope())),
+ "acl": netAcl,
+ "instance_address": types.StringValue(resp.Network.GetInstanceAddress()),
+ "router_address": types.StringValue(resp.Network.GetRouterAddress()),
+ },
+ )
+ tfDiags.Append(diags...)
+ if diags.HasError() {
+ return errors.New("error converting network response value")
+ }
+ m.Network = net
+ m.Replicas = types.Int64Value(int64(resp.GetReplicas()))
+ m.RetentionDays = types.Int64Value(resp.GetRetentionDays())
+ m.Status = types.StringValue(string(resp.GetStatus()))
+
+ stor, diags := sqlserverflexbetaResGen.NewStorageValue(
+ sqlserverflexbetaResGen.StorageValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "class": types.StringValue(resp.Storage.GetClass()),
+ "size": types.Int64Value(resp.Storage.GetSize()),
+ },
+ )
+ tfDiags.Append(diags...)
+ if diags.HasError() {
+ return fmt.Errorf("error converting storage response value")
+ }
+ m.Storage = stor
+
+ m.Version = types.StringValue(string(resp.GetVersion()))
+ return nil
+}
+
+func mapDataResponseToModel(
+ ctx context.Context,
+ resp *sqlserverflexbeta.GetInstanceResponse,
+ m *dataSourceModel,
+ tfDiags diag.Diagnostics,
+) error {
+ m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
+ m.Edition = types.StringValue(string(resp.GetEdition()))
+ m.Encryption = handleDSEncryption(ctx, m, resp)
+ m.FlavorId = types.StringValue(resp.GetFlavorId())
+ m.Id = types.StringValue(resp.GetId())
+ m.InstanceId = types.StringValue(resp.GetId())
+ m.IsDeletable = types.BoolValue(resp.GetIsDeletable())
+ m.Name = types.StringValue(resp.GetName())
+ netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
+ tfDiags.Append(diags...)
+ if diags.HasError() {
+ return fmt.Errorf(
+ "error converting network acl response value",
+ )
+ }
+ net, diags := sqlserverflexbetaDataGen.NewNetworkValue(
+ sqlserverflexbetaDataGen.NetworkValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "access_scope": types.StringValue(string(resp.Network.GetAccessScope())),
+ "acl": netAcl,
+ "instance_address": types.StringValue(resp.Network.GetInstanceAddress()),
+ "router_address": types.StringValue(resp.Network.GetRouterAddress()),
+ },
+ )
+ tfDiags.Append(diags...)
+ if diags.HasError() {
+ return errors.New("error converting network response value")
+ }
+ m.Network = net
+ m.Replicas = types.Int64Value(int64(resp.GetReplicas()))
+ m.RetentionDays = types.Int64Value(resp.GetRetentionDays())
+ m.Status = types.StringValue(string(resp.GetStatus()))
+
+ stor, diags := sqlserverflexbetaDataGen.NewStorageValue(
+ sqlserverflexbetaDataGen.StorageValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "class": types.StringValue(resp.Storage.GetClass()),
+ "size": types.Int64Value(resp.Storage.GetSize()),
+ },
+ )
+ tfDiags.Append(diags...)
+ if diags.HasError() {
+ return fmt.Errorf("error converting storage response value")
+ }
+ m.Storage = stor
+
+ m.Version = types.StringValue(string(resp.GetVersion()))
+ return nil
+}
+
+func handleEncryption(
+ ctx context.Context,
+ m *sqlserverflexbetaResGen.InstanceModel,
+ resp *sqlserverflexbeta.GetInstanceResponse,
+) sqlserverflexbetaResGen.EncryptionValue {
+ if !resp.HasEncryption() ||
+ resp.Encryption == nil ||
+ resp.Encryption.KekKeyId == nil ||
+ resp.Encryption.KekKeyRingId == nil ||
+ resp.Encryption.KekKeyVersion == nil ||
+ resp.Encryption.ServiceAccount == nil {
+ if m.Encryption.IsNull() || m.Encryption.IsUnknown() {
+ return sqlserverflexbetaResGen.NewEncryptionValueNull()
+ }
+ return m.Encryption
+ }
+
+ enc := sqlserverflexbetaResGen.NewEncryptionValueMust(
+ sqlserverflexbetaResGen.EncryptionValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "kek_key_id": types.StringValue(resp.Encryption.GetKekKeyId()),
+ "kek_key_ring_id": types.StringValue(resp.Encryption.GetKekKeyRingId()),
+ "kek_key_version": types.StringValue(resp.Encryption.GetKekKeyVersion()),
+ "service_account": types.StringValue(resp.Encryption.GetServiceAccount()),
+ },
+ )
+ return enc
+}
+
+func handleDSEncryption(
+ ctx context.Context,
+ m *dataSourceModel,
+ resp *sqlserverflexbeta.GetInstanceResponse,
+) sqlserverflexbetaDataGen.EncryptionValue {
+ if !resp.HasEncryption() ||
+ resp.Encryption == nil ||
+ resp.Encryption.KekKeyId == nil ||
+ resp.Encryption.KekKeyRingId == nil ||
+ resp.Encryption.KekKeyVersion == nil ||
+ resp.Encryption.ServiceAccount == nil {
+ if m.Encryption.IsNull() || m.Encryption.IsUnknown() {
+ return sqlserverflexbetaDataGen.NewEncryptionValueNull()
+ }
+ return m.Encryption
+ }
+
+ enc := sqlserverflexbetaDataGen.NewEncryptionValueMust(
+ sqlserverflexbetaDataGen.EncryptionValue{}.AttributeTypes(ctx),
+ map[string]attr.Value{
+ "kek_key_id": types.StringValue(resp.Encryption.GetKekKeyId()),
+ "kek_key_ring_id": types.StringValue(resp.Encryption.GetKekKeyRingId()),
+ "kek_key_version": types.StringValue(resp.Encryption.GetKekKeyVersion()),
+ "service_account": types.StringValue(resp.Encryption.GetServiceAccount()),
+ },
+ )
+ return enc
+}
+
+func toCreatePayload(
+ ctx context.Context,
+ model *sqlserverflexbetaResGen.InstanceModel,
+) (*sqlserverflexbeta.CreateInstanceRequestPayload, error) {
+ if model == nil {
+ return nil, fmt.Errorf("nil model")
+ }
+
+ storagePayload := &sqlserverflexbeta.CreateInstanceRequestPayloadGetStorageArgType{}
+ if !model.Storage.IsNull() && !model.Storage.IsUnknown() {
+ storagePayload.Class = model.Storage.Class.ValueStringPointer()
+ storagePayload.Size = model.Storage.Size.ValueInt64Pointer()
+ }
+
+ var encryptionPayload *sqlserverflexbeta.CreateInstanceRequestPayloadGetEncryptionArgType = nil
+ if !model.Encryption.IsNull() && !model.Encryption.IsUnknown() {
+ encryptionPayload = &sqlserverflexbeta.CreateInstanceRequestPayloadGetEncryptionArgType{}
+ encryptionPayload.KekKeyId = model.Encryption.KekKeyId.ValueStringPointer()
+ encryptionPayload.KekKeyRingId = model.Encryption.KekKeyRingId.ValueStringPointer()
+ encryptionPayload.KekKeyVersion = model.Encryption.KekKeyVersion.ValueStringPointer()
+ encryptionPayload.ServiceAccount = model.Encryption.ServiceAccount.ValueStringPointer()
+ }
+
+ networkPayload := &sqlserverflexbeta.CreateInstanceRequestPayloadGetNetworkArgType{}
+ if !model.Network.IsNull() && !model.Network.IsUnknown() {
+ networkPayload.AccessScope = sqlserverflexbeta.CreateInstanceRequestPayloadNetworkGetAccessScopeAttributeType(
+ model.Network.AccessScope.ValueStringPointer(),
+ )
+
+ var resList []string
+ diags := model.Network.Acl.ElementsAs(ctx, &resList, false)
+ if diags.HasError() {
+ return nil, fmt.Errorf("error converting network acl list")
+ }
+ networkPayload.Acl = &resList
+ }
+
+ return &sqlserverflexbeta.CreateInstanceRequestPayload{
+ BackupSchedule: conversion.StringValueToPointer(model.BackupSchedule),
+ Encryption: encryptionPayload,
+ FlavorId: conversion.StringValueToPointer(model.FlavorId),
+ Name: conversion.StringValueToPointer(model.Name),
+ Network: networkPayload,
+ RetentionDays: conversion.Int64ValueToPointer(model.RetentionDays),
+ Storage: storagePayload,
+ Version: sqlserverflexbeta.CreateInstanceRequestPayloadGetVersionAttributeType(
+ conversion.StringValueToPointer(model.Version),
+ ),
+ }, nil
+}
+
+func toUpdatePayload(
+ ctx context.Context,
+ m *sqlserverflexbetaResGen.InstanceModel,
+ resp *resource.UpdateResponse,
+) (*sqlserverflexbeta.UpdateInstanceRequestPayload, error) {
+ if m == nil {
+ return nil, fmt.Errorf("nil model")
+ }
+ if m.Replicas.ValueInt64() > math.MaxUint32 {
+ return nil, fmt.Errorf("replicas value is too big for uint32")
+ }
+ replVal := sqlserverflexbeta.Replicas(uint32(m.Replicas.ValueInt64())) // nolint:gosec // check is performed above
+
+ var netAcl []string
+ diags := m.Network.Acl.ElementsAs(ctx, &netAcl, false)
+ resp.Diagnostics.Append(diags...)
+ if diags.HasError() {
+ return nil, fmt.Errorf("error converting model network acl value")
+ }
+ return &sqlserverflexbeta.UpdateInstanceRequestPayload{
+ BackupSchedule: m.BackupSchedule.ValueStringPointer(),
+ FlavorId: m.FlavorId.ValueStringPointer(),
+ Name: m.Name.ValueStringPointer(),
+ Network: sqlserverflexbeta.NewUpdateInstanceRequestPayloadNetwork(netAcl),
+ Replicas: &replVal,
+ RetentionDays: m.RetentionDays.ValueInt64Pointer(),
+ Storage: &sqlserverflexbeta.StorageUpdate{Size: m.Storage.Size.ValueInt64Pointer()},
+ Version: sqlserverflexbeta.UpdateInstanceRequestPayloadGetVersionAttributeType(
+ m.Version.ValueStringPointer(),
+ ),
+ }, nil
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/instance/functions_test.go b/stackit/internal/services/sqlserverflexbeta/instance/functions_test.go
new file mode 100644
index 00000000..0c6f6147
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/instance/functions_test.go
@@ -0,0 +1,273 @@
+package sqlserverflexbeta
+
+import (
+ "context"
+ "reflect"
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ sqlserverflexbetaPkgGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+ sqlserverflexbetaRs "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance/resources_gen"
+)
+
+func Test_handleDSEncryption(t *testing.T) {
+ type args struct {
+ m *dataSourceModel
+ resp *sqlserverflexbetaPkgGen.GetInstanceResponse
+ }
+ tests := []struct {
+ name string
+ args args
+ want sqlserverflexbetaRs.EncryptionValue
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.name, func(t *testing.T) {
+ if got := handleDSEncryption(t.Context(), tt.args.m, tt.args.resp); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("handleDSEncryption() = %v, want %v", got, tt.want)
+ }
+ },
+ )
+ }
+}
+
+func Test_handleEncryption(t *testing.T) {
+ type args struct {
+ m *sqlserverflexbetaRs.InstanceModel
+ resp *sqlserverflexbetaPkgGen.GetInstanceResponse
+ }
+ tests := []struct {
+ name string
+ args args
+ want sqlserverflexbetaRs.EncryptionValue
+ }{
+ {
+ name: "nil response",
+ args: args{
+ m: &sqlserverflexbetaRs.InstanceModel{},
+ resp: &sqlserverflexbetaPkgGen.GetInstanceResponse{},
+ },
+ want: sqlserverflexbetaRs.EncryptionValue{},
+ },
+ {
+ name: "nil response",
+ args: args{
+ m: &sqlserverflexbetaRs.InstanceModel{},
+ resp: &sqlserverflexbetaPkgGen.GetInstanceResponse{
+ Encryption: &sqlserverflexbetaPkgGen.InstanceEncryption{},
+ },
+ },
+ want: sqlserverflexbetaRs.NewEncryptionValueNull(),
+ },
+ {
+ name: "response with values",
+ args: args{
+ m: &sqlserverflexbetaRs.InstanceModel{},
+ resp: &sqlserverflexbetaPkgGen.GetInstanceResponse{
+ Encryption: &sqlserverflexbetaPkgGen.InstanceEncryption{
+ KekKeyId: utils.Ptr("kek_key_id"),
+ KekKeyRingId: utils.Ptr("kek_key_ring_id"),
+ KekKeyVersion: utils.Ptr("kek_key_version"),
+ ServiceAccount: utils.Ptr("kek_svc_acc"),
+ },
+ },
+ },
+ want: sqlserverflexbetaRs.EncryptionValue{
+ KekKeyId: types.StringValue("kek_key_id"),
+ KekKeyRingId: types.StringValue("kek_key_ring_id"),
+ KekKeyVersion: types.StringValue("kek_key_version"),
+ ServiceAccount: types.StringValue("kek_svc_acc"),
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.name, func(t *testing.T) {
+ if got := handleEncryption(t.Context(), tt.args.m, tt.args.resp); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("handleEncryption() = %v, want %v", got, tt.want)
+ }
+ },
+ )
+ }
+}
+
+func Test_mapDataResponseToModel(t *testing.T) {
+ type args struct {
+ ctx context.Context
+ resp *sqlserverflexbetaPkgGen.GetInstanceResponse
+ m *dataSourceModel
+ tfDiags diag.Diagnostics
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.name, func(t *testing.T) {
+ if err := mapDataResponseToModel(
+ tt.args.ctx,
+ tt.args.resp,
+ tt.args.m,
+ tt.args.tfDiags,
+ ); (err != nil) != tt.wantErr {
+ t.Errorf("mapDataResponseToModel() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ },
+ )
+ }
+}
+
+func Test_mapResponseToModel(t *testing.T) {
+ type args struct {
+ ctx context.Context
+ resp *sqlserverflexbetaPkgGen.GetInstanceResponse
+ m *sqlserverflexbetaRs.InstanceModel
+ tfDiags diag.Diagnostics
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.name, func(t *testing.T) {
+ if err := mapResponseToModel(
+ tt.args.ctx,
+ tt.args.resp,
+ tt.args.m,
+ tt.args.tfDiags,
+ ); (err != nil) != tt.wantErr {
+ t.Errorf("mapResponseToModel() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ },
+ )
+ }
+}
+
+func Test_toCreatePayload(t *testing.T) {
+ type args struct {
+ ctx context.Context
+ model *sqlserverflexbetaRs.InstanceModel
+ }
+ tests := []struct {
+ name string
+ args args
+ want *sqlserverflexbetaPkgGen.CreateInstanceRequestPayload
+ wantErr bool
+ }{
+ {
+ name: "simple",
+ args: args{
+ ctx: context.Background(),
+ model: &sqlserverflexbetaRs.InstanceModel{
+ Encryption: sqlserverflexbetaRs.NewEncryptionValueMust(
+ sqlserverflexbetaRs.EncryptionValue{}.AttributeTypes(context.Background()),
+ map[string]attr.Value{
+ "kek_key_id": types.StringValue("kek_key_id"),
+ "kek_key_ring_id": types.StringValue("kek_key_ring_id"),
+ "kek_key_version": types.StringValue("kek_key_version"),
+ "service_account": types.StringValue("sacc"),
+ },
+ ),
+ Storage: sqlserverflexbetaRs.StorageValue{},
+ },
+ },
+ want: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayload{
+ BackupSchedule: nil,
+ Encryption: &sqlserverflexbetaPkgGen.InstanceEncryption{
+ KekKeyId: utils.Ptr("kek_key_id"),
+ KekKeyRingId: utils.Ptr("kek_key_ring_id"),
+ KekKeyVersion: utils.Ptr("kek_key_version"),
+ ServiceAccount: utils.Ptr("sacc"),
+ },
+ FlavorId: nil,
+ Name: nil,
+ Network: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayloadNetwork{},
+ RetentionDays: nil,
+ Storage: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayloadGetStorageArgType{},
+ Version: nil,
+ },
+ wantErr: false,
+ },
+ {
+ name: "nil object",
+ args: args{
+ ctx: context.Background(),
+ model: &sqlserverflexbetaRs.InstanceModel{
+ Encryption: sqlserverflexbetaRs.NewEncryptionValueNull(),
+ Storage: sqlserverflexbetaRs.StorageValue{},
+ },
+ },
+ want: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayload{
+ BackupSchedule: nil,
+ Encryption: nil,
+ FlavorId: nil,
+ Name: nil,
+ Network: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayloadNetwork{},
+ RetentionDays: nil,
+ Storage: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayloadGetStorageArgType{},
+ Version: nil,
+ },
+ wantErr: false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.name, func(t *testing.T) {
+ got, err := toCreatePayload(tt.args.ctx, tt.args.model)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("toCreatePayload() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if diff := cmp.Diff(tt.want, got); diff != "" {
+ t.Errorf("model mismatch (-want +got):\n%s", diff)
+ }
+ },
+ )
+ }
+}
+
+func Test_toUpdatePayload(t *testing.T) {
+ type args struct {
+ ctx context.Context
+ m *sqlserverflexbetaRs.InstanceModel
+ resp *resource.UpdateResponse
+ }
+ tests := []struct {
+ name string
+ args args
+ want *sqlserverflexbetaPkgGen.UpdateInstanceRequestPayload
+ wantErr bool
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.name, func(t *testing.T) {
+ got, err := toUpdatePayload(tt.args.ctx, tt.args.m, tt.args.resp)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("toUpdatePayload() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("toUpdatePayload() got = %v, want %v", got, tt.want)
+ }
+ },
+ )
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/instance/planModifiers.yaml b/stackit/internal/services/sqlserverflexbeta/instance/planModifiers.yaml
new file mode 100644
index 00000000..71d4cbe4
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/instance/planModifiers.yaml
@@ -0,0 +1,124 @@
+fields:
+ - name: 'id'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'instance_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'project_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'name'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'backup_schedule'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'encryption.kek_key_id'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'encryption.kek_key_version'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'encryption.kek_key_ring_id'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'encryption.service_account'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'network.access_scope'
+ validators:
+ - validate.NoSeparator
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'network.acl'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'network.instance_address'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'network.router_address'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'status'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'region'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'retention_days'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'edition'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'version'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'replicas'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'storage'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'storage.class'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'storage.size'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'flavor_id'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'is_deletable'
+ modifiers:
+ - 'UseStateForUnknown'
diff --git a/stackit/internal/services/sqlserverflexbeta/instance/resource.go b/stackit/internal/services/sqlserverflexbeta/instance/resource.go
new file mode 100644
index 00000000..044b4b43
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/instance/resource.go
@@ -0,0 +1,548 @@
+package sqlserverflexbeta
+
+import (
+ "context"
+ _ "embed"
+ "fmt"
+ "net/http"
+ "strings"
+ "time"
+
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+ "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ wait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexbeta"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexbetaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance/resources_gen"
+)
+
+var (
+ _ resource.Resource = &instanceResource{}
+ _ resource.ResourceWithConfigure = &instanceResource{}
+ _ resource.ResourceWithImportState = &instanceResource{}
+ _ resource.ResourceWithModifyPlan = &instanceResource{}
+ _ resource.ResourceWithIdentity = &instanceResource{}
+)
+
+func NewInstanceResource() resource.Resource {
+ return &instanceResource{}
+}
+
+type instanceResource struct {
+ client *sqlserverflexbeta.APIClient
+ providerData core.ProviderData
+}
+
+// resourceModel describes the resource data model.
+type resourceModel = sqlserverflexbetaResGen.InstanceModel
+
+type InstanceResourceIdentityModel struct {
+ ProjectID types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ InstanceID types.String `tfsdk:"instance_id"`
+}
+
+func (r *instanceResource) Metadata(
+ _ context.Context,
+ req resource.MetadataRequest,
+ resp *resource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexbeta_instance"
+}
+
+//go:embed planModifiers.yaml
+var modifiersFileByte []byte
+
+func (r *instanceResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
+ s := sqlserverflexbetaResGen.InstanceResourceSchema(ctx)
+
+ fields, err := utils.ReadModifiersConfig(modifiersFileByte)
+ if err != nil {
+ resp.Diagnostics.AddError("error during read modifiers config file", err.Error())
+ return
+ }
+
+ err = utils.AddPlanModifiersToResourceSchema(fields, &s)
+ if err != nil {
+ resp.Diagnostics.AddError("error adding plan modifiers", err.Error())
+ return
+ }
+ resp.Schema = s
+}
+
+func (r *instanceResource) IdentitySchema(
+ _ context.Context,
+ _ resource.IdentitySchemaRequest,
+ resp *resource.IdentitySchemaResponse,
+) {
+ resp.IdentitySchema = identityschema.Schema{
+ Attributes: map[string]identityschema.Attribute{
+ "project_id": identityschema.StringAttribute{
+ RequiredForImport: true, // must be set during import by the practitioner
+ },
+ "region": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ "instance_id": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ },
+ }
+}
+
+// Configure adds the provider configured client to the resource.
+func (r *instanceResource) Configure(
+ ctx context.Context,
+ req resource.ConfigureRequest,
+ resp *resource.ConfigureResponse,
+) {
+ var ok bool
+ r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(r.providerData.RoundTripper),
+ utils.UserAgentConfigOption(r.providerData.Version),
+ }
+ if r.providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(r.providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(apiClientConfigOptions, config.WithRegion(r.providerData.GetRegion()))
+ }
+ apiClient, err := sqlserverflexbeta.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return
+ }
+ r.client = apiClient
+ tflog.Info(ctx, "sqlserverflexbeta.Instance client configured")
+}
+
+// ModifyPlan implements resource.ResourceWithModifyPlan.
+// Use the modifier to set the effective region in the current plan.
+func (r *instanceResource) ModifyPlan(
+ ctx context.Context,
+ req resource.ModifyPlanRequest,
+ resp *resource.ModifyPlanResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ // skip initial empty configuration to avoid follow-up errors
+ if req.Config.Raw.IsNull() {
+ return
+ }
+ var configModel resourceModel
+ resp.Diagnostics.Append(req.Config.Get(ctx, &configModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ if req.Plan.Raw.IsNull() {
+ return
+ }
+ var planModel resourceModel
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+}
+
+func (r *instanceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
+ var data resourceModel
+ crateErr := "[SQL Server Flex BETA - Create] error"
+
+ // Read Terraform plan data into the model
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
+
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := data.ProjectId.ValueString()
+ region := data.Region.ValueString()
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ // Generate API request body from model
+ payload, err := toCreatePayload(ctx, &data)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ crateErr,
+ fmt.Sprintf("Creating API payload: %v", err),
+ )
+ return
+ }
+
+ // Create new Instance
+ createResp, err := r.client.CreateInstanceRequest(
+ ctx,
+ projectId,
+ region,
+ ).CreateInstanceRequestPayload(*payload).Execute()
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, crateErr, fmt.Sprintf("Calling API: %v", err))
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ InstanceId := *createResp.Id
+
+ // Example data value setting
+ data.InstanceId = types.StringValue("id-from-response")
+
+ identity := InstanceResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(InstanceId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ waitResp, err := wait.CreateInstanceWaitHandler(
+ ctx,
+ r.client,
+ projectId,
+ InstanceId,
+ region,
+ ).SetSleepBeforeWait(
+ 10 * time.Second,
+ ).SetTimeout(
+ 90 * time.Minute,
+ ).WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ crateErr,
+ fmt.Sprintf("Instance creation waiting: %v", err),
+ )
+ return
+ }
+
+ if waitResp.Id == nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ crateErr,
+ "Instance creation waiting: returned id is nil",
+ )
+ return
+ }
+
+ // Map response body to schema
+ err = mapResponseToModel(ctx, waitResp, &data, resp.Diagnostics)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ crateErr,
+ fmt.Sprintf("processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Save data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+
+ tflog.Info(ctx, "sqlserverflexbeta.Instance created")
+}
+
+func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
+ var data resourceModel
+
+ // Read Terraform prior state data into the model
+ resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := data.ProjectId.ValueString()
+ region := data.Region.ValueString()
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ instanceId := data.InstanceId.ValueString()
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+
+ instanceResp, err := r.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
+ if err != nil {
+ oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
+ if ok && oapiErr.StatusCode == http.StatusNotFound {
+ resp.State.RemoveResource(ctx)
+ return
+ }
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", err.Error())
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ // Map response body to schema
+ err = mapResponseToModel(ctx, instanceResp, &data, resp.Diagnostics)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading instance",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Save identity into Terraform state
+ identity := InstanceResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Save updated data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ tflog.Info(ctx, "sqlserverflexbeta.Instance read")
+}
+
+func (r *instanceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
+ var data resourceModel
+ updateInstanceError := "Error updating instance"
+
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := data.ProjectId.ValueString()
+ region := data.Region.ValueString()
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ instanceId := data.InstanceId.ValueString()
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+
+ // Generate API request body from model
+ payload, err := toUpdatePayload(ctx, &data, resp)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ updateInstanceError,
+ fmt.Sprintf("Creating API payload: %v", err),
+ )
+ return
+ }
+ // Update existing instance
+ err = r.client.UpdateInstanceRequest(
+ ctx,
+ projectId,
+ region,
+ instanceId,
+ ).UpdateInstanceRequestPayload(*payload).Execute()
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, updateInstanceError, err.Error())
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ waitResp, err := wait.
+ UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).
+ SetSleepBeforeWait(15 * time.Second).
+ SetTimeout(45 * time.Minute).
+ WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ updateInstanceError,
+ fmt.Sprintf("Instance update waiting: %v", err),
+ )
+ return
+ }
+
+ // Map response body to schema
+ err = mapResponseToModel(ctx, waitResp, &data, resp.Diagnostics)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ updateInstanceError,
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ identity := InstanceResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Save updated data into Terraform state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ tflog.Info(ctx, "sqlserverflexbeta.Instance updated")
+}
+
+func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
+ var data resourceModel
+
+ // Read Terraform prior state data into the model
+ resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Read identity data
+ var identityData InstanceResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ instanceId := identityData.InstanceID.ValueString()
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+
+ // Delete existing instance
+ err := r.client.DeleteInstanceRequest(ctx, projectId, region, instanceId).Execute()
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Calling API: %v", err))
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ delResp, err := wait.DeleteInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error deleting instance",
+ fmt.Sprintf("Instance deletion waiting: %v", err),
+ )
+ return
+ }
+
+ if delResp != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error deleting instance",
+ "wait handler returned non nil result",
+ )
+ return
+ }
+
+ resp.State.RemoveResource(ctx)
+
+ tflog.Info(ctx, "sqlserverflexbeta.Instance deleted")
+}
+
+// ImportState imports a resource into the Terraform state on success.
+// The expected format of the resource import identifier is: project_id,zone_id,record_set_id
+func (r *instanceResource) ImportState(
+ ctx context.Context,
+ req resource.ImportStateRequest,
+ resp *resource.ImportStateResponse,
+) {
+ ctx = core.InitProviderContext(ctx)
+
+ if req.ID != "" {
+ idParts := strings.Split(req.ID, core.Separator)
+
+ if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
+ core.LogAndAddError(
+ ctx, &resp.Diagnostics,
+ "Error importing instance",
+ fmt.Sprintf(
+ "Expected import identifier with format [project_id],[region],[instance_id] Got: %q",
+ req.ID,
+ ),
+ )
+ return
+ }
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
+ return
+ }
+
+ // If no ID is provided, attempt to read identity attributes from the import configuration
+ var identityData InstanceResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ instanceId := identityData.InstanceID.ValueString()
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), projectId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), region)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), instanceId)...)
+
+ tflog.Info(ctx, "Sqlserverflexbeta instance state imported")
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/instance/resources_gen/instance_resource_gen.go b/stackit/internal/services/sqlserverflexbeta/instance/resources_gen/instance_resource_gen.go
new file mode 100644
index 00000000..f8865ae5
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/instance/resources_gen/instance_resource_gen.go
@@ -0,0 +1,1597 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+)
+
+func InstanceResourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "backup_schedule": schema.StringAttribute{
+ Required: true,
+ Description: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ MarkdownDescription: "The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.",
+ },
+ "edition": schema.StringAttribute{
+ Computed: true,
+ Description: "Edition of the MSSQL server instance",
+ MarkdownDescription: "Edition of the MSSQL server instance",
+ },
+ "encryption": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "kek_key_id": schema.StringAttribute{
+ Required: true,
+ Description: "The key identifier",
+ MarkdownDescription: "The key identifier",
+ },
+ "kek_key_ring_id": schema.StringAttribute{
+ Required: true,
+ Description: "The keyring identifier",
+ MarkdownDescription: "The keyring identifier",
+ },
+ "kek_key_version": schema.StringAttribute{
+ Required: true,
+ Description: "The key version",
+ MarkdownDescription: "The key version",
+ },
+ "service_account": schema.StringAttribute{
+ Required: true,
+ },
+ },
+ CustomType: EncryptionType{
+ ObjectType: types.ObjectType{
+ AttrTypes: EncryptionValue{}.AttributeTypes(ctx),
+ },
+ },
+ Optional: true,
+ Computed: true,
+ Description: "this defines which key to use for storage encryption",
+ MarkdownDescription: "this defines which key to use for storage encryption",
+ },
+ "flavor_id": schema.StringAttribute{
+ Required: true,
+ Description: "The id of the instance flavor.",
+ MarkdownDescription: "The id of the instance flavor.",
+ },
+ "id": schema.StringAttribute{
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "instance_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "is_deletable": schema.BoolAttribute{
+ Computed: true,
+ Description: "Whether the instance can be deleted or not.",
+ MarkdownDescription: "Whether the instance can be deleted or not.",
+ },
+ "name": schema.StringAttribute{
+ Required: true,
+ Description: "The name of the instance.",
+ MarkdownDescription: "The name of the instance.",
+ },
+ "network": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "access_scope": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The network access scope of the instance\n\n⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ MarkdownDescription: "The network access scope of the instance\n\n⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.\n",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "PUBLIC",
+ "SNA",
+ ),
+ },
+ Default: stringdefault.StaticString("PUBLIC"),
+ },
+ "acl": schema.ListAttribute{
+ ElementType: types.StringType,
+ Required: true,
+ Description: "List of IPV4 cidr.",
+ MarkdownDescription: "List of IPV4 cidr.",
+ },
+ "instance_address": schema.StringAttribute{
+ Computed: true,
+ },
+ "router_address": schema.StringAttribute{
+ Computed: true,
+ },
+ },
+ CustomType: NetworkType{
+ ObjectType: types.ObjectType{
+ AttrTypes: NetworkValue{}.AttributeTypes(ctx),
+ },
+ },
+ Required: true,
+ Description: "the network configuration of the instance.",
+ MarkdownDescription: "the network configuration of the instance.",
+ },
+ "project_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "replicas": schema.Int64Attribute{
+ Computed: true,
+ Description: "How many replicas the instance should have.",
+ MarkdownDescription: "How many replicas the instance should have.",
+ },
+ "retention_days": schema.Int64Attribute{
+ Required: true,
+ Description: "The days for how long the backup files should be stored before cleaned up. 30 to 365",
+ MarkdownDescription: "The days for how long the backup files should be stored before cleaned up. 30 to 365",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ },
+ "storage": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "class": schema.StringAttribute{
+ Required: true,
+ Description: "The storage class for the storage.",
+ MarkdownDescription: "The storage class for the storage.",
+ },
+ "size": schema.Int64Attribute{
+ Required: true,
+ Description: "The storage size in Gigabytes.",
+ MarkdownDescription: "The storage size in Gigabytes.",
+ },
+ },
+ CustomType: StorageType{
+ ObjectType: types.ObjectType{
+ AttrTypes: StorageValue{}.AttributeTypes(ctx),
+ },
+ },
+ Required: true,
+ Description: "The object containing information about the storage size and class.",
+ MarkdownDescription: "The object containing information about the storage size and class.",
+ },
+ "version": schema.StringAttribute{
+ Required: true,
+ Description: "The sqlserver version used for the instance.",
+ MarkdownDescription: "The sqlserver version used for the instance.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "2022",
+ ),
+ },
+ },
+ },
+ }
+}
+
+type InstanceModel struct {
+ BackupSchedule types.String `tfsdk:"backup_schedule"`
+ Edition types.String `tfsdk:"edition"`
+ Encryption EncryptionValue `tfsdk:"encryption"`
+ FlavorId types.String `tfsdk:"flavor_id"`
+ Id types.String `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ IsDeletable types.Bool `tfsdk:"is_deletable"`
+ Name types.String `tfsdk:"name"`
+ Network NetworkValue `tfsdk:"network"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Replicas types.Int64 `tfsdk:"replicas"`
+ RetentionDays types.Int64 `tfsdk:"retention_days"`
+ Status types.String `tfsdk:"status"`
+ Storage StorageValue `tfsdk:"storage"`
+ Version types.String `tfsdk:"version"`
+}
+
+var _ basetypes.ObjectTypable = EncryptionType{}
+
+type EncryptionType struct {
+ basetypes.ObjectType
+}
+
+func (t EncryptionType) Equal(o attr.Type) bool {
+ other, ok := o.(EncryptionType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t EncryptionType) String() string {
+ return "EncryptionType"
+}
+
+func (t EncryptionType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return nil, diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return nil, diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueNull() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewEncryptionValueUnknown() EncryptionValue {
+ return EncryptionValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewEncryptionValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (EncryptionValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, a missing attribute value was detected. "+
+ "A EncryptionValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid EncryptionValue Attribute Type",
+ "While creating a EncryptionValue value, an invalid attribute value was detected. "+
+ "A EncryptionValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("EncryptionValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra EncryptionValue Attribute Value",
+ "While creating a EncryptionValue value, an extra attribute value was detected. "+
+ "A EncryptionValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra EncryptionValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdAttribute, ok := attributes["kek_key_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyIdVal, ok := kekKeyIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_id expected to be basetypes.StringValue, was: %T`, kekKeyIdAttribute))
+ }
+
+ kekKeyRingIdAttribute, ok := attributes["kek_key_ring_id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_ring_id is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyRingIdVal, ok := kekKeyRingIdAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_ring_id expected to be basetypes.StringValue, was: %T`, kekKeyRingIdAttribute))
+ }
+
+ kekKeyVersionAttribute, ok := attributes["kek_key_version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `kek_key_version is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ kekKeyVersionVal, ok := kekKeyVersionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`kek_key_version expected to be basetypes.StringValue, was: %T`, kekKeyVersionAttribute))
+ }
+
+ serviceAccountAttribute, ok := attributes["service_account"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `service_account is missing from object`)
+
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ serviceAccountVal, ok := serviceAccountAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`service_account expected to be basetypes.StringValue, was: %T`, serviceAccountAttribute))
+ }
+
+ if diags.HasError() {
+ return NewEncryptionValueUnknown(), diags
+ }
+
+ return EncryptionValue{
+ KekKeyId: kekKeyIdVal,
+ KekKeyRingId: kekKeyRingIdVal,
+ KekKeyVersion: kekKeyVersionVal,
+ ServiceAccount: serviceAccountVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewEncryptionValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) EncryptionValue {
+ object, diags := NewEncryptionValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewEncryptionValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t EncryptionType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewEncryptionValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewEncryptionValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewEncryptionValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewEncryptionValueMust(EncryptionValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t EncryptionType) ValueType(ctx context.Context) attr.Value {
+ return EncryptionValue{}
+}
+
+var _ basetypes.ObjectValuable = EncryptionValue{}
+
+type EncryptionValue struct {
+ KekKeyId basetypes.StringValue `tfsdk:"kek_key_id"`
+ KekKeyRingId basetypes.StringValue `tfsdk:"kek_key_ring_id"`
+ KekKeyVersion basetypes.StringValue `tfsdk:"kek_key_version"`
+ ServiceAccount basetypes.StringValue `tfsdk:"service_account"`
+ state attr.ValueState
+}
+
+func (v EncryptionValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["kek_key_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_ring_id"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["kek_key_version"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["service_account"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.KekKeyId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_id"] = val
+
+ val, err = v.KekKeyRingId.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_ring_id"] = val
+
+ val, err = v.KekKeyVersion.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["kek_key_version"] = val
+
+ val, err = v.ServiceAccount.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["service_account"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v EncryptionValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v EncryptionValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v EncryptionValue) String() string {
+ return "EncryptionValue"
+}
+
+func (v EncryptionValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "kek_key_id": v.KekKeyId,
+ "kek_key_ring_id": v.KekKeyRingId,
+ "kek_key_version": v.KekKeyVersion,
+ "service_account": v.ServiceAccount,
+ })
+
+ return objVal, diags
+}
+
+func (v EncryptionValue) Equal(o attr.Value) bool {
+ other, ok := o.(EncryptionValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.KekKeyId.Equal(other.KekKeyId) {
+ return false
+ }
+
+ if !v.KekKeyRingId.Equal(other.KekKeyRingId) {
+ return false
+ }
+
+ if !v.KekKeyVersion.Equal(other.KekKeyVersion) {
+ return false
+ }
+
+ if !v.ServiceAccount.Equal(other.ServiceAccount) {
+ return false
+ }
+
+ return true
+}
+
+func (v EncryptionValue) Type(ctx context.Context) attr.Type {
+ return EncryptionType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v EncryptionValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "kek_key_id": basetypes.StringType{},
+ "kek_key_ring_id": basetypes.StringType{},
+ "kek_key_version": basetypes.StringType{},
+ "service_account": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = NetworkType{}
+
+type NetworkType struct {
+ basetypes.ObjectType
+}
+
+func (t NetworkType) Equal(o attr.Type) bool {
+ other, ok := o.(NetworkType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t NetworkType) String() string {
+ return "NetworkType"
+}
+
+func (t NetworkType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return nil, diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return nil, diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return nil, diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return nil, diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueNull() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewNetworkValueUnknown() NetworkValue {
+ return NetworkValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewNetworkValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (NetworkValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing NetworkValue Attribute Value",
+ "While creating a NetworkValue value, a missing attribute value was detected. "+
+ "A NetworkValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid NetworkValue Attribute Type",
+ "While creating a NetworkValue value, an invalid attribute value was detected. "+
+ "A NetworkValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("NetworkValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra NetworkValue Attribute Value",
+ "While creating a NetworkValue value, an extra attribute value was detected. "+
+ "A NetworkValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra NetworkValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeAttribute, ok := attributes["access_scope"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `access_scope is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ accessScopeVal, ok := accessScopeAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`access_scope expected to be basetypes.StringValue, was: %T`, accessScopeAttribute))
+ }
+
+ aclAttribute, ok := attributes["acl"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `acl is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ aclVal, ok := aclAttribute.(basetypes.ListValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`acl expected to be basetypes.ListValue, was: %T`, aclAttribute))
+ }
+
+ instanceAddressAttribute, ok := attributes["instance_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `instance_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ instanceAddressVal, ok := instanceAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`instance_address expected to be basetypes.StringValue, was: %T`, instanceAddressAttribute))
+ }
+
+ routerAddressAttribute, ok := attributes["router_address"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `router_address is missing from object`)
+
+ return NewNetworkValueUnknown(), diags
+ }
+
+ routerAddressVal, ok := routerAddressAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`router_address expected to be basetypes.StringValue, was: %T`, routerAddressAttribute))
+ }
+
+ if diags.HasError() {
+ return NewNetworkValueUnknown(), diags
+ }
+
+ return NetworkValue{
+ AccessScope: accessScopeVal,
+ Acl: aclVal,
+ InstanceAddress: instanceAddressVal,
+ RouterAddress: routerAddressVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewNetworkValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) NetworkValue {
+ object, diags := NewNetworkValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewNetworkValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t NetworkType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewNetworkValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewNetworkValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewNetworkValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewNetworkValueMust(NetworkValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t NetworkType) ValueType(ctx context.Context) attr.Value {
+ return NetworkValue{}
+}
+
+var _ basetypes.ObjectValuable = NetworkValue{}
+
+type NetworkValue struct {
+ AccessScope basetypes.StringValue `tfsdk:"access_scope"`
+ Acl basetypes.ListValue `tfsdk:"acl"`
+ InstanceAddress basetypes.StringValue `tfsdk:"instance_address"`
+ RouterAddress basetypes.StringValue `tfsdk:"router_address"`
+ state attr.ValueState
+}
+
+func (v NetworkValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["access_scope"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["acl"] = basetypes.ListType{
+ ElemType: types.StringType,
+ }.TerraformType(ctx)
+ attrTypes["instance_address"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["router_address"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.AccessScope.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["access_scope"] = val
+
+ val, err = v.Acl.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["acl"] = val
+
+ val, err = v.InstanceAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["instance_address"] = val
+
+ val, err = v.RouterAddress.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["router_address"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v NetworkValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v NetworkValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v NetworkValue) String() string {
+ return "NetworkValue"
+}
+
+func (v NetworkValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ var aclVal basetypes.ListValue
+ switch {
+ case v.Acl.IsUnknown():
+ aclVal = types.ListUnknown(types.StringType)
+ case v.Acl.IsNull():
+ aclVal = types.ListNull(types.StringType)
+ default:
+ var d diag.Diagnostics
+ aclVal, d = types.ListValue(types.StringType, v.Acl.Elements())
+ diags.Append(d...)
+ }
+
+ if diags.HasError() {
+ return types.ObjectUnknown(map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }), diags
+ }
+
+ attributeTypes := map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "access_scope": v.AccessScope,
+ "acl": aclVal,
+ "instance_address": v.InstanceAddress,
+ "router_address": v.RouterAddress,
+ })
+
+ return objVal, diags
+}
+
+func (v NetworkValue) Equal(o attr.Value) bool {
+ other, ok := o.(NetworkValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.AccessScope.Equal(other.AccessScope) {
+ return false
+ }
+
+ if !v.Acl.Equal(other.Acl) {
+ return false
+ }
+
+ if !v.InstanceAddress.Equal(other.InstanceAddress) {
+ return false
+ }
+
+ if !v.RouterAddress.Equal(other.RouterAddress) {
+ return false
+ }
+
+ return true
+}
+
+func (v NetworkValue) Type(ctx context.Context) attr.Type {
+ return NetworkType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v NetworkValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "access_scope": basetypes.StringType{},
+ "acl": basetypes.ListType{
+ ElemType: types.StringType,
+ },
+ "instance_address": basetypes.StringType{},
+ "router_address": basetypes.StringType{},
+ }
+}
+
+var _ basetypes.ObjectTypable = StorageType{}
+
+type StorageType struct {
+ basetypes.ObjectType
+}
+
+func (t StorageType) Equal(o attr.Type) bool {
+ other, ok := o.(StorageType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t StorageType) String() string {
+ return "StorageType"
+}
+
+func (t StorageType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return nil, diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return StorageValue{
+ Class: classVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueNull() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewStorageValueUnknown() StorageValue {
+ return StorageValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewStorageValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (StorageValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing StorageValue Attribute Value",
+ "While creating a StorageValue value, a missing attribute value was detected. "+
+ "A StorageValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid StorageValue Attribute Type",
+ "While creating a StorageValue value, an invalid attribute value was detected. "+
+ "A StorageValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("StorageValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra StorageValue Attribute Value",
+ "While creating a StorageValue value, an extra attribute value was detected. "+
+ "A StorageValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra StorageValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ classAttribute, ok := attributes["class"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `class is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ classVal, ok := classAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`class expected to be basetypes.StringValue, was: %T`, classAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewStorageValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ if diags.HasError() {
+ return NewStorageValueUnknown(), diags
+ }
+
+ return StorageValue{
+ Class: classVal,
+ Size: sizeVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewStorageValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) StorageValue {
+ object, diags := NewStorageValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewStorageValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t StorageType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewStorageValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewStorageValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewStorageValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewStorageValueMust(StorageValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t StorageType) ValueType(ctx context.Context) attr.Value {
+ return StorageValue{}
+}
+
+var _ basetypes.ObjectValuable = StorageValue{}
+
+type StorageValue struct {
+ Class basetypes.StringValue `tfsdk:"class"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ state attr.ValueState
+}
+
+func (v StorageValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 2)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["class"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 2)
+
+ val, err = v.Class.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["class"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v StorageValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v StorageValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v StorageValue) String() string {
+ return "StorageValue"
+}
+
+func (v StorageValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "class": v.Class,
+ "size": v.Size,
+ })
+
+ return objVal, diags
+}
+
+func (v StorageValue) Equal(o attr.Value) bool {
+ other, ok := o.(StorageValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Class.Equal(other.Class) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ return true
+}
+
+func (v StorageValue) Type(ctx context.Context) attr.Type {
+ return StorageType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v StorageValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "class": basetypes.StringType{},
+ "size": basetypes.Int64Type{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go b/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go
new file mode 100644
index 00000000..887c5edd
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go
@@ -0,0 +1,494 @@
+package sqlserverflexbeta_test
+
+import (
+ "context"
+ _ "embed"
+ "fmt"
+ "log"
+ "os"
+ "strconv"
+ "strings"
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils"
+ sqlserverflexbetaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+ sqlserverflexbeta "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance"
+
+ // The fwresource import alias is so there is no collision
+ // with the more typical acceptance testing import:
+ // "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ fwresource "github.com/hashicorp/terraform-plugin-framework/resource"
+)
+
+const providerPrefix = "stackitprivatepreview_sqlserverflexbeta"
+
+var testInstances []string
+
+func init() {
+ sweeperName := fmt.Sprintf("%s_%s", providerPrefix, "sweeper")
+
+ resource.AddTestSweepers(sweeperName, &resource.Sweeper{
+ Name: sweeperName,
+ F: func(region string) error {
+ ctx := context.Background()
+ apiClientConfigOptions := []config.ConfigurationOption{}
+ apiClient, err := sqlserverflexbetaResGen.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ instances, err := apiClient.ListInstancesRequest(ctx, testutils.ProjectId, region).
+ Size(100).
+ Execute()
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ for _, inst := range instances.GetInstances() {
+ if strings.HasPrefix(inst.GetName(), "tf-acc-") {
+ for _, item := range testInstances {
+ if inst.GetName() == item {
+ delErr := apiClient.DeleteInstanceRequestExecute(ctx, testutils.ProjectId, region, inst.GetId())
+ if delErr != nil {
+ // TODO: maybe just warn?
+ log.Fatalln(delErr)
+ }
+ }
+ }
+ }
+ }
+ return nil
+ },
+ })
+}
+
+func TestInstanceResourceSchema(t *testing.T) {
+ t.Parallel()
+
+ ctx := context.Background()
+ schemaRequest := fwresource.SchemaRequest{}
+ schemaResponse := &fwresource.SchemaResponse{}
+
+ // Instantiate the resource.Resource and call its Schema method
+ sqlserverflexbeta.NewInstanceResource().Schema(ctx, schemaRequest, schemaResponse)
+
+ if schemaResponse.Diagnostics.HasError() {
+ t.Fatalf("Schema method diagnostics: %+v", schemaResponse.Diagnostics)
+ }
+
+ // Validate the schema
+ diagnostics := schemaResponse.Schema.ValidateImplementation(ctx)
+
+ if diagnostics.HasError() {
+ t.Fatalf("Schema validation diagnostics: %+v", diagnostics)
+ }
+}
+
+func TestMain(m *testing.M) {
+ testutils.Setup()
+ code := m.Run()
+ // shutdown()
+ os.Exit(code)
+}
+
+func testAccPreCheck(t *testing.T) {
+ if _, ok := os.LookupEnv("TF_ACC_PROJECT_ID"); !ok {
+ t.Fatalf("could not find env var TF_ACC_PROJECT_ID")
+ }
+}
+
+type resData struct {
+ ServiceAccountFilePath string
+ ProjectId string
+ Region string
+ Name string
+ TfName string
+ FlavorId string
+ BackupSchedule string
+ UseEncryption bool
+ KekKeyId string
+ KekKeyRingId string
+ KekKeyVersion uint8
+ KekServiceAccount string
+ PerformanceClass string
+ Size uint32
+ AclString string
+ AccessScope string
+ RetentionDays uint32
+ Version string
+ Users []User
+ Databases []Database
+}
+
+type User struct {
+ Name string
+ ProjectId string
+ Roles []string
+}
+
+type Database struct {
+ Name string
+ ProjectId string
+ Owner string
+ Collation string
+ Compatibility string
+}
+
+func resName(res, name string) string {
+ return fmt.Sprintf("%s_%s.%s", providerPrefix, res, name)
+}
+
+func getExample() resData {
+ name := acctest.RandomWithPrefix("tf-acc")
+ return resData{
+ Region: os.Getenv("TF_ACC_REGION"),
+ ServiceAccountFilePath: os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE"),
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Name: name,
+ TfName: name,
+ FlavorId: "4.16-Single",
+ BackupSchedule: "0 0 * * *",
+ UseEncryption: false,
+ RetentionDays: 33,
+ PerformanceClass: "premium-perf2-stackit",
+ Size: 10,
+ AclString: "0.0.0.0/0",
+ AccessScope: "PUBLIC",
+ Version: "2022",
+ }
+}
+
+func TestAccInstance(t *testing.T) {
+ exData := getExample()
+
+ updNameData := exData
+ updNameData.Name = "name-updated"
+
+ updSizeData := exData
+ updSizeData.Size = 25
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() {
+ testAccPreCheck(t)
+ t.Logf(" ... working on instance %s", exData.TfName)
+ testInstances = append(testInstances, exData.TfName)
+ },
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ exData,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", exData.Name),
+ resource.TestCheckResourceAttrSet(resName("instance", exData.TfName), "id"),
+ // TODO: check all fields
+ ),
+ },
+ // Update name and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ updNameData,
+ ),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", updNameData.Name),
+ ),
+ },
+ // Update size and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ updSizeData,
+ ),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr(
+ testutils.ResStr(providerPrefix, "instance", exData.TfName),
+ "storage.size",
+ strconv.Itoa(int(updSizeData.Size)),
+ ),
+ ),
+ },
+ {
+ RefreshState: true,
+ },
+ //// Import test
+ //{
+ // ResourceName: resName("instance", exData.TfName),
+ // ImportState: true,
+ // ImportStateVerify: true,
+ // },
+ },
+ })
+}
+
+func TestAccInstanceReApply(t *testing.T) {
+ exData := getExample()
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() {
+ testAccPreCheck(t)
+ t.Logf(" ... working on instance %s", exData.TfName)
+ testInstances = append(testInstances, exData.TfName)
+ },
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ exData,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", exData.Name),
+ resource.TestCheckResourceAttrSet(resName("instance", exData.TfName), "id"),
+ // TODO: check all fields
+ ),
+ },
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ exData,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", exData.Name),
+ resource.TestCheckResourceAttrSet(resName("instance", exData.TfName), "id"),
+ // TODO: check all fields
+ ),
+ },
+ {
+ RefreshState: true,
+ },
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ exData,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", exData.Name),
+ resource.TestCheckResourceAttrSet(resName("instance", exData.TfName), "id"),
+ // TODO: check all fields
+ ),
+ },
+ // Import test
+ {
+ ResourceName: resName("instance", exData.TfName),
+ ImportStateKind: resource.ImportBlockWithResourceIdentity,
+ ImportState: true,
+ // ImportStateVerify is not supported with plannable import blocks
+ // ImportStateVerify: true,
+ },
+ },
+ })
+}
+
+func TestAccInstanceNoEncryption(t *testing.T) {
+ data := getExample()
+
+ dbName := "testDb"
+ userName := "testUser"
+ data.Users = []User{
+ {
+ Name: userName,
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Roles: []string{
+ "##STACKIT_DatabaseManager##",
+ "##STACKIT_LoginManager##",
+ "##STACKIT_ProcessManager##",
+ "##STACKIT_SQLAgentManager##",
+ "##STACKIT_SQLAgentUser##",
+ "##STACKIT_ServerManager##",
+ },
+ },
+ }
+ data.Databases = []Database{
+ {
+ Name: dbName,
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Owner: userName,
+ },
+ }
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() {
+ testAccPreCheck(t)
+ t.Logf(" ... working on instance %s", data.TfName)
+ testInstances = append(testInstances, data.TfName)
+ },
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ data,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ // check instance values are set
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "backup_schedule"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "edition"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "flavor_id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "instance_id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "is_deletable"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "name"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "replicas"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "retention_days"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "status"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "version"),
+
+ resource.TestCheckNoResourceAttr(resName("instance", data.TfName), "encryption"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_id"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_version"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_ring_id"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.service_account"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.access_scope"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.acl"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.instance_address"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.router_address"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.class"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.size"),
+
+ // check instance values are correct
+ resource.TestCheckResourceAttr(resName("instance", data.TfName), "name", data.Name),
+
+ // check user values are set
+ resource.TestCheckResourceAttrSet(resName("user", userName), "id"),
+ resource.TestCheckResourceAttrSet(resName("user", userName), "username"),
+ // resource.TestCheckResourceAttrSet(resName("user", userName), "roles"),
+
+ // func(s *terraform.State) error {
+ // return nil
+ // },
+
+ // check user values are correct
+ resource.TestCheckResourceAttr(resName("user", userName), "username", userName),
+ resource.TestCheckResourceAttr(resName("user", userName), "roles.#", strconv.Itoa(len(data.Users[0].Roles))),
+
+ // check database values are set
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "id"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "name"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "owner"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "compatibility"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "collation"),
+
+ // check database values are correct
+ resource.TestCheckResourceAttr(resName("database", dbName), "name", dbName),
+ resource.TestCheckResourceAttr(resName("database", dbName), "owner", userName),
+ ),
+ },
+ },
+ })
+}
+
+func TestAccInstanceEncryption(t *testing.T) {
+ data := getExample()
+
+ dbName := "testDb"
+ userName := "testUser"
+ data.Users = []User{
+ {
+ Name: userName,
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Roles: []string{"##STACKIT_DatabaseManager##", "##STACKIT_LoginManager##"},
+ },
+ }
+ data.Databases = []Database{
+ {
+ Name: dbName,
+ ProjectId: os.Getenv("TF_ACC_PROJECT_ID"),
+ Owner: userName,
+ },
+ }
+
+ data.UseEncryption = true
+ data.KekKeyId = "fe039bcf-8d7b-431a-801d-9e81371a6b7b"
+ data.KekKeyRingId = "6a2d95ab-3c4c-4963-a2bb-08d17a320e27"
+ data.KekKeyVersion = 1
+ data.KekServiceAccount = "henselinm-u2v3ex1@sa.stackit.cloud"
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() {
+ testAccPreCheck(t)
+ t.Logf(" ... working on instance %s", data.TfName)
+ testInstances = append(testInstances, data.TfName)
+ },
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ // Create and verify
+ {
+ Config: testutils.StringFromTemplateMust(
+ "testdata/instance_template.gompl",
+ data,
+ ),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ // check instance values are set
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "backup_schedule"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "edition"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "flavor_id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "instance_id"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "is_deletable"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "name"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "replicas"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "retention_days"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "status"),
+ resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "version"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_id"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_version"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_ring_id"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.service_account"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.access_scope"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.acl"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.instance_address"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.router_address"),
+
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.class"),
+ // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.size"),
+
+ // check instance values are correct
+ resource.TestCheckResourceAttr(resName("instance", data.TfName), "name", data.Name),
+
+ // check user values are set
+ resource.TestCheckResourceAttrSet(resName("user", userName), "id"),
+ resource.TestCheckResourceAttrSet(resName("user", userName), "username"),
+
+ // func(s *terraform.State) error {
+ // return nil
+ // },
+
+ // check user values are correct
+ resource.TestCheckResourceAttr(resName("user", userName), "username", userName),
+ resource.TestCheckResourceAttr(resName("user", userName), "roles.#", "2"),
+
+ // check database values are set
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "id"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "name"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "owner"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "compatibility"),
+ resource.TestCheckResourceAttrSet(resName("database", dbName), "collation"),
+
+ // check database values are correct
+ resource.TestCheckResourceAttr(resName("database", dbName), "name", dbName),
+ resource.TestCheckResourceAttr(resName("database", dbName), "owner", userName),
+ ),
+ },
+ },
+ })
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/testdata/instance_template.gompl b/stackit/internal/services/sqlserverflexbeta/testdata/instance_template.gompl
new file mode 100644
index 00000000..e71f3fa0
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/testdata/instance_template.gompl
@@ -0,0 +1,60 @@
+provider "stackitprivatepreview" {
+ default_region = "{{ .Region }}"
+ service_account_key_path = "{{ .ServiceAccountFilePath }}"
+}
+
+resource "stackitprivatepreview_sqlserverflexbeta_instance" "{{ .TfName }}" {
+ project_id = "{{ .ProjectId }}"
+ name = "{{ .Name }}"
+ backup_schedule = "{{ .BackupSchedule }}"
+ retention_days = {{ .RetentionDays }}
+ flavor_id = "{{ .FlavorId }}"
+ storage = {
+ class = "{{ .PerformanceClass }}"
+ size = {{ .Size }}
+ }
+{{ if .UseEncryption }}
+ encryption = {
+ kek_key_id = "{{ .KekKeyId }}"
+ kek_key_ring_id = "{{ .KekKeyRingId }}"
+ kek_key_version = {{ .KekKeyVersion }}
+ service_account = "{{ .KekServiceAccount }}"
+ }
+{{ end }}
+ network = {
+ acl = ["{{ .AclString }}"]
+ access_scope = "{{ .AccessScope }}"
+ }
+ version = "{{ .Version }}"
+}
+
+{{ if .Users }}
+{{ $tfName := .TfName }}
+{{ range $user := .Users }}
+resource "stackitprivatepreview_sqlserverflexbeta_user" "{{ $user.Name }}" {
+ project_id = "{{ $user.ProjectId }}"
+ instance_id = stackitprivatepreview_sqlserverflexbeta_instance.{{ $tfName }}.instance_id
+ username = "{{ $user.Name }}"
+ roles = [{{ range $i, $v := $user.Roles }}{{if $i}},{{end}}"{{$v}}"{{end}}]
+}
+{{ end }}
+{{ end }}
+
+{{ if .Databases }}
+{{ $tfName := .TfName }}
+{{ range $db := .Databases }}
+resource "stackitprivatepreview_sqlserverflexbeta_database" "{{ $db.Name }}" {
+ depends_on = [stackitprivatepreview_sqlserverflexbeta_user.{{ $db.Owner }}]
+ project_id = "{{ $db.ProjectId }}"
+ instance_id = stackitprivatepreview_sqlserverflexbeta_instance.{{ $tfName }}.instance_id
+ name = "{{ $db.Name }}"
+ owner = "{{ $db.Owner }}"
+{{ if $db.Collation }}
+ collation = "{{ $db.Collation }}"
+{{ end }}
+{{ if $db.Compatibility }}
+ compatibility = "{{ $db.Compatibility }}"
+{{ end }}
+}
+{{ end }}
+{{ end }}
diff --git a/stackit/internal/services/sqlserverflexbeta/user/datasource.go b/stackit/internal/services/sqlserverflexbeta/user/datasource.go
new file mode 100644
index 00000000..d726bc2b
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/user/datasource.go
@@ -0,0 +1,139 @@
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ sqlserverflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/utils"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexbetaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+ sqlserverflexbetaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user/datasources_gen"
+)
+
+var _ datasource.DataSource = (*userDataSource)(nil)
+
+func NewUserDataSource() datasource.DataSource {
+ return &userDataSource{}
+}
+
+type dataSourceModel struct {
+ DefaultDatabase types.String `tfsdk:"default_database"`
+ Host types.String `tfsdk:"host"`
+ Id types.String `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Port types.Int64 `tfsdk:"port"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Roles types.List `tfsdk:"roles"`
+ Status types.String `tfsdk:"status"`
+ UserId types.Int64 `tfsdk:"user_id"`
+ Username types.String `tfsdk:"username"`
+}
+
+type userDataSource struct {
+ client *sqlserverflexbetaPkg.APIClient
+ providerData core.ProviderData
+}
+
+func (d *userDataSource) Metadata(
+ _ context.Context,
+ req datasource.MetadataRequest,
+ resp *datasource.MetadataResponse,
+) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexbeta_user"
+}
+
+func (d *userDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = sqlserverflexbetaGen.UserDataSourceSchema(ctx)
+}
+
+// Configure adds the provider configured client to the data source.
+func (d *userDataSource) Configure(
+ ctx context.Context,
+ req datasource.ConfigureRequest,
+ resp *datasource.ConfigureResponse,
+) {
+ var ok bool
+ d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClient := sqlserverflexUtils.ConfigureClient(ctx, &d.providerData, &resp.Diagnostics)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ d.client = apiClient
+ tflog.Info(ctx, "SQL SERVER Flex alpha database client configured")
+}
+
+func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var model dataSourceModel
+ diags := req.Config.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ userId := model.UserId.ValueInt64()
+ region := d.providerData.GetRegionWithOverride(model.Region)
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "user_id", userId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ recordSetResp, err := d.client.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute()
+ if err != nil {
+ utils.LogError(
+ ctx,
+ &resp.Diagnostics,
+ err,
+ "Reading user",
+ fmt.Sprintf(
+ "User with ID %q or instance with ID %q does not exist in project %q.",
+ userId,
+ instanceId,
+ projectId,
+ ),
+ map[int]string{
+ http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId),
+ },
+ )
+ resp.State.RemoveResource(ctx)
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ // Map response body to schema and populate Computed attribute values
+ err = mapDataSourceFields(recordSetResp, &model, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading user",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Set refreshed state
+ diags = resp.State.Set(ctx, model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ tflog.Info(ctx, "SQLServer Flex beta instance read")
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/user/datasources_gen/user_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/user/datasources_gen/user_data_source_gen.go
new file mode 100644
index 00000000..34aef9ca
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/user/datasources_gen/user_data_source_gen.go
@@ -0,0 +1,1118 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func UserDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "instance_id": schema.StringAttribute{
+ Required: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "page": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of the page of items list to be returned.",
+ MarkdownDescription: "Number of the page of items list to be returned.",
+ },
+ "pagination": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "page": schema.Int64Attribute{
+ Computed: true,
+ },
+ "size": schema.Int64Attribute{
+ Computed: true,
+ },
+ "sort": schema.StringAttribute{
+ Computed: true,
+ },
+ "total_pages": schema.Int64Attribute{
+ Computed: true,
+ },
+ "total_rows": schema.Int64Attribute{
+ Computed: true,
+ },
+ },
+ CustomType: PaginationType{
+ ObjectType: types.ObjectType{
+ AttrTypes: PaginationValue{}.AttributeTypes(ctx),
+ },
+ },
+ Computed: true,
+ },
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "size": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "Number of items to be returned on each page.",
+ MarkdownDescription: "Number of items to be returned on each page.",
+ },
+ "sort": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Sorting of the users to be returned on each page.",
+ MarkdownDescription: "Sorting of the users to be returned on each page.",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "id.asc",
+ "id.desc",
+ "index.desc",
+ "index.asc",
+ "name.desc",
+ "name.asc",
+ "status.desc",
+ "status.asc",
+ ),
+ },
+ },
+ "users": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "tf_original_api_id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The ID of the user.",
+ MarkdownDescription: "The ID of the user.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ Description: "The current status of the user.",
+ MarkdownDescription: "The current status of the user.",
+ },
+ "username": schema.StringAttribute{
+ Computed: true,
+ Description: "The name of the user.",
+ MarkdownDescription: "The name of the user.",
+ },
+ },
+ CustomType: UsersType{
+ ObjectType: types.ObjectType{
+ AttrTypes: UsersValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "List of all users inside an instance",
+ MarkdownDescription: "List of all users inside an instance",
+ },
+ },
+ }
+}
+
+type UserModel struct {
+ InstanceId types.String `tfsdk:"instance_id"`
+ Page types.Int64 `tfsdk:"page"`
+ Pagination PaginationValue `tfsdk:"pagination"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Size types.Int64 `tfsdk:"size"`
+ Sort types.String `tfsdk:"sort"`
+ Users types.List `tfsdk:"users"`
+}
+
+var _ basetypes.ObjectTypable = PaginationType{}
+
+type PaginationType struct {
+ basetypes.ObjectType
+}
+
+func (t PaginationType) Equal(o attr.Type) bool {
+ other, ok := o.(PaginationType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t PaginationType) String() string {
+ return "PaginationType"
+}
+
+func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return nil, diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return nil, diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return nil, diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return nil, diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return nil, diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueNull() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewPaginationValueUnknown() PaginationValue {
+ return PaginationValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing PaginationValue Attribute Value",
+ "While creating a PaginationValue value, a missing attribute value was detected. "+
+ "A PaginationValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid PaginationValue Attribute Type",
+ "While creating a PaginationValue value, an invalid attribute value was detected. "+
+ "A PaginationValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra PaginationValue Attribute Value",
+ "While creating a PaginationValue value, an extra attribute value was detected. "+
+ "A PaginationValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageAttribute, ok := attributes["page"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `page is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ pageVal, ok := pageAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
+ }
+
+ sizeAttribute, ok := attributes["size"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `size is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
+ }
+
+ sortAttribute, ok := attributes["sort"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `sort is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ sortVal, ok := sortAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
+ }
+
+ totalPagesAttribute, ok := attributes["total_pages"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_pages is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
+ }
+
+ totalRowsAttribute, ok := attributes["total_rows"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `total_rows is missing from object`)
+
+ return NewPaginationValueUnknown(), diags
+ }
+
+ totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
+ }
+
+ if diags.HasError() {
+ return NewPaginationValueUnknown(), diags
+ }
+
+ return PaginationValue{
+ Page: pageVal,
+ Size: sizeVal,
+ Sort: sortVal,
+ TotalPages: totalPagesVal,
+ TotalRows: totalRowsVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
+ object, diags := NewPaginationValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewPaginationValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewPaginationValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewPaginationValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t PaginationType) ValueType(ctx context.Context) attr.Value {
+ return PaginationValue{}
+}
+
+var _ basetypes.ObjectValuable = PaginationValue{}
+
+type PaginationValue struct {
+ Page basetypes.Int64Value `tfsdk:"page"`
+ Size basetypes.Int64Value `tfsdk:"size"`
+ Sort basetypes.StringValue `tfsdk:"sort"`
+ TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
+ TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
+ state attr.ValueState
+}
+
+func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 5)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 5)
+
+ val, err = v.Page.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["page"] = val
+
+ val, err = v.Size.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["size"] = val
+
+ val, err = v.Sort.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["sort"] = val
+
+ val, err = v.TotalPages.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_pages"] = val
+
+ val, err = v.TotalRows.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["total_rows"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v PaginationValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v PaginationValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v PaginationValue) String() string {
+ return "PaginationValue"
+}
+
+func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "page": v.Page,
+ "size": v.Size,
+ "sort": v.Sort,
+ "total_pages": v.TotalPages,
+ "total_rows": v.TotalRows,
+ })
+
+ return objVal, diags
+}
+
+func (v PaginationValue) Equal(o attr.Value) bool {
+ other, ok := o.(PaginationValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Page.Equal(other.Page) {
+ return false
+ }
+
+ if !v.Size.Equal(other.Size) {
+ return false
+ }
+
+ if !v.Sort.Equal(other.Sort) {
+ return false
+ }
+
+ if !v.TotalPages.Equal(other.TotalPages) {
+ return false
+ }
+
+ if !v.TotalRows.Equal(other.TotalRows) {
+ return false
+ }
+
+ return true
+}
+
+func (v PaginationValue) Type(ctx context.Context) attr.Type {
+ return PaginationType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "page": basetypes.Int64Type{},
+ "size": basetypes.Int64Type{},
+ "sort": basetypes.StringType{},
+ "total_pages": basetypes.Int64Type{},
+ "total_rows": basetypes.Int64Type{},
+ }
+}
+
+var _ basetypes.ObjectTypable = UsersType{}
+
+type UsersType struct {
+ basetypes.ObjectType
+}
+
+func (t UsersType) Equal(o attr.Type) bool {
+ other, ok := o.(UsersType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t UsersType) String() string {
+ return "UsersType"
+}
+
+func (t UsersType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return nil, diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return nil, diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ usernameAttribute, ok := attributes["username"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `username is missing from object`)
+
+ return nil, diags
+ }
+
+ usernameVal, ok := usernameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`username expected to be basetypes.StringValue, was: %T`, usernameAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return UsersValue{
+ Id: idVal,
+ Status: statusVal,
+ Username: usernameVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewUsersValueNull() UsersValue {
+ return UsersValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewUsersValueUnknown() UsersValue {
+ return UsersValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewUsersValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (UsersValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing UsersValue Attribute Value",
+ "While creating a UsersValue value, a missing attribute value was detected. "+
+ "A UsersValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("UsersValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid UsersValue Attribute Type",
+ "While creating a UsersValue value, an invalid attribute value was detected. "+
+ "A UsersValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("UsersValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("UsersValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra UsersValue Attribute Value",
+ "While creating a UsersValue value, an extra attribute value was detected. "+
+ "A UsersValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra UsersValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewUsersValueUnknown(), diags
+ }
+
+ idAttribute, ok := attributes["id"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `id is missing from object`)
+
+ return NewUsersValueUnknown(), diags
+ }
+
+ idVal, ok := idAttribute.(basetypes.Int64Value)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
+ }
+
+ statusAttribute, ok := attributes["status"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `status is missing from object`)
+
+ return NewUsersValueUnknown(), diags
+ }
+
+ statusVal, ok := statusAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`status expected to be basetypes.StringValue, was: %T`, statusAttribute))
+ }
+
+ usernameAttribute, ok := attributes["username"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `username is missing from object`)
+
+ return NewUsersValueUnknown(), diags
+ }
+
+ usernameVal, ok := usernameAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`username expected to be basetypes.StringValue, was: %T`, usernameAttribute))
+ }
+
+ if diags.HasError() {
+ return NewUsersValueUnknown(), diags
+ }
+
+ return UsersValue{
+ Id: idVal,
+ Status: statusVal,
+ Username: usernameVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewUsersValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) UsersValue {
+ object, diags := NewUsersValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewUsersValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t UsersType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewUsersValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewUsersValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewUsersValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewUsersValueMust(UsersValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t UsersType) ValueType(ctx context.Context) attr.Value {
+ return UsersValue{}
+}
+
+var _ basetypes.ObjectValuable = UsersValue{}
+
+type UsersValue struct {
+ Id basetypes.Int64Value `tfsdk:"id"`
+ Status basetypes.StringValue `tfsdk:"status"`
+ Username basetypes.StringValue `tfsdk:"username"`
+ state attr.ValueState
+}
+
+func (v UsersValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 3)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["id"] = basetypes.Int64Type{}.TerraformType(ctx)
+ attrTypes["status"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["username"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 3)
+
+ val, err = v.Id.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["id"] = val
+
+ val, err = v.Status.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["status"] = val
+
+ val, err = v.Username.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["username"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v UsersValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v UsersValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v UsersValue) String() string {
+ return "UsersValue"
+}
+
+func (v UsersValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "id": basetypes.Int64Type{},
+ "status": basetypes.StringType{},
+ "username": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "id": v.Id,
+ "status": v.Status,
+ "username": v.Username,
+ })
+
+ return objVal, diags
+}
+
+func (v UsersValue) Equal(o attr.Value) bool {
+ other, ok := o.(UsersValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Id.Equal(other.Id) {
+ return false
+ }
+
+ if !v.Status.Equal(other.Status) {
+ return false
+ }
+
+ if !v.Username.Equal(other.Username) {
+ return false
+ }
+
+ return true
+}
+
+func (v UsersValue) Type(ctx context.Context) attr.Type {
+ return UsersType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v UsersValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "id": basetypes.Int64Type{},
+ "status": basetypes.StringType{},
+ "username": basetypes.StringType{},
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/user/mapper.go b/stackit/internal/services/sqlserverflexbeta/user/mapper.go
new file mode 100644
index 00000000..ca916d28
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/user/mapper.go
@@ -0,0 +1,198 @@
+package sqlserverflexbeta
+
+import (
+ "fmt"
+ "slices"
+ "strconv"
+
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+// mapDataSourceFields maps the API response to a dataSourceModel.
+func mapDataSourceFields(userResp *sqlserverflexbeta.GetUserResponse, model *dataSourceModel, region string) error {
+ if userResp == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if model == nil {
+ return fmt.Errorf("model input is nil")
+ }
+ user := userResp
+
+ // Handle user ID
+ var userId int64
+ if model.UserId.ValueInt64() != 0 {
+ userId = model.UserId.ValueInt64()
+ } else if user.Id != nil {
+ userId = *user.Id
+ } else {
+ return fmt.Errorf("user id not present")
+ }
+
+ // Set main attributes
+ model.Id = utils.BuildInternalTerraformId(
+ model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), strconv.FormatInt(userId, 10),
+ )
+ model.UserId = types.Int64Value(userId)
+ model.Username = types.StringPointerValue(user.Username)
+
+ // Map roles
+ if user.Roles == nil {
+ model.Roles = types.List(types.SetNull(types.StringType))
+ } else {
+ var roles []attr.Value
+ resRoles := *user.Roles
+ slices.Sort(resRoles)
+ for _, role := range resRoles {
+ roles = append(roles, types.StringValue(string(role)))
+ }
+ rolesSet, diags := types.SetValue(types.StringType, roles)
+ if diags.HasError() {
+ return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
+ }
+ model.Roles = types.List(rolesSet)
+ }
+
+ // Set remaining attributes
+ model.Host = types.StringPointerValue(user.Host)
+ model.Port = types.Int64PointerValue(user.Port)
+ model.Region = types.StringValue(region)
+ model.Status = types.StringPointerValue(user.Status)
+ model.DefaultDatabase = types.StringPointerValue(user.DefaultDatabase)
+
+ return nil
+}
+
+// mapFields maps the API response to a resourceModel.
+func mapFields(userResp *sqlserverflexbeta.GetUserResponse, model *resourceModel, region string) error {
+ if userResp == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if model == nil {
+ return fmt.Errorf("model input is nil")
+ }
+ user := userResp
+
+ // Handle user ID
+ var userId int64
+ if model.UserId.ValueInt64() != 0 {
+ userId = model.UserId.ValueInt64()
+ } else if user.Id != nil {
+ userId = *user.Id
+ } else {
+ return fmt.Errorf("user id not present")
+ }
+
+ // Set main attributes
+ model.Id = types.Int64Value(userId)
+ model.UserId = types.Int64Value(userId)
+ model.Username = types.StringPointerValue(user.Username)
+
+ // Map roles
+ if userResp.Roles != nil {
+ resRoles := *userResp.Roles
+ slices.Sort(resRoles)
+
+ var roles []attr.Value
+ for _, role := range resRoles {
+ roles = append(roles, types.StringValue(string(role)))
+ }
+
+ rolesSet, diags := types.ListValue(types.StringType, roles)
+ if diags.HasError() {
+ return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
+ }
+ model.Roles = rolesSet
+ }
+
+ // Ensure roles is not null
+ if model.Roles.IsNull() || model.Roles.IsUnknown() {
+ model.Roles = types.List(types.SetNull(types.StringType))
+ }
+
+ // Set connection details
+ model.Host = types.StringPointerValue(user.Host)
+ model.Port = types.Int64PointerValue(user.Port)
+ model.Region = types.StringValue(region)
+ return nil
+}
+
+// mapFieldsCreate maps the API response from creating a user to a resourceModel.
+func mapFieldsCreate(userResp *sqlserverflexbeta.CreateUserResponse, model *resourceModel, region string) error {
+ if userResp == nil {
+ return fmt.Errorf("response is nil")
+ }
+ if model == nil {
+ return fmt.Errorf("model input is nil")
+ }
+ user := userResp
+
+ if user.Id == nil {
+ return fmt.Errorf("user id not present")
+ }
+ userId := *user.Id
+ model.Id = types.Int64Value(userId)
+ model.UserId = types.Int64Value(userId)
+ model.Username = types.StringPointerValue(user.Username)
+
+ if user.Password == nil {
+ return fmt.Errorf("user password not present")
+ }
+ model.Password = types.StringValue(*user.Password)
+
+ if user.Roles != nil {
+ resRoles := *user.Roles
+ slices.Sort(resRoles)
+
+ var roles []attr.Value
+ for _, role := range resRoles {
+ roles = append(roles, types.StringValue(string(role)))
+ }
+ rolesList, diags := types.ListValue(types.StringType, roles)
+ if diags.HasError() {
+ return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
+ }
+ model.Roles = rolesList
+ }
+
+ if model.Roles.IsNull() || model.Roles.IsUnknown() {
+ model.Roles = types.List(types.SetNull(types.StringType))
+ }
+
+ model.Password = types.StringPointerValue(user.Password)
+ model.Uri = types.StringPointerValue(user.Uri)
+
+ model.Host = types.StringPointerValue(user.Host)
+ model.Port = types.Int64PointerValue(user.Port)
+ model.Region = types.StringValue(region)
+ model.Status = types.StringPointerValue(user.Status)
+ model.DefaultDatabase = types.StringPointerValue(user.DefaultDatabase)
+
+ return nil
+}
+
+// toCreatePayload converts a resourceModel to an API CreateUserRequestPayload.
+func toCreatePayload(
+ model *resourceModel,
+ roles []string,
+) (*sqlserverflexbeta.CreateUserRequestPayload, error) {
+ if model == nil {
+ return nil, fmt.Errorf("nil model")
+ }
+
+ pl := sqlserverflexbeta.CreateUserRequestPayload{
+ Username: conversion.StringValueToPointer(model.Username),
+ Roles: &roles,
+ }
+ slices.Sort(roles)
+ if !model.DefaultDatabase.IsNull() || !model.DefaultDatabase.IsUnknown() {
+ pl.DefaultDatabase = conversion.StringValueToPointer(model.DefaultDatabase)
+ }
+
+ return &pl, nil
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/user/mapper_test.go b/stackit/internal/services/sqlserverflexbeta/user/mapper_test.go
new file mode 100644
index 00000000..c0e09bda
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/user/mapper_test.go
@@ -0,0 +1,527 @@
+package sqlserverflexbeta
+
+import (
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+)
+
+func TestMapDataSourceFields(t *testing.T) {
+ const testRegion = "region"
+ tests := []struct {
+ description string
+ input *sqlserverflexbeta.GetUserResponse
+ region string
+ expected dataSourceModel
+ isValid bool
+ }{
+ {
+ "default_values",
+ &sqlserverflexbeta.GetUserResponse{},
+ testRegion,
+ dataSourceModel{
+ Id: types.StringValue("pid,region,iid,1"),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringNull(),
+ Roles: types.List(types.SetNull(types.StringType)),
+ Host: types.StringNull(),
+ Port: types.Int64Null(),
+ Region: types.StringValue(testRegion),
+ Status: types.StringNull(),
+ DefaultDatabase: types.StringNull(),
+ },
+ true,
+ },
+ {
+ "simple_values",
+ &sqlserverflexbeta.GetUserResponse{
+ Roles: &[]string{
+ "role_1",
+ "role_2",
+ "",
+ },
+ Username: utils.Ptr("username"),
+ Host: utils.Ptr("host"),
+ Port: utils.Ptr(int64(1234)),
+ Status: utils.Ptr("active"),
+ DefaultDatabase: utils.Ptr("default_db"),
+ },
+ testRegion,
+ dataSourceModel{
+ Id: types.StringValue("pid,region,iid,1"),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringValue("username"),
+ Roles: types.List(
+ types.SetValueMust(
+ types.StringType, []attr.Value{
+ types.StringValue(""),
+ types.StringValue("role_1"),
+ types.StringValue("role_2"),
+ },
+ ),
+ ),
+ Host: types.StringValue("host"),
+ Port: types.Int64Value(1234),
+ Region: types.StringValue(testRegion),
+ Status: types.StringValue("active"),
+ DefaultDatabase: types.StringValue("default_db"),
+ },
+ true,
+ },
+ {
+ "null_fields_and_int_conversions",
+ &sqlserverflexbeta.GetUserResponse{
+ Id: utils.Ptr(int64(1)),
+ Roles: &[]string{},
+ Username: nil,
+ Host: nil,
+ Port: utils.Ptr(int64(2123456789)),
+ },
+ testRegion,
+ dataSourceModel{
+ Id: types.StringValue("pid,region,iid,1"),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringNull(),
+ Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
+ Host: types.StringNull(),
+ Port: types.Int64Value(2123456789),
+ Region: types.StringValue(testRegion),
+ },
+ true,
+ },
+ {
+ "nil_response",
+ nil,
+ testRegion,
+ dataSourceModel{},
+ false,
+ },
+ {
+ "nil_response_2",
+ &sqlserverflexbeta.GetUserResponse{},
+ testRegion,
+ dataSourceModel{},
+ false,
+ },
+ {
+ "no_resource_id",
+ &sqlserverflexbeta.GetUserResponse{},
+ testRegion,
+ dataSourceModel{},
+ false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ state := &dataSourceModel{
+ ProjectId: tt.expected.ProjectId,
+ InstanceId: tt.expected.InstanceId,
+ UserId: tt.expected.UserId,
+ }
+ err := mapDataSourceFields(tt.input, state, tt.region)
+ if !tt.isValid && err == nil {
+ t.Fatalf("Should have failed")
+ }
+ if tt.isValid && err != nil {
+ t.Fatalf("Should not have failed: %v", err)
+ }
+ if tt.isValid {
+ diff := cmp.Diff(&tt.expected, state)
+ if diff != "" {
+ t.Fatalf("Data does not match: %s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestMapFieldsCreate(t *testing.T) {
+ const testRegion = "region"
+ tests := []struct {
+ description string
+ input *sqlserverflexbeta.CreateUserResponse
+ region string
+ expected resourceModel
+ isValid bool
+ }{
+ {
+ "default_values",
+ &sqlserverflexbeta.CreateUserResponse{
+ Id: utils.Ptr(int64(1)),
+ Password: utils.Ptr(""),
+ },
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringNull(),
+ Roles: types.List(types.SetNull(types.StringType)),
+ Password: types.StringValue(""),
+ Host: types.StringNull(),
+ Port: types.Int64Null(),
+ Region: types.StringValue(testRegion),
+ },
+ true,
+ },
+ {
+ "simple_values",
+ &sqlserverflexbeta.CreateUserResponse{
+ Id: utils.Ptr(int64(2)),
+ Roles: &[]string{
+ "role_1",
+ "role_2",
+ "",
+ },
+ Username: utils.Ptr("username"),
+ Password: utils.Ptr("password"),
+ Host: utils.Ptr("host"),
+ Port: utils.Ptr(int64(1234)),
+ Status: utils.Ptr("status"),
+ DefaultDatabase: utils.Ptr("default_db"),
+ },
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(2),
+ UserId: types.Int64Value(2),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringValue("username"),
+ Roles: types.List(
+ types.SetValueMust(
+ types.StringType, []attr.Value{
+ types.StringValue(""),
+ types.StringValue("role_1"),
+ types.StringValue("role_2"),
+ },
+ ),
+ ),
+ Password: types.StringValue("password"),
+ Host: types.StringValue("host"),
+ Port: types.Int64Value(1234),
+ Region: types.StringValue(testRegion),
+ Status: types.StringValue("status"),
+ DefaultDatabase: types.StringValue("default_db"),
+ },
+ true,
+ },
+ {
+ "null_fields_and_int_conversions",
+ &sqlserverflexbeta.CreateUserResponse{
+ Id: utils.Ptr(int64(3)),
+ Roles: &[]string{},
+ Username: nil,
+ Password: utils.Ptr(""),
+ Host: nil,
+ Port: utils.Ptr(int64(2123456789)),
+ },
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(3),
+ UserId: types.Int64Value(3),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringNull(),
+ Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
+ Password: types.StringValue(""),
+ Host: types.StringNull(),
+ Port: types.Int64Value(2123456789),
+ Region: types.StringValue(testRegion),
+ DefaultDatabase: types.StringNull(),
+ Status: types.StringNull(),
+ },
+ true,
+ },
+ {
+ "nil_response",
+ nil,
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ {
+ "nil_response_2",
+ &sqlserverflexbeta.CreateUserResponse{},
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ {
+ "no_resource_id",
+ &sqlserverflexbeta.CreateUserResponse{},
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ {
+ "no_password",
+ &sqlserverflexbeta.CreateUserResponse{
+ Id: utils.Ptr(int64(1)),
+ },
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ state := &resourceModel{
+ ProjectId: tt.expected.ProjectId,
+ InstanceId: tt.expected.InstanceId,
+ }
+ err := mapFieldsCreate(tt.input, state, tt.region)
+ if !tt.isValid && err == nil {
+ t.Fatalf("Should have failed")
+ }
+ if tt.isValid && err != nil {
+ t.Fatalf("Should not have failed: %v", err)
+ }
+ if tt.isValid {
+ diff := cmp.Diff(&tt.expected, state)
+ if diff != "" {
+ t.Fatalf("Data does not match: %s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestMapFields(t *testing.T) {
+ const testRegion = "region"
+ tests := []struct {
+ description string
+ input *sqlserverflexbeta.GetUserResponse
+ region string
+ expected resourceModel
+ isValid bool
+ }{
+ {
+ "default_values",
+ &sqlserverflexbeta.GetUserResponse{},
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringNull(),
+ Roles: types.List(types.SetNull(types.StringType)),
+ Host: types.StringNull(),
+ Port: types.Int64Null(),
+ Region: types.StringValue(testRegion),
+ },
+ true,
+ },
+ {
+ "simple_values",
+ &sqlserverflexbeta.GetUserResponse{
+ Roles: &[]string{
+ "role_2",
+ "role_1",
+ "",
+ },
+ Username: utils.Ptr("username"),
+ Host: utils.Ptr("host"),
+ Port: utils.Ptr(int64(1234)),
+ },
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(2),
+ UserId: types.Int64Value(2),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringValue("username"),
+ Roles: types.List(
+ types.SetValueMust(
+ types.StringType, []attr.Value{
+ types.StringValue(""),
+ types.StringValue("role_1"),
+ types.StringValue("role_2"),
+ },
+ ),
+ ),
+ Host: types.StringValue("host"),
+ Port: types.Int64Value(1234),
+ Region: types.StringValue(testRegion),
+ },
+ true,
+ },
+ {
+ "null_fields_and_int_conversions",
+ &sqlserverflexbeta.GetUserResponse{
+ Id: utils.Ptr(int64(1)),
+ Roles: &[]string{},
+ Username: nil,
+ Host: nil,
+ Port: utils.Ptr(int64(2123456789)),
+ },
+ testRegion,
+ resourceModel{
+ Id: types.Int64Value(1),
+ UserId: types.Int64Value(1),
+ InstanceId: types.StringValue("iid"),
+ ProjectId: types.StringValue("pid"),
+ Username: types.StringNull(),
+ Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
+ Host: types.StringNull(),
+ Port: types.Int64Value(2123456789),
+ Region: types.StringValue(testRegion),
+ },
+ true,
+ },
+ {
+ "nil_response",
+ nil,
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ {
+ "nil_response_2",
+ &sqlserverflexbeta.GetUserResponse{},
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ {
+ "no_resource_id",
+ &sqlserverflexbeta.GetUserResponse{},
+ testRegion,
+ resourceModel{},
+ false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ state := &resourceModel{
+ ProjectId: tt.expected.ProjectId,
+ InstanceId: tt.expected.InstanceId,
+ UserId: tt.expected.UserId,
+ }
+ err := mapFields(tt.input, state, tt.region)
+ if !tt.isValid && err == nil {
+ t.Fatalf("Should have failed")
+ }
+ if tt.isValid && err != nil {
+ t.Fatalf("Should not have failed: %v", err)
+ }
+ if tt.isValid {
+ diff := cmp.Diff(&tt.expected, state)
+ if diff != "" {
+ t.Fatalf("Data does not match: %s", diff)
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestToCreatePayload(t *testing.T) {
+ tests := []struct {
+ description string
+ input *resourceModel
+ inputRoles []string
+ expected *sqlserverflexbeta.CreateUserRequestPayload
+ isValid bool
+ }{
+ {
+ "default_values",
+ &resourceModel{},
+ []string{},
+ &sqlserverflexbeta.CreateUserRequestPayload{
+ Roles: &[]string{},
+ Username: nil,
+ },
+ true,
+ },
+ {
+ "default_values",
+ &resourceModel{
+ Username: types.StringValue("username"),
+ },
+ []string{
+ "role_1",
+ "role_2",
+ },
+ &sqlserverflexbeta.CreateUserRequestPayload{
+ Roles: &[]string{
+ "role_1",
+ "role_2",
+ },
+ Username: utils.Ptr("username"),
+ },
+ true,
+ },
+ {
+ "null_fields_and_int_conversions",
+ &resourceModel{
+ Username: types.StringNull(),
+ },
+ []string{
+ "",
+ },
+ &sqlserverflexbeta.CreateUserRequestPayload{
+ Roles: &[]string{
+ "",
+ },
+ Username: nil,
+ },
+ true,
+ },
+ {
+ "nil_model",
+ nil,
+ []string{},
+ nil,
+ false,
+ },
+ {
+ "nil_roles",
+ &resourceModel{
+ Username: types.StringValue("username"),
+ },
+ []string{},
+ &sqlserverflexbeta.CreateUserRequestPayload{
+ Roles: &[]string{},
+ Username: utils.Ptr("username"),
+ },
+ true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.description, func(t *testing.T) {
+ output, err := toCreatePayload(tt.input, tt.inputRoles)
+ if !tt.isValid && err == nil {
+ t.Fatalf("Should have failed")
+ }
+ if tt.isValid && err != nil {
+ t.Fatalf("Should not have failed: %v", err)
+ }
+ if tt.isValid {
+ diff := cmp.Diff(output, tt.expected)
+ if diff != "" {
+ t.Fatalf("Data does not match: %s", diff)
+ }
+ }
+ },
+ )
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/user/planModifiers.yaml b/stackit/internal/services/sqlserverflexbeta/user/planModifiers.yaml
new file mode 100644
index 00000000..43b029e8
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/user/planModifiers.yaml
@@ -0,0 +1,53 @@
+fields:
+ - name: 'id'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'instance_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'project_id'
+ validators:
+ - validate.NoSeparator
+ - validate.UUID
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'region'
+ modifiers:
+ - 'RequiresReplace'
+ - 'RequiresReplace'
+
+ - name: 'user_id'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'username'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'roles'
+ modifiers:
+ - 'UseStateForUnknown'
+ - 'RequiresReplace'
+
+ - name: 'password'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'uri'
+ modifiers:
+ - 'UseStateForUnknown'
+
+ - name: 'status'
+ modifiers:
+ - 'UseStateForUnknown'
diff --git a/stackit/internal/services/sqlserverflexbeta/user/resource.go b/stackit/internal/services/sqlserverflexbeta/user/resource.go
new file mode 100644
index 00000000..efaf3fc1
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/user/resource.go
@@ -0,0 +1,577 @@
+package sqlserverflexbeta
+
+import (
+ "context"
+ _ "embed"
+ "errors"
+ "fmt"
+ "net/http"
+ "slices"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
+ sqlserverflexbetaUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/utils"
+ sqlserverflexbetaWait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexbeta"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+
+ sqlserverflexbetaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user/resources_gen"
+)
+
+var (
+ _ resource.Resource = &userResource{}
+ _ resource.ResourceWithConfigure = &userResource{}
+ _ resource.ResourceWithImportState = &userResource{}
+ _ resource.ResourceWithModifyPlan = &userResource{}
+ _ resource.ResourceWithIdentity = &userResource{}
+ _ resource.ResourceWithValidateConfig = &userResource{}
+)
+
+func NewUserResource() resource.Resource {
+ return &userResource{}
+}
+
+// resourceModel describes the resource data model.
+type resourceModel = sqlserverflexbetaResGen.UserModel
+
+// UserResourceIdentityModel describes the resource's identity attributes.
+type UserResourceIdentityModel struct {
+ ProjectID types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ InstanceID types.String `tfsdk:"instance_id"`
+ UserID types.Int64 `tfsdk:"user_id"`
+}
+
+type userResource struct {
+ client *sqlserverflexbeta.APIClient
+ providerData core.ProviderData
+}
+
+func (r *userResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_sqlserverflexbeta_user"
+}
+
+// Configure adds the provider configured client to the resource.
+func (r *userResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
+ var ok bool
+ r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics)
+ if !ok {
+ return
+ }
+
+ apiClient := sqlserverflexbetaUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ r.client = apiClient
+ tflog.Info(ctx, "SQLServer Beta Flex user client configured")
+}
+
+// ModifyPlan implements resource.ResourceWithModifyPlan.
+// Use the modifier to set the effective region in the current plan.
+func (r *userResource) ModifyPlan(
+ ctx context.Context,
+ req resource.ModifyPlanRequest,
+ resp *resource.ModifyPlanResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var configModel resourceModel
+ // skip initial empty configuration to avoid follow-up errors
+ if req.Config.Raw.IsNull() {
+ return
+ }
+ resp.Diagnostics.Append(req.Config.Get(ctx, &configModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ var planModel resourceModel
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ //// TODO: verify if this is needed - START
+ // var planRoles []string
+ // diags := planModel.Roles.ElementsAs(ctx, &planRoles, false)
+ // resp.Diagnostics.Append(diags...)
+ // if diags.HasError() {
+ // return
+ //}
+ // slices.Sort(planRoles)
+ // var roles []attr.Value
+ // for _, role := range planRoles {
+ // roles = append(roles, types.StringValue(string(role)))
+ //}
+ // rolesSet, diags := types.ListValue(types.StringType, roles)
+ // resp.Diagnostics.Append(diags...)
+ // if diags.HasError() {
+ // return
+ //}
+ // planModel.Roles = rolesSet
+ //// TODO: verify if this is needed - END
+
+ resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+}
+
+//go:embed planModifiers.yaml
+var modifiersFileByte []byte
+
+// Schema defines the schema for the resource.
+func (r *userResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
+ s := sqlserverflexbetaResGen.UserResourceSchema(ctx)
+
+ fields, err := utils.ReadModifiersConfig(modifiersFileByte)
+ if err != nil {
+ resp.Diagnostics.AddError("error during read modifiers config file", err.Error())
+ return
+ }
+
+ err = utils.AddPlanModifiersToResourceSchema(fields, &s)
+ if err != nil {
+ resp.Diagnostics.AddError("error adding plan modifiers", err.Error())
+ return
+ }
+ resp.Schema = s
+}
+
+// IdentitySchema defines the schema for the resource's identity attributes.
+func (r *userResource) IdentitySchema(
+ _ context.Context,
+ _ resource.IdentitySchemaRequest,
+ response *resource.IdentitySchemaResponse,
+) {
+ response.IdentitySchema = identityschema.Schema{
+ Attributes: map[string]identityschema.Attribute{
+ "project_id": identityschema.StringAttribute{
+ RequiredForImport: true, // must be set during import by the practitioner
+ },
+ "region": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ "instance_id": identityschema.StringAttribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ "user_id": identityschema.Int64Attribute{
+ RequiredForImport: true, // can be defaulted by the provider configuration
+ },
+ },
+ }
+}
+
+func (r *userResource) ValidateConfig(
+ ctx context.Context,
+ req resource.ValidateConfigRequest,
+ resp *resource.ValidateConfigResponse,
+) {
+ var data resourceModel
+
+ resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ var roles []string
+ diags := data.Roles.ElementsAs(ctx, &roles, false)
+ resp.Diagnostics.Append(diags...)
+ if diags.HasError() {
+ return
+ }
+
+ var resRoles []string
+ for _, role := range roles {
+ if slices.Contains(resRoles, role) {
+ resp.Diagnostics.AddAttributeError(
+ path.Root("roles"),
+ "Attribute Configuration Error",
+ "defined roles MUST NOT contain duplicates",
+ )
+ return
+ }
+ resRoles = append(resRoles, role)
+ }
+}
+
+// Create creates the resource and sets the initial Terraform state.
+func (r *userResource) Create(
+ ctx context.Context,
+ req resource.CreateRequest,
+ resp *resource.CreateResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
+ diags := req.Plan.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ region := model.Region.ValueString()
+
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ var roles []string
+ if !model.Roles.IsNull() && !model.Roles.IsUnknown() {
+ diags = model.Roles.ElementsAs(ctx, &roles, false)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ slices.Sort(roles)
+ }
+
+ // Generate API request body from model
+ payload, err := toCreatePayload(&model, roles)
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating user", fmt.Sprintf("Creating API payload: %v", err))
+ return
+ }
+ // Create new user
+ userResp, err := r.client.CreateUserRequest(
+ ctx,
+ projectId,
+ region,
+ instanceId,
+ ).CreateUserRequestPayload(*payload).Execute()
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating user", fmt.Sprintf("Calling API: %v", err))
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ if userResp == nil || userResp.Id == nil || *userResp.Id == 0 {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating user",
+ "API didn't return user Id. A user might have been created",
+ )
+ return
+ }
+
+ userId := *userResp.Id
+ ctx = tflog.SetField(ctx, "user_id", userId)
+
+ // Set data returned by API in identity
+ identity := UserResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ UserID: types.Int64Value(userId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ err = mapFieldsCreate(userResp, &model, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating user",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ waitResp, err := sqlserverflexbetaWait.CreateUserWaitHandler(
+ ctx,
+ r.client,
+ projectId,
+ instanceId,
+ region,
+ userId,
+ ).SetSleepBeforeWait(
+ 90 * time.Second,
+ ).SetTimeout(
+ 90 * time.Minute,
+ ).WaitWithContext(ctx)
+
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "create user",
+ fmt.Sprintf("Instance creation waiting: %v", err),
+ )
+ return
+ }
+
+ if waitResp.Id == nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "create user",
+ "Instance creation waiting: returned id is nil",
+ )
+ return
+ }
+
+ // Map response body to schema
+ err = mapFields(waitResp, &model, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error creating user",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+ // Set state to fully populated data
+ diags = resp.State.Set(ctx, model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ tflog.Info(ctx, "SQLServer Flex user created")
+}
+
+// Read refreshes the Terraform state with the latest data.
+func (r *userResource) Read(
+ ctx context.Context,
+ req resource.ReadRequest,
+ resp *resource.ReadResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ var model resourceModel
+ diags := req.State.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ userId := model.UserId.ValueInt64()
+ region := r.providerData.GetRegionWithOverride(model.Region)
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "user_id", userId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ recordSetResp, err := r.client.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute()
+ if err != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(
+ err,
+ &oapiErr,
+ )
+ //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
+ if ok && oapiErr.StatusCode == http.StatusNotFound {
+ resp.State.RemoveResource(ctx)
+ return
+ }
+ core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading user", fmt.Sprintf("Calling API: %v", err))
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ // Map response body to schema
+ err = mapFields(recordSetResp, &model, region)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error reading user",
+ fmt.Sprintf("Processing API payload: %v", err),
+ )
+ return
+ }
+
+ // Set data returned by API in identity
+ identity := UserResourceIdentityModel{
+ ProjectID: types.StringValue(projectId),
+ Region: types.StringValue(region),
+ InstanceID: types.StringValue(instanceId),
+ UserID: types.Int64Value(userId),
+ }
+ resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Set refreshed state
+ diags = resp.State.Set(ctx, model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+ tflog.Info(ctx, "SQLServer Flex user read")
+}
+
+// Update updates the resource and sets the updated Terraform state on success.
+func (r *userResource) Update(
+ ctx context.Context,
+ _ resource.UpdateRequest,
+ resp *resource.UpdateResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ // Update shouldn't be called
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error updating user",
+ "an SQL server user can not be updated, only created",
+ )
+}
+
+// Delete deletes the resource and removes the Terraform state on success.
+func (r *userResource) Delete(
+ ctx context.Context,
+ req resource.DeleteRequest,
+ resp *resource.DeleteResponse,
+) { // nolint:gocritic // function signature required by Terraform
+ // Retrieve values from plan
+ var model resourceModel
+ diags := req.State.Get(ctx, &model)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ ctx = core.InitProviderContext(ctx)
+
+ projectId := model.ProjectId.ValueString()
+ instanceId := model.InstanceId.ValueString()
+ userId := model.UserId.ValueInt64()
+ region := model.Region.ValueString()
+ ctx = tflog.SetField(ctx, "project_id", projectId)
+ ctx = tflog.SetField(ctx, "instance_id", instanceId)
+ ctx = tflog.SetField(ctx, "user_id", userId)
+ ctx = tflog.SetField(ctx, "region", region)
+
+ // Delete existing record set
+ // err := r.client.DeleteUserRequest(ctx, projectId, region, instanceId, userId).Execute()
+ err := r.client.DeleteUserRequestExecute(ctx, projectId, region, instanceId, userId)
+ if err != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ // TODO err handling
+ return
+ }
+
+ switch oapiErr.StatusCode {
+ case http.StatusNotFound:
+ resp.State.RemoveResource(ctx)
+ return
+ // case http.StatusInternalServerError:
+ // tflog.Warn(ctx, "[delete user] Wait handler got error 500")
+ // return false, nil, nil
+ default:
+ // TODO err handling
+ return
+ }
+ }
+ // Delete existing record set
+ _, err = sqlserverflexbetaWait.DeleteUserWaitHandler(ctx, r.client, projectId, region, instanceId, userId).
+ WaitWithContext(ctx)
+ if err != nil {
+ core.LogAndAddError(ctx, &resp.Diagnostics, "User Delete Error", fmt.Sprintf("Calling API: %v", err))
+ return
+ }
+
+ ctx = core.LogResponse(ctx)
+
+ resp.State.RemoveResource(ctx)
+
+ tflog.Info(ctx, "SQLServer Flex user deleted")
+}
+
+// ImportState imports a resource into the Terraform state on success.
+// The expected format of the resource import identifier is: project_id,zone_id,record_set_id
+func (r *userResource) ImportState(
+ ctx context.Context,
+ req resource.ImportStateRequest,
+ resp *resource.ImportStateResponse,
+) {
+ ctx = core.InitProviderContext(ctx)
+
+ if req.ID != "" {
+ idParts := strings.Split(req.ID, core.Separator)
+
+ if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" {
+ core.LogAndAddError(
+ ctx, &resp.Diagnostics,
+ "Error importing user",
+ fmt.Sprintf(
+ "Expected import identifier with format [project_id],[region],[instance_id],[user_id], got %q",
+ req.ID,
+ ),
+ )
+ return
+ }
+
+ userId, err := strconv.ParseInt(idParts[3], 10, 64)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ &resp.Diagnostics,
+ "Error importing user",
+ fmt.Sprintf("Invalid user_id format: %q. It must be a valid integer.", idParts[3]),
+ )
+ return
+ }
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_id"), userId)...)
+
+ tflog.Info(ctx, "SQLServer Flex user state imported")
+
+ return
+ }
+
+ // If no ID is provided, attempt to read identity attributes from the import configuration
+ var identityData UserResourceIdentityModel
+ resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ projectId := identityData.ProjectID.ValueString()
+ region := identityData.Region.ValueString()
+ instanceId := identityData.InstanceID.ValueString()
+ userId := identityData.UserID.ValueInt64()
+
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), projectId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), region)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), instanceId)...)
+ resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_id"), userId)...)
+
+ core.LogAndAddWarning(
+ ctx,
+ &resp.Diagnostics,
+ "SQLServer Flex user imported with empty password",
+ "The user password is not imported as it is only available upon creation of a new user. The password field will be empty.",
+ )
+ tflog.Info(ctx, "SQLServer Flex user state imported")
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/user/resources_gen/user_resource_gen.go b/stackit/internal/services/sqlserverflexbeta/user/resources_gen/user_resource_gen.go
new file mode 100644
index 00000000..f181f79c
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/user/resources_gen/user_resource_gen.go
@@ -0,0 +1,111 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexbeta
+
+import (
+ "context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+)
+
+func UserResourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "default_database": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The default database for a user of the instance.",
+ MarkdownDescription: "The default database for a user of the instance.",
+ },
+ "host": schema.StringAttribute{
+ Computed: true,
+ Description: "The host of the instance in which the user belongs to.",
+ MarkdownDescription: "The host of the instance in which the user belongs to.",
+ },
+ "id": schema.Int64Attribute{
+ Computed: true,
+ Description: "The ID of the user.",
+ MarkdownDescription: "The ID of the user.",
+ },
+ "instance_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
+ "password": schema.StringAttribute{
+ Computed: true,
+ Description: "The password for the user.",
+ MarkdownDescription: "The password for the user.",
+ },
+ "port": schema.Int64Attribute{
+ Computed: true,
+ Description: "The port of the instance in which the user belongs to.",
+ MarkdownDescription: "The port of the instance in which the user belongs to.",
+ },
+ "project_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "roles": schema.ListAttribute{
+ ElementType: types.StringType,
+ Required: true,
+ Description: "A list containing the user roles for the instance. A list with the valid user roles can be retrieved using the List Roles endpoint.",
+ MarkdownDescription: "A list containing the user roles for the instance. A list with the valid user roles can be retrieved using the List Roles endpoint.",
+ },
+ "status": schema.StringAttribute{
+ Computed: true,
+ Description: "The current status of the user.",
+ MarkdownDescription: "The current status of the user.",
+ },
+ "uri": schema.StringAttribute{
+ Computed: true,
+ Description: "The connection string for the user to the instance.",
+ MarkdownDescription: "The connection string for the user to the instance.",
+ },
+ "user_id": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the user.",
+ MarkdownDescription: "The ID of the user.",
+ },
+ "username": schema.StringAttribute{
+ Required: true,
+ Description: "The name of the user.",
+ MarkdownDescription: "The name of the user.",
+ },
+ },
+ }
+}
+
+type UserModel struct {
+ DefaultDatabase types.String `tfsdk:"default_database"`
+ Host types.String `tfsdk:"host"`
+ Id types.Int64 `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Password types.String `tfsdk:"password"`
+ Port types.Int64 `tfsdk:"port"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Roles types.List `tfsdk:"roles"`
+ Status types.String `tfsdk:"status"`
+ Uri types.String `tfsdk:"uri"`
+ UserId types.Int64 `tfsdk:"user_id"`
+ Username types.String `tfsdk:"username"`
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/utils/util.go b/stackit/internal/services/sqlserverflexbeta/utils/util.go
new file mode 100644
index 00000000..d8ba984b
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/utils/util.go
@@ -0,0 +1,48 @@
+package utils
+
+import (
+ "context"
+ "fmt"
+
+ sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+func ConfigureClient(
+ ctx context.Context,
+ providerData *core.ProviderData,
+ diags *diag.Diagnostics,
+) *sqlserverflex.APIClient {
+ apiClientConfigOptions := []config.ConfigurationOption{
+ config.WithCustomAuth(providerData.RoundTripper),
+ utils.UserAgentConfigOption(providerData.Version),
+ }
+ if providerData.SQLServerFlexCustomEndpoint != "" {
+ apiClientConfigOptions = append(
+ apiClientConfigOptions,
+ config.WithEndpoint(providerData.SQLServerFlexCustomEndpoint),
+ )
+ } else {
+ apiClientConfigOptions = append(apiClientConfigOptions, config.WithRegion(providerData.GetRegion()))
+ }
+ apiClient, err := sqlserverflex.NewAPIClient(apiClientConfigOptions...)
+ if err != nil {
+ core.LogAndAddError(
+ ctx,
+ diags,
+ "Error configuring API client",
+ fmt.Sprintf(
+ "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration",
+ err,
+ ),
+ )
+ return nil
+ }
+
+ return apiClient
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/utils/util_test.go b/stackit/internal/services/sqlserverflexbeta/utils/util_test.go
new file mode 100644
index 00000000..92fb1ae9
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/utils/util_test.go
@@ -0,0 +1,98 @@
+package utils
+
+import (
+ "context"
+ "os"
+ "reflect"
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ sdkClients "github.com/stackitcloud/stackit-sdk-go/core/clients"
+ "github.com/stackitcloud/stackit-sdk-go/core/config"
+
+ sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
+)
+
+const (
+ testVersion = "1.2.3"
+ testCustomEndpoint = "https://sqlserverflex-custom-endpoint.api.stackit.cloud"
+)
+
+func TestConfigureClient(t *testing.T) {
+ /* mock authentication by setting service account token env variable */
+ os.Clearenv()
+ err := os.Setenv(sdkClients.ServiceAccountToken, "mock-val")
+ if err != nil {
+ t.Errorf("error setting env variable: %v", err)
+ }
+
+ type args struct {
+ providerData *core.ProviderData
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ expected *sqlserverflex.APIClient
+ }{
+ {
+ name: "default endpoint",
+ args: args{
+ providerData: &core.ProviderData{
+ Version: testVersion,
+ },
+ },
+ expected: func() *sqlserverflex.APIClient {
+ apiClient, err := sqlserverflex.NewAPIClient(
+ config.WithRegion("eu01"),
+ utils.UserAgentConfigOption(testVersion),
+ )
+ if err != nil {
+ t.Errorf("error configuring client: %v", err)
+ }
+ return apiClient
+ }(),
+ wantErr: false,
+ },
+ {
+ name: "custom endpoint",
+ args: args{
+ providerData: &core.ProviderData{
+ Version: testVersion,
+ SQLServerFlexCustomEndpoint: testCustomEndpoint,
+ },
+ },
+ expected: func() *sqlserverflex.APIClient {
+ apiClient, err := sqlserverflex.NewAPIClient(
+ utils.UserAgentConfigOption(testVersion),
+ config.WithEndpoint(testCustomEndpoint),
+ )
+ if err != nil {
+ t.Errorf("error configuring client: %v", err)
+ }
+ return apiClient
+ }(),
+ wantErr: false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.name, func(t *testing.T) {
+ ctx := context.Background()
+ diags := diag.Diagnostics{}
+
+ actual := ConfigureClient(ctx, tt.args.providerData, &diags)
+ if diags.HasError() != tt.wantErr {
+ t.Errorf("ConfigureClient() error = %v, want %v", diags.HasError(), tt.wantErr)
+ }
+
+ if !reflect.DeepEqual(actual, tt.expected) {
+ t.Errorf("ConfigureClient() = %v, want %v", actual, tt.expected)
+ }
+ },
+ )
+ }
+}
diff --git a/stackit/internal/services/sqlserverflexbeta/versions/datasources_gen/version_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/versions/datasources_gen/version_data_source_gen.go
new file mode 100644
index 00000000..239b44d3
--- /dev/null
+++ b/stackit/internal/services/sqlserverflexbeta/versions/datasources_gen/version_data_source_gen.go
@@ -0,0 +1,569 @@
+// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
+
+package sqlserverflexbeta
+
+import (
+ "context"
+ "fmt"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-go/tftypes"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+)
+
+func VersionDataSourceSchema(ctx context.Context) schema.Schema {
+ return schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "project_id": schema.StringAttribute{
+ Required: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Required: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
+ "versions": schema.ListNestedAttribute{
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "beta": schema.BoolAttribute{
+ Computed: true,
+ Description: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.",
+ MarkdownDescription: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.",
+ },
+ "deprecated": schema.StringAttribute{
+ Computed: true,
+ Description: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.",
+ MarkdownDescription: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.",
+ },
+ "recommend": schema.BoolAttribute{
+ Computed: true,
+ Description: "Flag if the version is recommend by the STACKIT Team.",
+ MarkdownDescription: "Flag if the version is recommend by the STACKIT Team.",
+ },
+ "version": schema.StringAttribute{
+ Computed: true,
+ Description: "The sqlserver version used for the instance.",
+ MarkdownDescription: "The sqlserver version used for the instance.",
+ },
+ },
+ CustomType: VersionsType{
+ ObjectType: types.ObjectType{
+ AttrTypes: VersionsValue{}.AttributeTypes(ctx),
+ },
+ },
+ },
+ Computed: true,
+ Description: "A list containing available sqlserver versions.",
+ MarkdownDescription: "A list containing available sqlserver versions.",
+ },
+ },
+ }
+}
+
+type VersionModel struct {
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Versions types.List `tfsdk:"versions"`
+}
+
+var _ basetypes.ObjectTypable = VersionsType{}
+
+type VersionsType struct {
+ basetypes.ObjectType
+}
+
+func (t VersionsType) Equal(o attr.Type) bool {
+ other, ok := o.(VersionsType)
+
+ if !ok {
+ return false
+ }
+
+ return t.ObjectType.Equal(other.ObjectType)
+}
+
+func (t VersionsType) String() string {
+ return "VersionsType"
+}
+
+func (t VersionsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributes := in.Attributes()
+
+ betaAttribute, ok := attributes["beta"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `beta is missing from object`)
+
+ return nil, diags
+ }
+
+ betaVal, ok := betaAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute))
+ }
+
+ deprecatedAttribute, ok := attributes["deprecated"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `deprecated is missing from object`)
+
+ return nil, diags
+ }
+
+ deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute))
+ }
+
+ recommendAttribute, ok := attributes["recommend"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `recommend is missing from object`)
+
+ return nil, diags
+ }
+
+ recommendVal, ok := recommendAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute))
+ }
+
+ versionAttribute, ok := attributes["version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `version is missing from object`)
+
+ return nil, diags
+ }
+
+ versionVal, ok := versionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute))
+ }
+
+ if diags.HasError() {
+ return nil, diags
+ }
+
+ return VersionsValue{
+ Beta: betaVal,
+ Deprecated: deprecatedVal,
+ Recommend: recommendVal,
+ Version: versionVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewVersionsValueNull() VersionsValue {
+ return VersionsValue{
+ state: attr.ValueStateNull,
+ }
+}
+
+func NewVersionsValueUnknown() VersionsValue {
+ return VersionsValue{
+ state: attr.ValueStateUnknown,
+ }
+}
+
+func NewVersionsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (VersionsValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
+ ctx := context.Background()
+
+ for name, attributeType := range attributeTypes {
+ attribute, ok := attributes[name]
+
+ if !ok {
+ diags.AddError(
+ "Missing VersionsValue Attribute Value",
+ "While creating a VersionsValue value, a missing attribute value was detected. "+
+ "A VersionsValue must contain values for all attributes, even if null or unknown. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
+ )
+
+ continue
+ }
+
+ if !attributeType.Equal(attribute.Type(ctx)) {
+ diags.AddError(
+ "Invalid VersionsValue Attribute Type",
+ "While creating a VersionsValue value, an invalid attribute value was detected. "+
+ "A VersionsValue must use a matching attribute type for the value. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
+ fmt.Sprintf("VersionsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
+ )
+ }
+ }
+
+ for name := range attributes {
+ _, ok := attributeTypes[name]
+
+ if !ok {
+ diags.AddError(
+ "Extra VersionsValue Attribute Value",
+ "While creating a VersionsValue value, an extra attribute value was detected. "+
+ "A VersionsValue must not contain values beyond the expected attribute types. "+
+ "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
+ fmt.Sprintf("Extra VersionsValue Attribute Name: %s", name),
+ )
+ }
+ }
+
+ if diags.HasError() {
+ return NewVersionsValueUnknown(), diags
+ }
+
+ betaAttribute, ok := attributes["beta"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `beta is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ betaVal, ok := betaAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute))
+ }
+
+ deprecatedAttribute, ok := attributes["deprecated"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `deprecated is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute))
+ }
+
+ recommendAttribute, ok := attributes["recommend"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `recommend is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ recommendVal, ok := recommendAttribute.(basetypes.BoolValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute))
+ }
+
+ versionAttribute, ok := attributes["version"]
+
+ if !ok {
+ diags.AddError(
+ "Attribute Missing",
+ `version is missing from object`)
+
+ return NewVersionsValueUnknown(), diags
+ }
+
+ versionVal, ok := versionAttribute.(basetypes.StringValue)
+
+ if !ok {
+ diags.AddError(
+ "Attribute Wrong Type",
+ fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute))
+ }
+
+ if diags.HasError() {
+ return NewVersionsValueUnknown(), diags
+ }
+
+ return VersionsValue{
+ Beta: betaVal,
+ Deprecated: deprecatedVal,
+ Recommend: recommendVal,
+ Version: versionVal,
+ state: attr.ValueStateKnown,
+ }, diags
+}
+
+func NewVersionsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) VersionsValue {
+ object, diags := NewVersionsValue(attributeTypes, attributes)
+
+ if diags.HasError() {
+ // This could potentially be added to the diag package.
+ diagsStrings := make([]string, 0, len(diags))
+
+ for _, diagnostic := range diags {
+ diagsStrings = append(diagsStrings, fmt.Sprintf(
+ "%s | %s | %s",
+ diagnostic.Severity(),
+ diagnostic.Summary(),
+ diagnostic.Detail()))
+ }
+
+ panic("NewVersionsValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
+ }
+
+ return object
+}
+
+func (t VersionsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
+ if in.Type() == nil {
+ return NewVersionsValueNull(), nil
+ }
+
+ if !in.Type().Equal(t.TerraformType(ctx)) {
+ return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
+ }
+
+ if !in.IsKnown() {
+ return NewVersionsValueUnknown(), nil
+ }
+
+ if in.IsNull() {
+ return NewVersionsValueNull(), nil
+ }
+
+ attributes := map[string]attr.Value{}
+
+ val := map[string]tftypes.Value{}
+
+ err := in.As(&val)
+
+ if err != nil {
+ return nil, err
+ }
+
+ for k, v := range val {
+ a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
+
+ if err != nil {
+ return nil, err
+ }
+
+ attributes[k] = a
+ }
+
+ return NewVersionsValueMust(VersionsValue{}.AttributeTypes(ctx), attributes), nil
+}
+
+func (t VersionsType) ValueType(ctx context.Context) attr.Value {
+ return VersionsValue{}
+}
+
+var _ basetypes.ObjectValuable = VersionsValue{}
+
+type VersionsValue struct {
+ Beta basetypes.BoolValue `tfsdk:"beta"`
+ Deprecated basetypes.StringValue `tfsdk:"deprecated"`
+ Recommend basetypes.BoolValue `tfsdk:"recommend"`
+ Version basetypes.StringValue `tfsdk:"version"`
+ state attr.ValueState
+}
+
+func (v VersionsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
+ attrTypes := make(map[string]tftypes.Type, 4)
+
+ var val tftypes.Value
+ var err error
+
+ attrTypes["beta"] = basetypes.BoolType{}.TerraformType(ctx)
+ attrTypes["deprecated"] = basetypes.StringType{}.TerraformType(ctx)
+ attrTypes["recommend"] = basetypes.BoolType{}.TerraformType(ctx)
+ attrTypes["version"] = basetypes.StringType{}.TerraformType(ctx)
+
+ objectType := tftypes.Object{AttributeTypes: attrTypes}
+
+ switch v.state {
+ case attr.ValueStateKnown:
+ vals := make(map[string]tftypes.Value, 4)
+
+ val, err = v.Beta.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["beta"] = val
+
+ val, err = v.Deprecated.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["deprecated"] = val
+
+ val, err = v.Recommend.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["recommend"] = val
+
+ val, err = v.Version.ToTerraformValue(ctx)
+
+ if err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ vals["version"] = val
+
+ if err := tftypes.ValidateValue(objectType, vals); err != nil {
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), err
+ }
+
+ return tftypes.NewValue(objectType, vals), nil
+ case attr.ValueStateNull:
+ return tftypes.NewValue(objectType, nil), nil
+ case attr.ValueStateUnknown:
+ return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
+ default:
+ panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
+ }
+}
+
+func (v VersionsValue) IsNull() bool {
+ return v.state == attr.ValueStateNull
+}
+
+func (v VersionsValue) IsUnknown() bool {
+ return v.state == attr.ValueStateUnknown
+}
+
+func (v VersionsValue) String() string {
+ return "VersionsValue"
+}
+
+func (v VersionsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
+ var diags diag.Diagnostics
+
+ attributeTypes := map[string]attr.Type{
+ "beta": basetypes.BoolType{},
+ "deprecated": basetypes.StringType{},
+ "recommend": basetypes.BoolType{},
+ "version": basetypes.StringType{},
+ }
+
+ if v.IsNull() {
+ return types.ObjectNull(attributeTypes), diags
+ }
+
+ if v.IsUnknown() {
+ return types.ObjectUnknown(attributeTypes), diags
+ }
+
+ objVal, diags := types.ObjectValue(
+ attributeTypes,
+ map[string]attr.Value{
+ "beta": v.Beta,
+ "deprecated": v.Deprecated,
+ "recommend": v.Recommend,
+ "version": v.Version,
+ })
+
+ return objVal, diags
+}
+
+func (v VersionsValue) Equal(o attr.Value) bool {
+ other, ok := o.(VersionsValue)
+
+ if !ok {
+ return false
+ }
+
+ if v.state != other.state {
+ return false
+ }
+
+ if v.state != attr.ValueStateKnown {
+ return true
+ }
+
+ if !v.Beta.Equal(other.Beta) {
+ return false
+ }
+
+ if !v.Deprecated.Equal(other.Deprecated) {
+ return false
+ }
+
+ if !v.Recommend.Equal(other.Recommend) {
+ return false
+ }
+
+ if !v.Version.Equal(other.Version) {
+ return false
+ }
+
+ return true
+}
+
+func (v VersionsValue) Type(ctx context.Context) attr.Type {
+ return VersionsType{
+ basetypes.ObjectType{
+ AttrTypes: v.AttributeTypes(ctx),
+ },
+ }
+}
+
+func (v VersionsValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
+ return map[string]attr.Type{
+ "beta": basetypes.BoolType{},
+ "deprecated": basetypes.StringType{},
+ "recommend": basetypes.BoolType{},
+ "version": basetypes.StringType{},
+ }
+}
diff --git a/stackit/internal/utils/attributes.go b/stackit/internal/utils/attributes.go
index 4572960f..26d228c3 100644
--- a/stackit/internal/utils/attributes.go
+++ b/stackit/internal/utils/attributes.go
@@ -10,7 +10,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
)
type attributeGetter interface {
diff --git a/stackit/internal/utils/planModifiers.go b/stackit/internal/utils/planModifiers.go
new file mode 100644
index 00000000..ee9b35f3
--- /dev/null
+++ b/stackit/internal/utils/planModifiers.go
@@ -0,0 +1,229 @@
+package utils
+
+import (
+ "fmt"
+ "log/slog"
+ "reflect"
+ "slices"
+
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
+ "github.com/iancoleman/strcase"
+
+ "gopkg.in/yaml.v3"
+)
+
+type Field struct {
+ Name string `yaml:"name"`
+ Modifiers []*string `yaml:"modifiers"`
+}
+
+type Fields struct {
+ Fields []*Field `yaml:"fields"`
+}
+
+var validModifiers = []string{
+ "UseStateForUnknown",
+ "RequiresReplace",
+}
+
+func ReadModifiersConfig(content []byte) (*Fields, error) {
+ var fields Fields
+ err := yaml.Unmarshal(content, &fields)
+ if err != nil {
+ return nil, err
+ }
+ return &fields, nil
+}
+
+func AddPlanModifiersToResourceSchema(fields *Fields, s *schema.Schema) error {
+ err := validateFields(fields)
+ if err != nil {
+ return err
+ }
+
+ resAttr, err := handleAttributes("", s.Attributes, fields)
+ if err != nil {
+ return err
+ }
+ s.Attributes = resAttr
+
+ return nil
+}
+
+func handleAttributes(prefix string, attributes map[string]schema.Attribute, fields *Fields) (map[string]schema.Attribute, error) {
+ fieldMap := fieldListToMap(fields)
+ for attrName, attrValue := range attributes {
+ attrNameSnake := strcase.ToSnake(attrName)
+ if prefix != "" {
+ attrNameSnake = prefix + "." + attrNameSnake
+ }
+ switch reflect.TypeOf(attrValue).String() {
+ case "schema.BoolAttribute":
+ if field, ok := fieldMap[attrNameSnake]; ok {
+ res, err := handleBoolPlanModifiers(attrValue, field)
+ if err != nil {
+ return nil, err
+ }
+ attributes[attrName] = res
+ }
+ case "schema.Int64Attribute":
+ if field, ok := fieldMap[attrNameSnake]; ok {
+ res, err := handleInt64PlanModifiers(attrValue, field)
+ if err != nil {
+ return nil, err
+ }
+ attributes[attrName] = res
+ }
+ case "schema.StringAttribute":
+ if field, ok := fieldMap[attrNameSnake]; ok {
+ res, err := handleStringPlanModifiers(attrValue, field)
+ if err != nil {
+ return nil, err
+ }
+ attributes[attrName] = res
+ }
+ case "schema.ListAttribute":
+ if field, ok := fieldMap[attrNameSnake]; ok {
+ res, err := handleListPlanModifiers(attrValue, field)
+ if err != nil {
+ return nil, err
+ }
+ attributes[attrName] = res
+ }
+ case "schema.SingleNestedAttribute":
+ nested, ok := attrValue.(schema.SingleNestedAttribute)
+ if !ok {
+ if _, ok := attrValue.(interface {
+ GetAttributes() map[string]schema.Attribute
+ }); ok {
+ return nil, fmt.Errorf("unsupported type for single nested attribute")
+ }
+ }
+
+ res, err := handleAttributes(attrName, nested.Attributes, fields)
+ if err != nil {
+ return nil, err
+ }
+ nested.Attributes = res
+ attributes[attrName] = nested
+ default:
+ slog.Warn("type currently not supported", "type", reflect.TypeOf(attrValue).String())
+ }
+ }
+ return attributes, nil
+}
+
+func handleBoolPlanModifiers(
+ attr schema.Attribute,
+ fields []*string,
+) (schema.Attribute, error) {
+ a, ok := attr.(schema.BoolAttribute)
+ if !ok {
+ return nil, fmt.Errorf("field is not a string attribute")
+ }
+
+ for _, v := range fields {
+ switch *v {
+ case "RequiresReplace":
+ a.PlanModifiers = append(a.PlanModifiers, boolplanmodifier.RequiresReplace())
+ case "UseStateForUnknown":
+ a.PlanModifiers = append(a.PlanModifiers, boolplanmodifier.UseStateForUnknown())
+ }
+ }
+ return a, nil
+}
+
+func handleStringPlanModifiers(
+ attr schema.Attribute,
+ fields []*string,
+) (schema.Attribute, error) {
+ a, ok := attr.(schema.StringAttribute)
+ if !ok {
+ return nil, fmt.Errorf("field is not a string attribute")
+ }
+
+ for _, v := range fields {
+ switch *v {
+ case "RequiresReplace":
+ a.PlanModifiers = append(a.PlanModifiers, stringplanmodifier.RequiresReplace())
+ case "UseStateForUnknown":
+ a.PlanModifiers = append(a.PlanModifiers, stringplanmodifier.UseStateForUnknown())
+ }
+ }
+ return a, nil
+}
+
+func handleInt64PlanModifiers(
+ attr schema.Attribute,
+ fields []*string,
+) (schema.Attribute, error) {
+ a, ok := attr.(schema.Int64Attribute)
+ if !ok {
+ return nil, fmt.Errorf("field is not a string attribute")
+ }
+
+ for _, v := range fields {
+ switch *v {
+ case "RequiresReplace":
+ a.PlanModifiers = append(a.PlanModifiers, int64planmodifier.RequiresReplace())
+ case "UseStateForUnknown":
+ a.PlanModifiers = append(a.PlanModifiers, int64planmodifier.UseStateForUnknown())
+ }
+ }
+ return a, nil
+}
+
+func handleListPlanModifiers(
+ attr schema.Attribute,
+ fields []*string,
+) (schema.Attribute, error) {
+ a, ok := attr.(schema.ListAttribute)
+ if !ok {
+ return nil, fmt.Errorf("field is not a string attribute")
+ }
+
+ for _, v := range fields {
+ switch *v {
+ case "RequiresReplace":
+ a.PlanModifiers = append(a.PlanModifiers, listplanmodifier.RequiresReplace())
+ case "UseStateForUnknown":
+ a.PlanModifiers = append(a.PlanModifiers, listplanmodifier.UseStateForUnknown())
+ }
+ }
+ return a, nil
+}
+
+func validateFields(fields *Fields) error {
+ if fields == nil {
+ return nil
+ }
+ for _, field := range fields.Fields {
+ for _, modifier := range field.Modifiers {
+ if *modifier == "" {
+ return fmt.Errorf("modifier %s is required", *modifier)
+ }
+ if !slices.Contains(validModifiers, *modifier) {
+ return fmt.Errorf("modifier %s is invalid", *modifier)
+ }
+ }
+ }
+ return nil
+}
+
+func fieldListToMap(fields *Fields) map[string][]*string {
+ res := make(map[string][]*string)
+
+ if fields != nil {
+ for _, field := range fields.Fields {
+ res[field.Name] = field.Modifiers
+ }
+ } else {
+ slog.Warn("no fields available")
+ }
+
+ return res
+}
diff --git a/stackit/internal/utils/planModifiers_test.go b/stackit/internal/utils/planModifiers_test.go
new file mode 100644
index 00000000..337ea36f
--- /dev/null
+++ b/stackit/internal/utils/planModifiers_test.go
@@ -0,0 +1,224 @@
+package utils
+
+import (
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+)
+
+func TestReadModifiersConfig(t *testing.T) {
+ testcases := []struct {
+ name string
+ content []byte
+ wantErr bool
+ }{
+ {
+ name: "valid yaml",
+ content: []byte(`
+fields:
+ - name: 'id'
+ modifiers:
+ - 'UseStateForUnknown'
+`),
+ wantErr: false,
+ },
+ {
+ name: "invalid yaml",
+ content: []byte(`invalid: yaml: :`),
+ wantErr: true,
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ _, err := ReadModifiersConfig(tc.content)
+ if (err != nil) != tc.wantErr {
+ t.Errorf("ReadModifiersConfig() error = %v, wantErr %v", err, tc.wantErr)
+ }
+ },
+ )
+ }
+}
+
+func TestAddPlanModifiersToResourceSchema(t *testing.T) {
+ testcases := []struct {
+ name string
+ fields *Fields
+ sch *schema.Schema
+ wantErr bool
+ }{
+ {
+ name: "full coverage - all types and nested structures",
+ fields: &Fields{
+ Fields: []*Field{
+ {
+ Name: "string_attr",
+ Modifiers: []*string{utils.Ptr("RequiresReplace"), utils.Ptr("UseStateForUnknown")},
+ },
+ {Name: "bool_attr", Modifiers: []*string{utils.Ptr("RequiresReplace")}},
+ {Name: "int_attr", Modifiers: []*string{utils.Ptr("UseStateForUnknown")}},
+ {Name: "list_attr", Modifiers: []*string{utils.Ptr("RequiresReplace")}},
+ {Name: "Nested.sub_string", Modifiers: []*string{utils.Ptr("RequiresReplace")}},
+ },
+ },
+ sch: &schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "StringAttr": schema.StringAttribute{},
+ "BoolAttr": schema.BoolAttribute{},
+ "IntAttr": schema.Int64Attribute{},
+ "ListAttr": schema.ListAttribute{},
+ "Nested": schema.SingleNestedAttribute{
+ Attributes: map[string]schema.Attribute{
+ "SubString": schema.StringAttribute{},
+ },
+ },
+ "Unsupported": schema.MapAttribute{ElementType: types.StringType}, // Triggers default/warn case
+ },
+ },
+ wantErr: false,
+ },
+ {
+ name: "validation error - invalid modifier",
+ fields: &Fields{
+ Fields: []*Field{
+ {Name: "id", Modifiers: []*string{utils.Ptr("InvalidModifier")}},
+ },
+ },
+ sch: &schema.Schema{
+ Attributes: map[string]schema.Attribute{"id": schema.StringAttribute{}},
+ },
+ wantErr: true,
+ },
+ {
+ name: "validation error - empty modifier",
+ fields: &Fields{
+ Fields: []*Field{
+ {Name: "id", Modifiers: []*string{utils.Ptr("")}},
+ },
+ },
+ sch: &schema.Schema{},
+ wantErr: true,
+ },
+ {
+ name: "nil fields - should return nil",
+ fields: nil,
+ sch: &schema.Schema{},
+ wantErr: false,
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ err := AddPlanModifiersToResourceSchema(tc.fields, tc.sch)
+
+ if (err != nil) != tc.wantErr {
+ t.Fatalf("AddPlanModifiersToResourceSchema() error = %v, wantErr %v", err, tc.wantErr)
+ }
+
+ if !tc.wantErr && tc.name == "full coverage - all types and nested structures" {
+ // Check StringAttr
+ if sAttr, ok := tc.sch.Attributes["StringAttr"].(schema.StringAttribute); ok {
+ if len(sAttr.PlanModifiers) != 2 {
+ t.Errorf("StringAttr: expected 2 modifiers, got %d", len(sAttr.PlanModifiers))
+ }
+ }
+
+ // Check Nested Sub-Attribute
+ if nested, ok := tc.sch.Attributes["Nested"].(schema.SingleNestedAttribute); ok {
+ if subAttr, ok := nested.Attributes["SubString"].(schema.StringAttribute); ok {
+ if len(subAttr.PlanModifiers) != 1 {
+ // Dies schlug vorher fehl, weil der Prefix "Nested" statt "nested" war
+ t.Errorf("Nested SubString: expected 1 modifier, got %d", len(subAttr.PlanModifiers))
+ }
+ } else {
+ t.Error("SubString attribute not found in Nested")
+ }
+ } else {
+ t.Error("Nested attribute not found")
+ }
+ }
+ },
+ )
+ }
+}
+
+func TestFieldListToMap(t *testing.T) {
+ testcases := []struct {
+ name string
+ fields *Fields
+ want map[string][]*string
+ }{
+ {
+ name: "convert list to map",
+ fields: &Fields{
+ Fields: []*Field{
+ {Name: "test", Modifiers: []*string{utils.Ptr("mod")}},
+ },
+ },
+ want: map[string][]*string{
+ "test": {utils.Ptr("mod")},
+ },
+ },
+ {
+ name: "nil fields",
+ fields: nil,
+ want: map[string][]*string{},
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(
+ tc.name, func(t *testing.T) {
+ got := fieldListToMap(tc.fields)
+ if diff := cmp.Diff(tc.want, got); diff != "" {
+ t.Errorf("fieldListToMap() mismatch (-want +got):\n%s", diff)
+ }
+ },
+ )
+ }
+}
+
+func TestHandleTypeMismatches(t *testing.T) {
+ modifiers := []*string{utils.Ptr("RequiresReplace")}
+
+ t.Run(
+ "bool type mismatch", func(t *testing.T) {
+ _, err := handleBoolPlanModifiers(schema.StringAttribute{}, modifiers)
+ if err == nil {
+ t.Error("expected error for type mismatch in handleBoolPlanModifiers")
+ }
+ },
+ )
+
+ t.Run(
+ "string type mismatch", func(t *testing.T) {
+ _, err := handleStringPlanModifiers(schema.BoolAttribute{}, modifiers)
+ if err == nil {
+ t.Error("expected error for type mismatch in handleStringPlanModifiers")
+ }
+ },
+ )
+
+ t.Run(
+ "int64 type mismatch", func(t *testing.T) {
+ _, err := handleInt64PlanModifiers(schema.StringAttribute{}, modifiers)
+ if err == nil {
+ t.Error("expected error for type mismatch in handleInt64PlanModifiers")
+ }
+ },
+ )
+
+ t.Run(
+ "list type mismatch", func(t *testing.T) {
+ _, err := handleListPlanModifiers(schema.StringAttribute{}, modifiers)
+ if err == nil {
+ t.Error("expected error for type mismatch in handleListPlanModifiers")
+ }
+ },
+ )
+}
diff --git a/stackit/internal/utils/regions.go b/stackit/internal/utils/regions.go
index 1b7cec36..70f79620 100644
--- a/stackit/internal/utils/regions.go
+++ b/stackit/internal/utils/regions.go
@@ -8,7 +8,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
)
// AdaptRegion rewrites the region of a terraform plan
diff --git a/stackit/internal/utils/utils.go b/stackit/internal/utils/utils.go
index 962799ea..8ca4984d 100644
--- a/stackit/internal/utils/utils.go
+++ b/stackit/internal/utils/utils.go
@@ -20,7 +20,8 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
"github.com/stackitcloud/stackit-sdk-go/core/utils"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
)
const (
diff --git a/stackit/internal/validate/testdata/file.txt b/stackit/internal/validate/testdata/file.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/stackit/internal/validate/validate.go b/stackit/internal/validate/validate.go
index 9675bec0..d118ac52 100644
--- a/stackit/internal/validate/validate.go
+++ b/stackit/internal/validate/validate.go
@@ -17,9 +17,10 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
"github.com/teambition/rrule-go"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
)
const (
diff --git a/stackit/internal/wait/postgresflexalpha/wait.go b/stackit/internal/wait/postgresflexalpha/wait.go
new file mode 100644
index 00000000..4aea71e8
--- /dev/null
+++ b/stackit/internal/wait/postgresflexalpha/wait.go
@@ -0,0 +1,298 @@
+package postgresflexalpha
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "math"
+ "net/http"
+ "time"
+
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+
+ "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+ "github.com/stackitcloud/stackit-sdk-go/core/wait"
+)
+
+// "READY" "PENDING" "PROGRESSING" "FAILURE" "UNKNOWN" "TERMINATING"
+const (
+ InstanceStateEmpty = ""
+ InstanceStateProgressing = "PROGRESSING"
+ InstanceStateSuccess = "READY"
+ InstanceStateFailed = "FAILURE"
+ InstanceStateTerminating = "TERMINATING"
+ InstanceStateUnknown = "UNKNOWN"
+ InstanceStatePending = "PENDING"
+)
+
+// APIClientInstanceInterface Interface needed for tests
+type APIClientInstanceInterface interface {
+ GetInstanceRequestExecute(ctx context.Context, projectId, region, instanceId string) (
+ *postgresflex.GetInstanceResponse,
+ error,
+ )
+
+ ListUsersRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ ) (*postgresflex.ListUserResponse, error)
+}
+
+// APIClientUserInterface Interface needed for tests
+type APIClientUserInterface interface {
+ GetUserRequestExecute(ctx context.Context, projectId, region, instanceId string, userId int32) (
+ *postgresflex.GetUserResponse,
+ error,
+ )
+
+ GetDatabaseRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ databaseId int32,
+ ) (*postgresflex.GetDatabaseResponse, error)
+}
+
+// CreateInstanceWaitHandler will wait for instance creation
+func CreateInstanceWaitHandler(
+ ctx context.Context, a APIClientInstanceInterface, projectId, region,
+ instanceId string,
+) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse] {
+ instanceCreated := false
+ var instanceGetResponse *postgresflex.GetInstanceResponse
+ maxWait := time.Minute * 45
+ startTime := time.Now()
+ extendedTimeout := 0
+
+ handler := wait.New(
+ func() (waitFinished bool, response *postgresflex.GetInstanceResponse, err error) {
+ if !instanceCreated {
+ s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
+ if err != nil {
+ return false, nil, err
+ }
+ if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
+ return false, nil, nil
+ }
+ tflog.Debug(
+ ctx, "waiting for instance ready", map[string]interface{}{
+ "status": *s.Status,
+ },
+ )
+ switch *s.Status {
+ default:
+ return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
+ case InstanceStateEmpty:
+ return false, nil, nil
+ case InstanceStatePending:
+ return false, nil, nil
+ case InstanceStateUnknown:
+ return false, nil, nil
+ case InstanceStateProgressing:
+ if time.Since(startTime) < maxWait {
+ return false, nil, nil
+ }
+ tflog.Warn(
+ ctx,
+ fmt.Sprintf(
+ "Wait handler still got status %s after %v for instance: %s",
+ InstanceStateProgressing,
+ maxWait,
+ instanceId,
+ ),
+ )
+ if extendedTimeout < 3 {
+ maxWait += time.Minute * 5
+ extendedTimeout++
+ if *s.Network.AccessScope == "SNA" {
+ ready := true
+ if s.Network == nil || s.Network.InstanceAddress == nil {
+ tflog.Warn(ctx, "Waiting for instance_address")
+ ready = false
+ }
+ if s.Network.RouterAddress == nil {
+ tflog.Warn(ctx, "Waiting for router_address")
+ ready = false
+ }
+ if !ready {
+ return false, nil, nil
+ }
+ }
+ if s.IsDeletable == nil {
+ tflog.Warn(ctx, "Waiting for is_deletable")
+ return false, nil, nil
+ }
+ }
+
+ instanceCreated = true
+ instanceGetResponse = s
+ case InstanceStateSuccess:
+ if s.Network != nil && s.Network.AccessScope != nil && *s.Network.AccessScope == "SNA" {
+ if s.Network.InstanceAddress == nil {
+ tflog.Warn(ctx, "Waiting for instance_address")
+ return false, nil, nil
+ }
+ if s.Network.RouterAddress == nil {
+ tflog.Warn(ctx, "Waiting for router_address")
+ return false, nil, nil
+ }
+ }
+ instanceCreated = true
+ instanceGetResponse = s
+ case InstanceStateFailed:
+ tflog.Warn(ctx, fmt.Sprintf("Wait handler got status FAILURE for instance: %s", instanceId))
+ return false, nil, nil
+ // API responds with FAILURE for some seconds and then the instance goes to READY
+ // return true, s, fmt.Errorf("create failed for instance with id %s", instanceId)
+ }
+ }
+
+ tflog.Info(ctx, "Waiting for instance (calling list users")
+ // // User operations aren't available right after an instance is deemed successful
+ // // To check if they are, perform a users request
+ _, err = a.ListUsersRequestExecute(ctx, projectId, region, instanceId)
+ if err == nil {
+ return true, instanceGetResponse, nil
+ }
+ oapiErr, ok := err.(*oapierror.GenericOpenAPIError) // nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
+ if !ok {
+ return false, nil, err
+ }
+ // TODO: refactor and cooperate with api guys to mitigate
+ if oapiErr.StatusCode < 500 {
+ return true, instanceGetResponse, fmt.Errorf(
+ "users request after instance creation returned %d status code",
+ oapiErr.StatusCode,
+ )
+ }
+ return false, nil, nil
+ },
+ )
+ // Sleep before wait is set because sometimes API returns 404 right after creation request
+ handler.SetTimeout(90 * time.Minute).SetSleepBeforeWait(30 * time.Second)
+ return handler
+}
+
+// PartialUpdateInstanceWaitHandler will wait for instance update
+func PartialUpdateInstanceWaitHandler(
+ ctx context.Context, a APIClientInstanceInterface, projectId, region,
+ instanceId string,
+) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *postgresflex.GetInstanceResponse, err error) {
+ s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
+ if err != nil {
+ return false, nil, err
+ }
+ if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
+ return false, nil, nil
+ }
+ switch *s.Status {
+ default:
+ return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
+ case InstanceStateEmpty:
+ return false, nil, nil
+ case InstanceStatePending:
+ return false, nil, nil
+ case InstanceStateProgressing:
+ return false, nil, nil
+ case InstanceStateSuccess:
+ return true, s, nil
+ case InstanceStateTerminating:
+ return false, nil, nil
+ case InstanceStateUnknown:
+ return false, nil, nil
+ case InstanceStateFailed:
+ return true, s, fmt.Errorf("update got status FAILURE for instance with id %s", instanceId)
+ }
+ },
+ )
+ handler.SetTimeout(45 * time.Minute).SetSleepBeforeWait(30 * time.Second)
+ return handler
+}
+
+// GetUserByIdWaitHandler will wait for instance creation
+func GetUserByIdWaitHandler(
+ ctx context.Context,
+ a APIClientUserInterface,
+ projectId, instanceId, region string,
+ userId int64,
+) *wait.AsyncActionHandler[postgresflex.GetUserResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *postgresflex.GetUserResponse, err error) {
+ if userId > math.MaxInt32 {
+ return false, nil, fmt.Errorf("userId value is too big for int32")
+ }
+ userId32 := int32(userId) //nolint:gosec // we need to convert databaseId to int32 because API expects int32
+ s, err := a.GetUserRequestExecute(ctx, projectId, region, instanceId, userId32)
+ if err != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+ switch oapiErr.StatusCode {
+ case http.StatusBadGateway, http.StatusGatewayTimeout, http.StatusServiceUnavailable:
+ case http.StatusNotFound:
+ tflog.Warn(
+ ctx, "api responded with status", map[string]interface{}{
+ "status": oapiErr.StatusCode,
+ },
+ )
+ return false, nil, nil
+ default:
+ return false, nil, err
+ }
+ }
+ return true, s, nil
+ },
+ )
+ return handler
+}
+
+// GetDatabaseByIdWaitHandler will wait for instance creation
+func GetDatabaseByIdWaitHandler(
+ ctx context.Context,
+ a APIClientUserInterface,
+ projectId, instanceId, region string,
+ databaseId int64,
+) *wait.AsyncActionHandler[postgresflex.GetDatabaseResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *postgresflex.GetDatabaseResponse, err error) {
+ dbId32 := int32(databaseId) //nolint:gosec // we need to convert databaseId to int32 because API expects int32
+ s, err := a.GetDatabaseRequestExecute(ctx, projectId, region, instanceId, dbId32)
+ if err != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+ switch oapiErr.StatusCode {
+ case http.StatusBadGateway, http.StatusGatewayTimeout, http.StatusServiceUnavailable:
+ tflog.Warn(
+ ctx, "api responded with 50[2,3,4] status", map[string]interface{}{
+ "status": oapiErr.StatusCode,
+ },
+ )
+ return false, nil, nil
+ case http.StatusNotFound:
+ tflog.Warn(
+ ctx, "api responded with 404 status", map[string]interface{}{
+ "status": oapiErr.StatusCode,
+ },
+ )
+ return false, nil, nil
+ default:
+ return false, nil, err
+ }
+ }
+ return true, s, nil
+ },
+ )
+ return handler
+}
diff --git a/stackit/internal/wait/postgresflexalpha/wait_test.go b/stackit/internal/wait/postgresflexalpha/wait_test.go
new file mode 100644
index 00000000..57d36175
--- /dev/null
+++ b/stackit/internal/wait/postgresflexalpha/wait_test.go
@@ -0,0 +1,336 @@
+// Copyright (c) STACKIT
+
+package postgresflexalpha
+
+import (
+ "context"
+ "testing"
+ "time"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+)
+
+// Used for testing instance operations
+type apiClientInstanceMocked struct {
+ instanceId string
+ instanceState string
+ instanceNetwork postgresflex.InstanceNetwork
+ instanceIsForceDeleted bool
+ instanceGetFails bool
+ usersGetErrorStatus int
+}
+
+func (a *apiClientInstanceMocked) GetInstanceRequestExecute(
+ _ context.Context,
+ _, _, _ string,
+) (*postgresflex.GetInstanceResponse, error) {
+ if a.instanceGetFails {
+ return nil, &oapierror.GenericOpenAPIError{
+ StatusCode: 500,
+ }
+ }
+
+ if a.instanceIsForceDeleted {
+ return nil, &oapierror.GenericOpenAPIError{
+ StatusCode: 404,
+ }
+ }
+
+ return &postgresflex.GetInstanceResponse{
+ Id: &a.instanceId,
+ Status: postgresflex.GetInstanceResponseGetStatusAttributeType(&a.instanceState),
+ Network: postgresflex.GetInstanceResponseGetNetworkAttributeType(&a.instanceNetwork),
+ }, nil
+}
+
+func (a *apiClientInstanceMocked) ListUsersRequestExecute(
+ _ context.Context,
+ _, _, _ string,
+) (*postgresflex.ListUserResponse, error) {
+ if a.usersGetErrorStatus != 0 {
+ return nil, &oapierror.GenericOpenAPIError{
+ StatusCode: a.usersGetErrorStatus,
+ }
+ }
+
+ aux := int64(0)
+ return &postgresflex.ListUserResponse{
+ Pagination: &postgresflex.Pagination{
+ TotalRows: &aux,
+ },
+ Users: &[]postgresflex.ListUser{},
+ }, nil
+}
+
+func TestCreateInstanceWaitHandler(t *testing.T) {
+ tests := []struct {
+ desc string
+ instanceGetFails bool
+ instanceState string
+ instanceNetwork postgresflex.InstanceNetwork
+ usersGetErrorStatus int
+ wantErr bool
+ wantRes *postgresflex.GetInstanceResponse
+ }{
+ {
+ desc: "create_succeeded",
+ instanceGetFails: false,
+ instanceState: InstanceStateSuccess,
+ instanceNetwork: postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ wantErr: false,
+ wantRes: &postgresflex.GetInstanceResponse{
+ Id: utils.Ptr("foo-bar"),
+ Status: postgresflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(InstanceStateSuccess)),
+ Network: &postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ },
+ },
+ {
+ desc: "create_failed",
+ instanceGetFails: false,
+ instanceState: InstanceStateFailed,
+ instanceNetwork: postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "create_failed_2",
+ instanceGetFails: false,
+ instanceState: InstanceStateEmpty,
+ instanceNetwork: postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "instance_get_fails",
+ instanceGetFails: true,
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "users_get_fails",
+ instanceGetFails: false,
+ instanceState: InstanceStateSuccess,
+ instanceNetwork: postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ usersGetErrorStatus: 500,
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "users_get_fails_2",
+ instanceGetFails: false,
+ instanceState: InstanceStateSuccess,
+ instanceNetwork: postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ usersGetErrorStatus: 400,
+ wantErr: true,
+ wantRes: &postgresflex.GetInstanceResponse{
+ Id: utils.Ptr("foo-bar"),
+ Status: postgresflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(InstanceStateSuccess)),
+ Network: &postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ },
+ },
+ {
+ desc: "fail when response has no instance address",
+ instanceGetFails: false,
+ instanceState: InstanceStateSuccess,
+ instanceNetwork: postgresflex.InstanceNetwork{
+ AccessScope: postgresflex.InstanceNetworkGetAccessScopeAttributeType(utils.Ptr("SNA")),
+ Acl: nil,
+ InstanceAddress: nil,
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "timeout",
+ instanceGetFails: false,
+ instanceState: InstanceStateProgressing,
+ instanceNetwork: postgresflex.InstanceNetwork{
+ AccessScope: postgresflex.InstanceNetworkGetAccessScopeAttributeType(utils.Ptr("SNA")),
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ wantErr: true,
+ wantRes: nil,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.desc, func(t *testing.T) {
+ instanceId := "foo-bar"
+
+ apiClient := &apiClientInstanceMocked{
+ instanceId: instanceId,
+ instanceState: tt.instanceState,
+ instanceNetwork: tt.instanceNetwork,
+ instanceGetFails: tt.instanceGetFails,
+ usersGetErrorStatus: tt.usersGetErrorStatus,
+ }
+
+ handler := CreateInstanceWaitHandler(context.Background(), apiClient, "", "", instanceId)
+
+ gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
+ if (err != nil) != tt.wantErr {
+ t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
+ }
+
+ if !cmp.Equal(gotRes, tt.wantRes) {
+ t.Fatalf("handler gotRes = %v, want %v", gotRes, tt.wantRes)
+ }
+ },
+ )
+ }
+}
+
+func TestUpdateInstanceWaitHandler(t *testing.T) {
+ tests := []struct {
+ desc string
+ instanceGetFails bool
+ instanceState string
+ instanceNetwork postgresflex.InstanceNetwork
+ wantErr bool
+ wantRes *postgresflex.GetInstanceResponse
+ }{
+ {
+ desc: "update_succeeded",
+ instanceGetFails: false,
+ instanceState: InstanceStateSuccess,
+ instanceNetwork: postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ wantErr: false,
+ wantRes: &postgresflex.GetInstanceResponse{
+ Id: utils.Ptr("foo-bar"),
+ Status: postgresflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(InstanceStateSuccess)),
+ Network: &postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ },
+ },
+ {
+ desc: "update_failed",
+ instanceGetFails: false,
+ instanceState: InstanceStateFailed,
+ instanceNetwork: postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ wantErr: true,
+ wantRes: &postgresflex.GetInstanceResponse{
+ Id: utils.Ptr("foo-bar"),
+ Status: postgresflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(InstanceStateFailed)),
+ Network: &postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ },
+ },
+ {
+ desc: "update_failed_2",
+ instanceGetFails: false,
+ instanceState: InstanceStateEmpty,
+ instanceNetwork: postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "get_fails",
+ instanceGetFails: true,
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "timeout",
+ instanceGetFails: false,
+ instanceState: InstanceStateProgressing,
+ instanceNetwork: postgresflex.InstanceNetwork{
+ AccessScope: nil,
+ Acl: nil,
+ InstanceAddress: utils.Ptr("10.0.0.1"),
+ RouterAddress: utils.Ptr("10.0.0.1"),
+ },
+ wantErr: true,
+ wantRes: nil,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.desc, func(t *testing.T) {
+ instanceId := "foo-bar"
+
+ apiClient := &apiClientInstanceMocked{
+ instanceId: instanceId,
+ instanceState: tt.instanceState,
+ instanceNetwork: tt.instanceNetwork,
+ instanceGetFails: tt.instanceGetFails,
+ }
+
+ handler := PartialUpdateInstanceWaitHandler(context.Background(), apiClient, "", "", instanceId)
+
+ gotRes, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
+ if (err != nil) != tt.wantErr {
+ t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
+ }
+
+ if !cmp.Equal(gotRes, tt.wantRes) {
+ t.Fatalf("handler gotRes = %v, want %v", gotRes, tt.wantRes)
+ }
+ },
+ )
+ }
+}
diff --git a/stackit/internal/wait/sqlserverflexalpha/wait.go b/stackit/internal/wait/sqlserverflexalpha/wait.go
new file mode 100644
index 00000000..712347d1
--- /dev/null
+++ b/stackit/internal/wait/sqlserverflexalpha/wait.go
@@ -0,0 +1,392 @@
+package sqlserverflexalpha
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "strings"
+ "time"
+
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+ "github.com/stackitcloud/stackit-sdk-go/core/wait"
+
+ sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+)
+
+// READY, PENDING, PROGRESSING, FAILURE, UNKNOWN,
+const (
+ InstanceStateEmpty = ""
+ InstanceStateSuccess = "READY"
+ InstanceStatePending = "PENDING"
+ InstanceStateProcessing = "PROGRESSING"
+ InstanceStateFailed = "FAILURE"
+ InstanceStateUnknown = "UNKNOWN"
+ InstanceStateTerminating = "TERMINATING"
+)
+
+// APIClientInterface Interface needed for tests
+type APIClientInterface interface {
+ GetInstanceRequestExecute(
+ ctx context.Context,
+ projectId, region, instanceId string,
+ ) (*sqlserverflex.GetInstanceResponse, error)
+ GetDatabaseRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ databaseName string,
+ ) (*sqlserverflex.GetDatabaseResponse, error)
+ GetUserRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ userId int64,
+ ) (*sqlserverflex.GetUserResponse, error)
+
+ ListRolesRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ ) (*sqlserverflex.ListRolesResponse, error)
+
+ ListUsersRequest(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ ) sqlserverflex.ApiListUsersRequestRequest
+
+ ListUsersRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ ) (*sqlserverflex.ListUserResponse, error)
+}
+
+// APIClientUserInterface Interface needed for tests
+type APIClientUserInterface interface {
+ DeleteUserRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ userId int64,
+ ) error
+}
+
+// CreateInstanceWaitHandler will wait for instance creation
+func CreateInstanceWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region string,
+) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
+ s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
+ if err != nil {
+ return false, nil, err
+ }
+ if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
+ return false, nil, nil
+ }
+ switch strings.ToLower(string(*s.Status)) {
+ case strings.ToLower(InstanceStateSuccess):
+ if s.Network != nil && s.Network.AccessScope != nil && *s.Network.AccessScope == "SNA" {
+ if s.Network.InstanceAddress == nil {
+ tflog.Info(ctx, "Waiting for instance_address")
+ return false, nil, nil
+ }
+ if s.Network.RouterAddress == nil {
+ tflog.Info(ctx, "Waiting for router_address")
+ return false, nil, nil
+ }
+ }
+
+ tflog.Info(ctx, "trying to get roles")
+ time.Sleep(10 * time.Second)
+ _, rolesErr := a.ListRolesRequestExecute(ctx, projectId, region, instanceId)
+ if rolesErr != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(rolesErr, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+ if oapiErr.StatusCode != http.StatusInternalServerError {
+ tflog.Info(
+ ctx, "got error from api", map[string]interface{}{
+ "error": rolesErr.Error(),
+ },
+ )
+ return false, nil, rolesErr
+ }
+ tflog.Info(
+ ctx, "wait for get-roles to work hack", map[string]interface{}{},
+ )
+ time.Sleep(10 * time.Second)
+ return false, nil, nil
+ }
+
+ tflog.Info(ctx, "trying to get users")
+ time.Sleep(10 * time.Second)
+ _, usersErr := a.ListUsersRequestExecute(ctx, projectId, region, instanceId)
+ if usersErr != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(usersErr, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+ if oapiErr.StatusCode != http.StatusInternalServerError {
+ tflog.Info(
+ ctx, "got error from api", map[string]interface{}{
+ "error": rolesErr.Error(),
+ },
+ )
+ return false, nil, usersErr
+ }
+ tflog.Info(
+ ctx, "wait for get-users to work hack", map[string]interface{}{},
+ )
+ time.Sleep(10 * time.Second)
+ return false, nil, nil
+ }
+ return true, s, nil
+ case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed):
+ return true, nil, fmt.Errorf("create failed for instance with id %s", instanceId)
+ case strings.ToLower(InstanceStatePending), strings.ToLower(InstanceStateProcessing):
+ tflog.Info(
+ ctx, "request is being handled", map[string]interface{}{
+ "status": *s.Status,
+ },
+ )
+ time.Sleep(10 * time.Second)
+ return false, nil, nil
+ default:
+ tflog.Info(
+ ctx, "Wait (create) received unknown status", map[string]interface{}{
+ "instanceId": instanceId,
+ "status": s.Status,
+ },
+ )
+ return true, nil, errors.New("unknown status received")
+ }
+ },
+ )
+ return handler
+}
+
+// UpdateInstanceWaitHandler will wait for instance update
+func UpdateInstanceWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region string,
+) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
+ s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
+ if err != nil {
+ return false, nil, err
+ }
+ if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
+ return false, nil, nil
+ }
+ switch strings.ToLower(string(*s.Status)) {
+ case strings.ToLower(InstanceStateSuccess):
+ return true, s, nil
+ case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed):
+ return true, s, fmt.Errorf("update failed for instance with id %s", instanceId)
+ case strings.ToLower(InstanceStatePending), strings.ToLower(InstanceStateProcessing):
+ tflog.Info(
+ ctx, "request is being handled", map[string]interface{}{
+ "status": *s.Status,
+ },
+ )
+ return false, s, nil
+ default:
+ tflog.Info(
+ ctx, "Wait (update) received unknown status", map[string]interface{}{
+ "instanceId": instanceId,
+ "status": s.Status,
+ },
+ )
+ return false, s, nil
+ }
+ },
+ )
+ return handler
+}
+
+// DeleteInstanceWaitHandler will wait for instance deletion
+func DeleteInstanceWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region string,
+) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
+ s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
+ if err == nil {
+ return false, s, nil
+ }
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+ if oapiErr.StatusCode != http.StatusNotFound {
+ return false, nil, err
+ }
+ return true, nil, nil
+ },
+ )
+ handler.SetTimeout(30 * time.Minute)
+ return handler
+}
+
+// CreateDatabaseWaitHandler will wait for instance creation
+func CreateDatabaseWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region, databaseName string,
+) *wait.AsyncActionHandler[sqlserverflex.GetDatabaseResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.GetDatabaseResponse, err error) {
+ s, err := a.GetDatabaseRequestExecute(ctx, projectId, region, instanceId, databaseName)
+ if err != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf(
+ "get database - could not convert error to oapierror.GenericOpenAPIError: %s",
+ err.Error(),
+ )
+ }
+ if oapiErr.StatusCode != http.StatusNotFound {
+ return false, nil, err
+ }
+ return false, nil, nil
+ }
+ if s == nil || s.Name == nil || *s.Name != databaseName {
+ return false, nil, errors.New("response did return different result")
+ }
+ return true, s, nil
+ },
+ )
+ return handler
+}
+
+// CreateUserWaitHandler will wait for instance creation
+func CreateUserWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region string,
+ userId int64,
+) *wait.AsyncActionHandler[sqlserverflex.GetUserResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.GetUserResponse, err error) {
+ s, err := a.GetUserRequestExecute(ctx, projectId, region, instanceId, userId)
+ if err != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+ if oapiErr.StatusCode != http.StatusNotFound {
+ return false, nil, err
+ }
+ return false, nil, nil
+ }
+ return true, s, nil
+ },
+ )
+ return handler
+}
+
+// WaitForUserWaitHandler will wait for instance creation
+func WaitForUserWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region, userName string,
+) *wait.AsyncActionHandler[sqlserverflex.ListUserResponse] {
+ startTime := time.Now()
+ timeOut := 2 * time.Minute
+
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.ListUserResponse, err error) {
+ if time.Since(startTime) > timeOut {
+ return false, nil, errors.New("ran into timeout")
+ }
+ s, err := a.ListUsersRequest(ctx, projectId, region, instanceId).Size(100).Execute()
+ if err != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf(
+ "wait (list users) could not convert error to oapierror.GenericOpenAPIError: %s",
+ err.Error(),
+ )
+ }
+ if oapiErr.StatusCode != http.StatusNotFound {
+ return false, nil, err
+ }
+ tflog.Info(
+ ctx, "Wait (list users) still waiting", map[string]interface{}{},
+ )
+
+ return false, nil, nil
+ }
+ users, ok := s.GetUsersOk()
+ if !ok {
+ return false, nil, errors.New("no users found")
+ }
+
+ for _, u := range users {
+ if u.GetUsername() == userName {
+ return true, s, nil
+ }
+ }
+ tflog.Info(
+ ctx, "Wait (list users) user still not present", map[string]interface{}{},
+ )
+ return false, nil, nil
+ },
+ )
+ return handler
+}
+
+// DeleteUserWaitHandler will wait for instance deletion
+func DeleteUserWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, region, instanceId string,
+ userId int64,
+) *wait.AsyncActionHandler[struct{}] {
+ handler := wait.New(
+ func() (waitFinished bool, response *struct{}, err error) {
+ _, err = a.GetUserRequestExecute(ctx, projectId, region, instanceId, userId)
+ if err == nil {
+ return false, nil, nil
+ }
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+
+ switch oapiErr.StatusCode {
+ case http.StatusNotFound:
+ return true, nil, nil
+ default:
+ return false, nil, err
+ }
+ },
+ )
+ handler.SetTimeout(15 * time.Minute)
+ handler.SetSleepBeforeWait(15 * time.Second)
+ return handler
+}
diff --git a/stackit/internal/wait/sqlserverflexalpha/wait_test.go b/stackit/internal/wait/sqlserverflexalpha/wait_test.go
new file mode 100644
index 00000000..ca84ad1e
--- /dev/null
+++ b/stackit/internal/wait/sqlserverflexalpha/wait_test.go
@@ -0,0 +1,344 @@
+package sqlserverflexalpha
+
+import (
+ "context"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
+)
+
+// Used for testing instance operations
+type apiClientInstanceMocked struct {
+ instanceId string
+ instanceState string
+ instanceNetwork sqlserverflex.InstanceNetwork
+ instanceIsDeleted bool
+ instanceGetFails bool
+}
+
+type ListUsersRequestRequest struct{}
+
+func (l ListUsersRequestRequest) Page(_ int64) sqlserverflex.ApiListUsersRequestRequest {
+ return l
+}
+
+func (l ListUsersRequestRequest) Size(_ int64) sqlserverflex.ApiListUsersRequestRequest {
+ return l
+}
+
+func (l ListUsersRequestRequest) Sort(_ sqlserverflex.UserSort) sqlserverflex.ApiListUsersRequestRequest {
+ return l
+}
+
+func (l ListUsersRequestRequest) Execute() (*sqlserverflex.ListUserResponse, error) {
+ // TODO implement me
+ panic("implement me")
+}
+
+func (a *apiClientInstanceMocked) ListUsersRequest(
+ _ context.Context,
+ _ string,
+ _ string,
+ _ string,
+) sqlserverflex.ApiListUsersRequestRequest {
+ return ListUsersRequestRequest{}
+}
+
+func (a *apiClientInstanceMocked) ListRolesRequestExecute(
+ _ context.Context,
+ _ string,
+ _ string,
+ _ string,
+) (*sqlserverflex.ListRolesResponse, error) {
+ return &sqlserverflex.ListRolesResponse{
+ Roles: &[]string{},
+ }, nil
+}
+
+func (a *apiClientInstanceMocked) ListUsersRequestExecute(
+ _ context.Context,
+ _ string,
+ _ string,
+ _ string,
+) (*sqlserverflex.ListUserResponse, error) {
+ return &sqlserverflex.ListUserResponse{
+ Pagination: nil,
+ Users: nil,
+ }, nil
+}
+
+func (a *apiClientInstanceMocked) GetDatabaseRequestExecute(
+ _ context.Context,
+ _ string,
+ _ string,
+ _ string,
+ _ string,
+) (*sqlserverflex.GetDatabaseResponse, error) {
+ return nil, nil
+}
+
+func (a *apiClientInstanceMocked) GetUserRequestExecute(
+ _ context.Context,
+ _ string,
+ _ string,
+ _ string,
+ _ int64,
+) (*sqlserverflex.GetUserResponse, error) {
+ return nil, nil
+}
+
+func (a *apiClientInstanceMocked) GetInstanceRequestExecute(
+ _ context.Context,
+ _, _, _ string,
+) (*sqlserverflex.GetInstanceResponse, error) {
+ if a.instanceGetFails {
+ return nil, &oapierror.GenericOpenAPIError{
+ StatusCode: 500,
+ }
+ }
+
+ if a.instanceIsDeleted {
+ return nil, &oapierror.GenericOpenAPIError{
+ StatusCode: 404,
+ }
+ }
+
+ return &sqlserverflex.GetInstanceResponse{
+ Id: &a.instanceId,
+ Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(&a.instanceState),
+ Network: &a.instanceNetwork,
+ }, nil
+}
+func TestCreateInstanceWaitHandler(t *testing.T) {
+ instanceId := utils.Ptr("foo")
+ tests := []struct {
+ desc string
+ instanceId string
+ instanceGetFails bool
+ instanceState string
+ instanceNetwork sqlserverflex.InstanceNetwork
+ usersGetErrorStatus int
+ wantErr bool
+ wantRes *sqlserverflex.GetInstanceResponse
+ }{
+ //{
+ // desc: "create_succeeded",
+ // instanceId: *instanceId,
+ // instanceGetFails: false,
+ // instanceState: *stateSuccess,
+ // instanceNetwork: sqlserverflex.InstanceNetwork{
+ // AccessScope: nil,
+ // Acl: nil,
+ // InstanceAddress: utils.Ptr("10.0.0.1"),
+ // RouterAddress: utils.Ptr("10.0.0.2"),
+ // },
+ // wantErr: false,
+ // wantRes: &sqlserverflex.GetInstanceResponse{
+ // BackupSchedule: nil,
+ // Edition: nil,
+ // Encryption: nil,
+ // FlavorId: nil,
+ // Id: instanceId,
+ // IsDeletable: nil,
+ // Name: nil,
+ // Network: &sqlserverflex.InstanceNetwork{
+ // AccessScope: nil,
+ // Acl: nil,
+ // InstanceAddress: utils.Ptr("10.0.0.1"),
+ // RouterAddress: utils.Ptr("10.0.0.2"),
+ // },
+ // Replicas: nil,
+ // RetentionDays: nil,
+ // Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(stateSuccess),
+ // Storage: nil,
+ // Version: nil,
+ // },
+ // },
+ {
+ desc: "create_failed",
+ instanceId: *instanceId,
+ instanceGetFails: false,
+ instanceState: InstanceStateFailed,
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "create_failed_2",
+ instanceId: *instanceId,
+ instanceGetFails: false,
+ instanceState: InstanceStateEmpty,
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "instance_get_fails",
+ instanceId: *instanceId,
+ instanceGetFails: true,
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "timeout",
+ instanceId: *instanceId,
+ instanceGetFails: false,
+ instanceState: InstanceStateProcessing,
+ wantErr: true,
+ wantRes: nil,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.desc, func(t *testing.T) {
+ apiClient := &apiClientInstanceMocked{
+ instanceId: tt.instanceId,
+ instanceState: tt.instanceState,
+ instanceGetFails: tt.instanceGetFails,
+ }
+
+ handler := CreateInstanceWaitHandler(context.Background(), apiClient, "", tt.instanceId, "")
+
+ gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
+ if (err != nil) != tt.wantErr {
+ t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
+ }
+
+ if !reflect.DeepEqual(gotRes, tt.wantRes) {
+ t.Fatalf("handler gotRes = %v, want %v", gotRes, tt.wantRes)
+ }
+ },
+ )
+ }
+}
+
+func TestUpdateInstanceWaitHandler(t *testing.T) {
+ t.Skip("skipping - needs refactoring")
+ tests := []struct {
+ desc string
+ instanceGetFails bool
+ instanceState string
+ wantErr bool
+ wantResp bool
+ }{
+ {
+ desc: "update_succeeded",
+ instanceGetFails: false,
+ instanceState: InstanceStateSuccess,
+ wantErr: false,
+ wantResp: true,
+ },
+ {
+ desc: "update_failed",
+ instanceGetFails: false,
+ instanceState: InstanceStateFailed,
+ wantErr: true,
+ wantResp: true,
+ },
+ {
+ desc: "update_failed_2",
+ instanceGetFails: false,
+ instanceState: InstanceStateEmpty,
+ wantErr: true,
+ wantResp: true,
+ },
+ {
+ desc: "get_fails",
+ instanceGetFails: true,
+ wantErr: true,
+ wantResp: false,
+ },
+ {
+ desc: "timeout",
+ instanceGetFails: false,
+ instanceState: InstanceStateProcessing,
+ wantErr: true,
+ wantResp: true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.desc, func(t *testing.T) {
+ instanceId := "foo-bar"
+
+ apiClient := &apiClientInstanceMocked{
+ instanceId: instanceId,
+ instanceState: tt.instanceState,
+ instanceGetFails: tt.instanceGetFails,
+ }
+
+ var wantRes *sqlserverflex.GetInstanceResponse
+ if tt.wantResp {
+ wantRes = &sqlserverflex.GetInstanceResponse{
+ Id: &instanceId,
+ Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(tt.instanceState)),
+ }
+ }
+
+ handler := UpdateInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "")
+
+ gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
+
+ if (err != nil) != tt.wantErr {
+ t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
+ }
+ if !cmp.Equal(gotRes, wantRes) {
+ t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
+ }
+ },
+ )
+ }
+}
+
+func TestDeleteInstanceWaitHandler(t *testing.T) {
+ tests := []struct {
+ desc string
+ instanceGetFails bool
+ instanceState string
+ wantErr bool
+ }{
+ {
+ desc: "delete_succeeded",
+ instanceGetFails: false,
+ instanceState: InstanceStateSuccess,
+ wantErr: false,
+ },
+ {
+ desc: "delete_failed",
+ instanceGetFails: false,
+ instanceState: InstanceStateFailed,
+ wantErr: true,
+ },
+ {
+ desc: "get_fails",
+ instanceGetFails: true,
+ wantErr: true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.desc, func(t *testing.T) {
+ instanceId := "foo-bar"
+
+ apiClient := &apiClientInstanceMocked{
+ instanceGetFails: tt.instanceGetFails,
+ instanceIsDeleted: tt.instanceState == InstanceStateSuccess,
+ instanceId: instanceId,
+ instanceState: tt.instanceState,
+ }
+
+ handler := DeleteInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "")
+
+ _, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
+
+ if (err != nil) != tt.wantErr {
+ t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
+ }
+ },
+ )
+ }
+}
diff --git a/stackit/internal/wait/sqlserverflexbeta/wait.go b/stackit/internal/wait/sqlserverflexbeta/wait.go
new file mode 100644
index 00000000..2660cac5
--- /dev/null
+++ b/stackit/internal/wait/sqlserverflexbeta/wait.go
@@ -0,0 +1,412 @@
+package sqlserverflexbeta
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "strings"
+ "time"
+
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+ "github.com/stackitcloud/stackit-sdk-go/core/wait"
+
+ sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+)
+
+// READY, PENDING, PROGRESSING, FAILURE, UNKNOWN,
+const (
+ InstanceStateEmpty = ""
+ InstanceStateSuccess = "READY"
+ InstanceStatePending = "PENDING"
+ InstanceStateProcessing = "PROGRESSING"
+ InstanceStateFailed = "FAILURE"
+ InstanceStateUnknown = "UNKNOWN"
+ InstanceStateTerminating = "TERMINATING"
+)
+
+// APIClientInterface Interface needed for tests
+type APIClientInterface interface {
+ GetInstanceRequestExecute(
+ ctx context.Context,
+ projectId, region, instanceId string,
+ ) (*sqlserverflex.GetInstanceResponse, error)
+ GetDatabaseRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ databaseName string,
+ ) (*sqlserverflex.GetDatabaseResponse, error)
+ GetUserRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ userId int64,
+ ) (*sqlserverflex.GetUserResponse, error)
+
+ ListRolesRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ ) (*sqlserverflex.ListRolesResponse, error)
+
+ ListUsersRequest(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ ) sqlserverflex.ApiListUsersRequestRequest
+
+ ListUsersRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ ) (*sqlserverflex.ListUserResponse, error)
+}
+
+// APIClientUserInterface Interface needed for tests
+type APIClientUserInterface interface {
+ DeleteUserRequestExecute(
+ ctx context.Context,
+ projectId string,
+ region string,
+ instanceId string,
+ userId int64,
+ ) error
+}
+
+// CreateInstanceWaitHandler will wait for instance creation
+func CreateInstanceWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region string,
+) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
+ s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
+ if err != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError: %w", err)
+ }
+ switch oapiErr.StatusCode {
+ case http.StatusNotFound:
+ return false, nil, nil
+ default:
+ return false, nil, fmt.Errorf("api error: %w", err)
+ }
+ }
+ if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
+ return false, nil, nil
+ }
+ switch strings.ToLower(string(*s.Status)) {
+ case strings.ToLower(InstanceStateSuccess):
+ if s.Network != nil && s.Network.AccessScope != nil && *s.Network.AccessScope == "SNA" {
+ if s.Network.InstanceAddress == nil {
+ tflog.Info(ctx, "Waiting for instance_address")
+ return false, nil, nil
+ }
+ if s.Network.RouterAddress == nil {
+ tflog.Info(ctx, "Waiting for router_address")
+ return false, nil, nil
+ }
+ }
+
+ tflog.Info(ctx, "trying to get roles")
+ time.Sleep(10 * time.Second)
+ _, rolesErr := a.ListRolesRequestExecute(ctx, projectId, region, instanceId)
+ if rolesErr != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(rolesErr, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+ if oapiErr.StatusCode != http.StatusInternalServerError {
+ tflog.Info(
+ ctx, "got error from api", map[string]interface{}{
+ "error": rolesErr.Error(),
+ },
+ )
+ return false, nil, rolesErr
+ }
+ tflog.Info(
+ ctx, "wait for get-roles to work hack", map[string]interface{}{},
+ )
+ time.Sleep(10 * time.Second)
+ return false, nil, nil
+ }
+
+ tflog.Info(ctx, "trying to get users")
+ time.Sleep(10 * time.Second)
+ _, usersErr := a.ListUsersRequestExecute(ctx, projectId, region, instanceId)
+ if usersErr != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(usersErr, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+ if oapiErr.StatusCode != http.StatusInternalServerError {
+ tflog.Info(
+ ctx, "got error from api", map[string]interface{}{
+ "error": rolesErr.Error(),
+ },
+ )
+ return false, nil, usersErr
+ }
+ tflog.Info(
+ ctx, "wait for get-users to work hack", map[string]interface{}{},
+ )
+ time.Sleep(10 * time.Second)
+ return false, nil, nil
+ }
+ return true, s, nil
+ case strings.ToLower(InstanceStateUnknown):
+ return true, nil, fmt.Errorf(
+ "create failed for instance %s with status %s",
+ instanceId,
+ InstanceStateUnknown,
+ )
+ case strings.ToLower(InstanceStateFailed):
+ return true, nil, fmt.Errorf(
+ "create failed for instance %s with status %s",
+ instanceId,
+ InstanceStateFailed,
+ )
+ case strings.ToLower(InstanceStatePending), strings.ToLower(InstanceStateProcessing):
+ tflog.Info(
+ ctx, "request is being handled", map[string]interface{}{
+ "status": *s.Status,
+ },
+ )
+ time.Sleep(10 * time.Second)
+ return false, nil, nil
+ default:
+ tflog.Info(
+ ctx, "Wait (create) received unknown status", map[string]interface{}{
+ "instanceId": instanceId,
+ "status": s.Status,
+ },
+ )
+ return true, nil, errors.New("unknown status received")
+ }
+ },
+ )
+ return handler
+}
+
+// UpdateInstanceWaitHandler will wait for instance update
+func UpdateInstanceWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region string,
+) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
+ s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
+ if err != nil {
+ return false, nil, err
+ }
+ if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
+ return false, nil, nil
+ }
+ switch strings.ToLower(string(*s.Status)) {
+ case strings.ToLower(InstanceStateSuccess):
+ return true, s, nil
+ case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed):
+ return true, s, fmt.Errorf("update failed for instance with id %s", instanceId)
+ case strings.ToLower(InstanceStatePending), strings.ToLower(InstanceStateProcessing):
+ tflog.Info(
+ ctx, "request is being handled", map[string]interface{}{
+ "status": *s.Status,
+ },
+ )
+ return false, s, nil
+ default:
+ tflog.Info(
+ ctx, "Wait (update) received unknown status", map[string]interface{}{
+ "instanceId": instanceId,
+ "status": s.Status,
+ },
+ )
+ return false, s, nil
+ }
+ },
+ )
+ return handler
+}
+
+// DeleteInstanceWaitHandler will wait for instance deletion
+func DeleteInstanceWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region string,
+) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
+ s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
+ if err == nil {
+ return false, s, nil
+ }
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+ if oapiErr.StatusCode != http.StatusNotFound {
+ return false, nil, err
+ }
+ return true, nil, nil
+ },
+ )
+ handler.SetTimeout(30 * time.Minute)
+ return handler
+}
+
+// CreateDatabaseWaitHandler will wait for instance creation
+func CreateDatabaseWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region, databaseName string,
+) *wait.AsyncActionHandler[sqlserverflex.GetDatabaseResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.GetDatabaseResponse, err error) {
+ s, err := a.GetDatabaseRequestExecute(ctx, projectId, region, instanceId, databaseName)
+ if err != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf(
+ "get database - could not convert error to oapierror.GenericOpenAPIError: %s",
+ err.Error(),
+ )
+ }
+ if oapiErr.StatusCode != http.StatusNotFound {
+ return false, nil, err
+ }
+ return false, nil, nil
+ }
+ if s == nil || s.Name == nil || *s.Name != databaseName {
+ return false, nil, errors.New("response did return different result")
+ }
+ return true, s, nil
+ },
+ )
+ return handler
+}
+
+// CreateUserWaitHandler will wait for instance creation
+func CreateUserWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region string,
+ userId int64,
+) *wait.AsyncActionHandler[sqlserverflex.GetUserResponse] {
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.GetUserResponse, err error) {
+ s, err := a.GetUserRequestExecute(ctx, projectId, region, instanceId, userId)
+ if err != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+ if oapiErr.StatusCode != http.StatusNotFound {
+ return false, nil, err
+ }
+ return false, nil, nil
+ }
+ return true, s, nil
+ },
+ )
+ return handler
+}
+
+// WaitForUserWaitHandler will wait for instance creation
+func WaitForUserWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, instanceId, region, userName string,
+) *wait.AsyncActionHandler[sqlserverflex.ListUserResponse] {
+ startTime := time.Now()
+ timeOut := 2 * time.Minute
+
+ handler := wait.New(
+ func() (waitFinished bool, response *sqlserverflex.ListUserResponse, err error) {
+ if time.Since(startTime) > timeOut {
+ return false, nil, errors.New("ran into timeout")
+ }
+ s, err := a.ListUsersRequest(ctx, projectId, region, instanceId).Size(100).Execute()
+ if err != nil {
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf(
+ "wait (list users) could not convert error to oapierror.GenericOpenAPIError: %s",
+ err.Error(),
+ )
+ }
+ if oapiErr.StatusCode != http.StatusNotFound {
+ return false, nil, err
+ }
+ tflog.Info(
+ ctx, "Wait (list users) still waiting", map[string]interface{}{},
+ )
+
+ return false, nil, nil
+ }
+ users, ok := s.GetUsersOk()
+ if !ok {
+ return false, nil, errors.New("no users found")
+ }
+
+ for _, u := range users {
+ if u.GetUsername() == userName {
+ return true, s, nil
+ }
+ }
+ tflog.Info(
+ ctx, "Wait (list users) user still not present", map[string]interface{}{},
+ )
+ return false, nil, nil
+ },
+ )
+ return handler
+}
+
+// DeleteUserWaitHandler will wait for instance deletion
+func DeleteUserWaitHandler(
+ ctx context.Context,
+ a APIClientInterface,
+ projectId, region, instanceId string,
+ userId int64,
+) *wait.AsyncActionHandler[struct{}] {
+ handler := wait.New(
+ func() (waitFinished bool, response *struct{}, err error) {
+ _, err = a.GetUserRequestExecute(ctx, projectId, region, instanceId, userId)
+ if err == nil {
+ return false, nil, nil
+ }
+ var oapiErr *oapierror.GenericOpenAPIError
+ ok := errors.As(err, &oapiErr)
+ if !ok {
+ return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
+ }
+
+ switch oapiErr.StatusCode {
+ case http.StatusNotFound:
+ return true, nil, nil
+ default:
+ return false, nil, err
+ }
+ },
+ )
+ handler.SetTimeout(15 * time.Minute)
+ handler.SetSleepBeforeWait(15 * time.Second)
+ return handler
+}
diff --git a/stackit/internal/wait/sqlserverflexbeta/wait_test.go b/stackit/internal/wait/sqlserverflexbeta/wait_test.go
new file mode 100644
index 00000000..0d10abae
--- /dev/null
+++ b/stackit/internal/wait/sqlserverflexbeta/wait_test.go
@@ -0,0 +1,344 @@
+package sqlserverflexbeta
+
+import (
+ "context"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
+)
+
+// Used for testing instance operations
+type apiClientInstanceMocked struct {
+ instanceId string
+ instanceState string
+ instanceNetwork sqlserverflex.InstanceNetwork
+ instanceIsDeleted bool
+ instanceGetFails bool
+}
+
+type ListUsersRequestRequest struct{}
+
+func (l ListUsersRequestRequest) Page(_ int64) sqlserverflex.ApiListUsersRequestRequest {
+ return l
+}
+
+func (l ListUsersRequestRequest) Size(_ int64) sqlserverflex.ApiListUsersRequestRequest {
+ return l
+}
+
+func (l ListUsersRequestRequest) Sort(_ sqlserverflex.UserSort) sqlserverflex.ApiListUsersRequestRequest {
+ return l
+}
+
+func (l ListUsersRequestRequest) Execute() (*sqlserverflex.ListUserResponse, error) {
+ // TODO implement me
+ panic("implement me")
+}
+
+func (a *apiClientInstanceMocked) ListUsersRequest(
+ _ context.Context,
+ _ string,
+ _ string,
+ _ string,
+) sqlserverflex.ApiListUsersRequestRequest {
+ return ListUsersRequestRequest{}
+}
+
+func (a *apiClientInstanceMocked) ListRolesRequestExecute(
+ _ context.Context,
+ _ string,
+ _ string,
+ _ string,
+) (*sqlserverflex.ListRolesResponse, error) {
+ return &sqlserverflex.ListRolesResponse{
+ Roles: &[]string{},
+ }, nil
+}
+
+func (a *apiClientInstanceMocked) ListUsersRequestExecute(
+ _ context.Context,
+ _ string,
+ _ string,
+ _ string,
+) (*sqlserverflex.ListUserResponse, error) {
+ return &sqlserverflex.ListUserResponse{
+ Pagination: nil,
+ Users: nil,
+ }, nil
+}
+
+func (a *apiClientInstanceMocked) GetDatabaseRequestExecute(
+ _ context.Context,
+ _ string,
+ _ string,
+ _ string,
+ _ string,
+) (*sqlserverflex.GetDatabaseResponse, error) {
+ return nil, nil
+}
+
+func (a *apiClientInstanceMocked) GetUserRequestExecute(
+ _ context.Context,
+ _ string,
+ _ string,
+ _ string,
+ _ int64,
+) (*sqlserverflex.GetUserResponse, error) {
+ return nil, nil
+}
+
+func (a *apiClientInstanceMocked) GetInstanceRequestExecute(
+ _ context.Context,
+ _, _, _ string,
+) (*sqlserverflex.GetInstanceResponse, error) {
+ if a.instanceGetFails {
+ return nil, &oapierror.GenericOpenAPIError{
+ StatusCode: 500,
+ }
+ }
+
+ if a.instanceIsDeleted {
+ return nil, &oapierror.GenericOpenAPIError{
+ StatusCode: 404,
+ }
+ }
+
+ return &sqlserverflex.GetInstanceResponse{
+ Id: &a.instanceId,
+ Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(&a.instanceState),
+ Network: &a.instanceNetwork,
+ }, nil
+}
+func TestCreateInstanceWaitHandler(t *testing.T) {
+ instanceId := utils.Ptr("foo")
+ tests := []struct {
+ desc string
+ instanceId string
+ instanceGetFails bool
+ instanceState string
+ instanceNetwork sqlserverflex.InstanceNetwork
+ usersGetErrorStatus int
+ wantErr bool
+ wantRes *sqlserverflex.GetInstanceResponse
+ }{
+ //{
+ // desc: "create_succeeded",
+ // instanceId: *instanceId,
+ // instanceGetFails: false,
+ // instanceState: *stateSuccess,
+ // instanceNetwork: sqlserverflex.InstanceNetwork{
+ // AccessScope: nil,
+ // Acl: nil,
+ // InstanceAddress: utils.Ptr("10.0.0.1"),
+ // RouterAddress: utils.Ptr("10.0.0.2"),
+ // },
+ // wantErr: false,
+ // wantRes: &sqlserverflex.GetInstanceResponse{
+ // BackupSchedule: nil,
+ // Edition: nil,
+ // Encryption: nil,
+ // FlavorId: nil,
+ // Id: instanceId,
+ // IsDeletable: nil,
+ // Name: nil,
+ // Network: &sqlserverflex.InstanceNetwork{
+ // AccessScope: nil,
+ // Acl: nil,
+ // InstanceAddress: utils.Ptr("10.0.0.1"),
+ // RouterAddress: utils.Ptr("10.0.0.2"),
+ // },
+ // Replicas: nil,
+ // RetentionDays: nil,
+ // Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(stateSuccess),
+ // Storage: nil,
+ // Version: nil,
+ // },
+ // },
+ {
+ desc: "create_failed",
+ instanceId: *instanceId,
+ instanceGetFails: false,
+ instanceState: InstanceStateFailed,
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "create_failed_2",
+ instanceId: *instanceId,
+ instanceGetFails: false,
+ instanceState: InstanceStateEmpty,
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "instance_get_fails",
+ instanceId: *instanceId,
+ instanceGetFails: true,
+ wantErr: true,
+ wantRes: nil,
+ },
+ {
+ desc: "timeout",
+ instanceId: *instanceId,
+ instanceGetFails: false,
+ instanceState: InstanceStateProcessing,
+ wantErr: true,
+ wantRes: nil,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.desc, func(t *testing.T) {
+ apiClient := &apiClientInstanceMocked{
+ instanceId: tt.instanceId,
+ instanceState: tt.instanceState,
+ instanceGetFails: tt.instanceGetFails,
+ }
+
+ handler := CreateInstanceWaitHandler(context.Background(), apiClient, "", tt.instanceId, "")
+
+ gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
+ if (err != nil) != tt.wantErr {
+ t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
+ }
+
+ if !reflect.DeepEqual(gotRes, tt.wantRes) {
+ t.Fatalf("handler gotRes = %v, want %v", gotRes, tt.wantRes)
+ }
+ },
+ )
+ }
+}
+
+func TestUpdateInstanceWaitHandler(t *testing.T) {
+ t.Skip("skipping - needs refactoring")
+ tests := []struct {
+ desc string
+ instanceGetFails bool
+ instanceState string
+ wantErr bool
+ wantResp bool
+ }{
+ {
+ desc: "update_succeeded",
+ instanceGetFails: false,
+ instanceState: InstanceStateSuccess,
+ wantErr: false,
+ wantResp: true,
+ },
+ {
+ desc: "update_failed",
+ instanceGetFails: false,
+ instanceState: InstanceStateFailed,
+ wantErr: true,
+ wantResp: true,
+ },
+ {
+ desc: "update_failed_2",
+ instanceGetFails: false,
+ instanceState: InstanceStateEmpty,
+ wantErr: true,
+ wantResp: true,
+ },
+ {
+ desc: "get_fails",
+ instanceGetFails: true,
+ wantErr: true,
+ wantResp: false,
+ },
+ {
+ desc: "timeout",
+ instanceGetFails: false,
+ instanceState: InstanceStateProcessing,
+ wantErr: true,
+ wantResp: true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.desc, func(t *testing.T) {
+ instanceId := "foo-bar"
+
+ apiClient := &apiClientInstanceMocked{
+ instanceId: instanceId,
+ instanceState: tt.instanceState,
+ instanceGetFails: tt.instanceGetFails,
+ }
+
+ var wantRes *sqlserverflex.GetInstanceResponse
+ if tt.wantResp {
+ wantRes = &sqlserverflex.GetInstanceResponse{
+ Id: &instanceId,
+ Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(tt.instanceState)),
+ }
+ }
+
+ handler := UpdateInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "")
+
+ gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
+
+ if (err != nil) != tt.wantErr {
+ t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
+ }
+ if !cmp.Equal(gotRes, wantRes) {
+ t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
+ }
+ },
+ )
+ }
+}
+
+func TestDeleteInstanceWaitHandler(t *testing.T) {
+ tests := []struct {
+ desc string
+ instanceGetFails bool
+ instanceState string
+ wantErr bool
+ }{
+ {
+ desc: "delete_succeeded",
+ instanceGetFails: false,
+ instanceState: InstanceStateSuccess,
+ wantErr: false,
+ },
+ {
+ desc: "delete_failed",
+ instanceGetFails: false,
+ instanceState: InstanceStateFailed,
+ wantErr: true,
+ },
+ {
+ desc: "get_fails",
+ instanceGetFails: true,
+ wantErr: true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(
+ tt.desc, func(t *testing.T) {
+ instanceId := "foo-bar"
+
+ apiClient := &apiClientInstanceMocked{
+ instanceGetFails: tt.instanceGetFails,
+ instanceIsDeleted: tt.instanceState == InstanceStateSuccess,
+ instanceId: instanceId,
+ instanceState: tt.instanceState,
+ }
+
+ handler := DeleteInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "")
+
+ _, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
+
+ if (err != nil) != tt.wantErr {
+ t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
+ }
+ },
+ )
+ }
+}
diff --git a/stackit/provider.go b/stackit/provider.go
index c9c54a7f..086ae003 100644
--- a/stackit/provider.go
+++ b/stackit/provider.go
@@ -6,6 +6,7 @@ import (
"context"
"fmt"
"strings"
+ "time"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
@@ -16,13 +17,28 @@ import (
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
sdkauth "github.com/stackitcloud/stackit-sdk-go/core/auth"
"github.com/stackitcloud/stackit-sdk-go/core/config"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/features"
- postgresFlexAlphaInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflexalpha/instance"
- sqlServerFlexAlphaInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/sqlserverflexalpha/instance"
- sqlServerFlexAlpaUser "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/sqlserverflexalpha/user"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/features"
+
+ postgresFlexAlphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/database"
+ postgresFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavor"
+ postgresflexalphaFlavors "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavors"
+ postgresFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance"
+ postgresFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user"
+
+ sqlserverflexalphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database"
+ sqlserverFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/flavor"
+ sqlServerFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance"
+ sqlserverFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user"
+
+ sqlserverflexBetaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database"
+ sqlserverFlexBetaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/flavor"
+ sqlserverflexBetaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance"
+ sqlserverFlexBetaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user"
)
// Ensure the implementation satisfies the expected interfaces
@@ -30,6 +46,18 @@ var (
_ provider.Provider = &Provider{}
)
+//nolint:unused // These constants are defined for future use in retry logic for HTTP requests, which is not yet implemented.
+const (
+ // maxRetries is the maximum number of retries for a failed HTTP request.
+ maxRetries = 3
+ // initialDelay is the initial delay before the first retry attempt.
+ initialDelay = 2 * time.Second
+ // maxDelay is the maximum delay between retry attempts.
+ maxDelay = 90 * time.Second
+ // perTryTimeout is the timeout for each individual HTTP request attempt.
+ perTryTimeout = 30 * time.Second
+)
+
// Provider is the provider implementation.
type Provider struct {
version string
@@ -96,6 +124,7 @@ type providerModel struct {
// Schema defines the provider-level schema for configuration data.
func (p *Provider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) {
+ //nolint:gosec // These are just descriptions, not actual credentials or sensitive information.
descriptions := map[string]string{
"credentials_path": "Path of JSON from where the credentials are read. Takes precedence over the env var `STACKIT_CREDENTIALS_PATH`. Default value is `~/.stackit/credentials.json`.",
"service_account_token": "Token used for authentication. If set, the token flow will be used to authenticate all operations.",
@@ -313,6 +342,7 @@ func (p *Provider) Schema(_ context.Context, _ provider.SchemaRequest, resp *pro
// Configure prepares a stackit API client for data sources and resources.
func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) {
+ tflog.Info(ctx, "Configuring provider client")
// Retrieve provider data and configuration
var providerConfig providerModel
diags := req.Config.Get(ctx, &providerConfig)
@@ -360,8 +390,8 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest,
setStringField(providerConfig.DefaultRegion, func(v string) { providerData.DefaultRegion = v })
setStringField(
providerConfig.Region,
- func(v string) { providerData.Region = v },
- ) // nolint:staticcheck // preliminary handling of deprecated attribute
+ func(v string) { providerData.Region = v }, // nolint:staticcheck // preliminary handling of deprecated attribute
+ )
setBoolField(providerConfig.EnableBetaResources, func(v bool) { providerData.EnableBetaResources = v })
setStringField(
@@ -436,7 +466,7 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest,
func(v string) { providerData.SQLServerFlexCustomEndpoint = v },
)
- if !(providerConfig.Experiments.IsUnknown() || providerConfig.Experiments.IsNull()) {
+ if !providerConfig.Experiments.IsUnknown() && !providerConfig.Experiments.IsNull() {
var experimentValues []string
diags := providerConfig.Experiments.ElementsAs(ctx, &experimentValues, false)
if diags.HasError() {
@@ -450,7 +480,7 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest,
providerData.Experiments = experimentValues
}
- roundTripper, err := sdkauth.SetupAuth(sdkConfig)
+ baseRoundTripper, err := sdkauth.SetupAuth(sdkConfig)
if err != nil {
core.LogAndAddError(
ctx,
@@ -461,9 +491,19 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest,
return
}
+ //nolint:gocritic // maybe later in the code
+ // roundTripper := core.NewRetryRoundTripper(
+ // baseRoundTripper,
+ // maxRetries,
+ // initialDelay,
+ // maxDelay,
+ // perTryTimeout,
+ //)
+
// Make round tripper and custom endpoints available during DataSource and Resource
// type Configure methods.
- providerData.RoundTripper = roundTripper
+ // providerData.RoundTripper = roundTripper
+ providerData.RoundTripper = baseRoundTripper
resp.DataSourceData = providerData
resp.ResourceData = providerData
@@ -486,8 +526,22 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest,
// DataSources defines the data sources implemented in the provider.
func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
+ postgresFlexAlphaFlavor.NewFlavorDataSource,
+ // postgresFlexAlphaFlavor.NewFlavorListDataSource,
+ postgresFlexAlphaDatabase.NewDatabaseDataSource,
+ postgresFlexAlphaInstance.NewInstanceDataSource,
+ postgresFlexAlphaUser.NewUserDataSource,
+ postgresflexalphaFlavors.NewFlavorsDataSource,
+
+ sqlserverFlexAlphaFlavor.NewFlavorDataSource,
sqlServerFlexAlphaInstance.NewInstanceDataSource,
- sqlServerFlexAlpaUser.NewUserDataSource,
+ sqlserverFlexAlphaUser.NewUserDataSource,
+ sqlserverflexalphaDatabase.NewDatabaseDataSource,
+
+ sqlserverflexBetaDatabase.NewDatabaseDataSource,
+ sqlserverflexBetaInstance.NewInstanceDataSource,
+ sqlserverFlexBetaUser.NewUserDataSource,
+ sqlserverFlexBetaFlavor.NewFlavorDataSource,
}
}
@@ -495,8 +549,16 @@ func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource
func (p *Provider) Resources(_ context.Context) []func() resource.Resource {
resources := []func() resource.Resource{
postgresFlexAlphaInstance.NewInstanceResource,
+ postgresFlexAlphaUser.NewUserResource,
+ postgresFlexAlphaDatabase.NewDatabaseResource,
+
sqlServerFlexAlphaInstance.NewInstanceResource,
- sqlServerFlexAlpaUser.NewUserResource,
+ sqlserverFlexAlphaUser.NewUserResource,
+ sqlserverflexalphaDatabase.NewDatabaseResource,
+
+ sqlserverflexBetaInstance.NewInstanceResource,
+ sqlserverFlexBetaUser.NewUserResource,
+ sqlserverflexBetaDatabase.NewDatabaseResource,
}
return resources
}
diff --git a/stackit/provider_acc_test.go b/stackit/provider_acc_test.go
index 557d3c61..2230d731 100644
--- a/stackit/provider_acc_test.go
+++ b/stackit/provider_acc_test.go
@@ -1,20 +1,47 @@
-// Copyright (c) STACKIT
-
package stackit_test
import (
+ "context"
_ "embed"
"fmt"
+ "net/http"
"os"
- "path"
+ "reflect"
"regexp"
- "runtime"
"testing"
+ "time"
+
+ "github.com/golang-jwt/jwt/v5"
+ "github.com/google/go-cmp/cmp"
+ test "github.com/hashicorp/terraform-plugin-testing/helper/resource" //nolint:staticcheck // used for acceptance testing
+ "github.com/jarcoal/httpmock"
+ "github.com/stackitcloud/stackit-sdk-go/core/clients"
+ "github.com/stackitcloud/stackit-sdk-go/core/utils"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
+ postgresFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavor"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ tfResource "github.com/hashicorp/terraform-plugin-framework/resource"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit"
+ postgresFlexAlphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/database"
+ postgresflexalphaFlavors "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavors"
+ postgresFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance"
+ postgresFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user"
+ sqlserverflexalphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database"
+ sqlserverFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/flavor"
+ sqlserverFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance"
+ sqlserverFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user"
+ sqlserverflexBetaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database"
+ sqlserverFlexBetaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/flavor"
+ sqlserverFlexBetaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance"
+ sqlserverFlexBetaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user"
+
+ "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils"
"github.com/hashicorp/terraform-plugin-testing/config"
- "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
- "github.com/hashicorp/terraform-plugin-testing/helper/resource"
- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/testutil"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource" //nolint:staticcheck // used for acceptance testing
)
//go:embed testdata/provider-credentials.tf
@@ -26,236 +53,328 @@ var providerInvalidAttribute string
//go:embed testdata/provider-all-attributes.tf
var providerValidAttributes string
-var testConfigProviderCredentials = config.Variables{
- "project_id": config.StringVariable(testutil.ProjectId),
- "name": config.StringVariable(fmt.Sprintf("tf-acc-prov%s", acctest.RandStringFromCharSet(3, acctest.CharSetAlphaNum))),
+var testConfigProviderCredentials config.Variables
+
+func TestMain(m *testing.M) {
+ testutils.Setup()
+ code := m.Run()
+ // shutdown()
+ os.Exit(code)
}
-// Helper function to obtain the home directory on different systems.
-// Based on os.UserHomeDir().
-func getHomeEnvVariableName() string {
- env := "HOME"
- switch runtime.GOOS {
- case "windows":
- env = "USERPROFILE"
- case "plan9":
- env = "home"
- }
- return env
+func TestMshTest(t *testing.T) {
+ httpmock.Activate()
+ defer httpmock.DeactivateAndReset()
+
+ testutils.ActivateEnvironmentHttpMocks()
+
+ httpmock.RegisterResponder(
+ "POST", `https://service-account.api.stackit.cloud/token`,
+ func(_ *http.Request) (*http.Response, error) {
+ token := jwt.NewWithClaims(
+ jwt.SigningMethodHS256, jwt.MapClaims{
+ "foo": "bar",
+ "nbf": time.Date(2015, 10, 10, 12, 0, 0, 0, time.UTC).Unix(),
+ },
+ )
+ // Sign and get the complete encoded token as a string using the secret
+ tokenString, err := token.SignedString([]byte("mySecret"))
+ if err != nil {
+ panic(err)
+ }
+
+ tR := clients.TokenResponseBody{
+ AccessToken: tokenString,
+ ExpiresIn: 3600,
+ RefreshToken: "",
+ Scope: "",
+ TokenType: "",
+ }
+
+ return httpmock.NewJsonResponse(http.StatusOK, tR)
+ },
+ )
+
+ httpmock.RegisterResponder(
+ "GET",
+ `https://postgres-flex-service.api.eu01.stackit.cloud/v3alpha1/projects/xyz-project-id/regions/eu01/flavors?page=1&size=25&sort=id.asc`,
+ func(_ *http.Request) (*http.Response, error) {
+ res := postgresflexalpha.GetFlavorsResponse{
+ Flavors: &[]postgresflexalpha.ListFlavors{
+ {
+ Cpu: nil,
+ Description: nil,
+ Id: nil,
+ MaxGB: nil,
+ Memory: nil,
+ MinGB: nil,
+ NodeType: nil,
+ StorageClasses: nil,
+ },
+ },
+ Pagination: &postgresflexalpha.Pagination{
+ Page: utils.Ptr(int64(1)),
+ Size: utils.Ptr(int64(25)),
+ Sort: nil,
+ TotalPages: utils.Ptr(int64(1)),
+ TotalRows: utils.Ptr(int64(0)),
+ },
+ }
+ return httpmock.NewJsonResponse(
+ http.StatusOK,
+ res,
+ )
+ },
+ )
+
+ test.Test(
+ t, test.TestCase{
+ IsUnitTest: true,
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []test.TestStep{
+ {
+ ConfigVariables: map[string]config.Variable{
+ "project_id": config.StringVariable("xyz-project-id"),
+ },
+ Config: fmt.Sprintf(
+ `
+ provider "stackitprivatepreview" {
+ default_region = "%[1]s"
+ service_account_key_path = "%[2]s"
+ }
+ variable "project_id" {
+ type = string
+ }
+ data "stackitprivatepreview_postgresflexalpha_flavor" "all" {
+ project_id = var.project_id
+ region = "eu01"
+ cpu = 2
+ ram = 4
+ node_type = "Single"
+ storage_class = "premium-perf2-stackit"
+ }`,
+ os.Getenv("TF_ACC_REGION"),
+ os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE"),
+ ),
+ },
+ },
+ },
+ )
}
-// create temporary home and initialize the credentials file as well
-func createTemporaryHome(createValidCredentialsFile bool, t *testing.T) string {
- // create a temporary file
- tempHome, err := os.MkdirTemp("", "tempHome")
- if err != nil {
- t.Fatalf("Failed to create temporary home directory: %v", err)
+func TestUnitProviderHasChildDataSources_Basic(t *testing.T) {
+ expectedDataSources := []datasource.DataSource{
+ postgresFlexAlphaFlavor.NewFlavorDataSource(),
+ // postgresFlexAlphaFlavor.NewFlavorListDataSource,
+ postgresFlexAlphaDatabase.NewDatabaseDataSource(),
+ postgresFlexAlphaInstance.NewInstanceDataSource(),
+ postgresFlexAlphaUser.NewUserDataSource(),
+ postgresflexalphaFlavors.NewFlavorsDataSource(),
+
+ sqlserverFlexAlphaFlavor.NewFlavorDataSource(),
+ sqlserverFlexAlphaInstance.NewInstanceDataSource(),
+ sqlserverFlexAlphaUser.NewUserDataSource(),
+ sqlserverflexalphaDatabase.NewDatabaseDataSource(),
+
+ sqlserverflexBetaDatabase.NewDatabaseDataSource(),
+ sqlserverFlexBetaInstance.NewInstanceDataSource(),
+ sqlserverFlexBetaUser.NewUserDataSource(),
+ sqlserverFlexBetaFlavor.NewFlavorDataSource(),
+ }
+ provider, ok := stackit.New("testing")().(*stackit.Provider)
+ if !ok {
+ t.Fatal("could not assert provider type")
+ }
+ datasources := provider.DataSources(context.Background())
+
+ expectedMap := map[string]struct{}{}
+ for _, d := range expectedDataSources {
+ expectedMap[reflect.TypeOf(d).String()] = struct{}{}
}
- // create credentials file in temp directory
- stackitFolder := path.Join(tempHome, ".stackit")
- if err := os.Mkdir(stackitFolder, 0o750); err != nil {
- t.Fatalf("Failed to create stackit folder: %v", err)
+ actualMap := map[string]struct{}{}
+ for _, d := range datasources {
+ actualMap[reflect.TypeOf(d()).String()] = struct{}{}
}
- filePath := path.Join(stackitFolder, "credentials.json")
- file, err := os.Create(filePath)
- if err != nil {
- t.Fatalf("Failed to create credentials file: %v", err)
- }
- defer func() {
- if err := file.Close(); err != nil {
- t.Fatalf("Error while closing the file: %v", err)
- }
- }()
-
- // Define content, default = invalid token
- token := "foo_token"
- if createValidCredentialsFile {
- token = testutil.GetTestProjectServiceAccountToken("")
- }
- content := fmt.Sprintf(`
- {
- "STACKIT_SERVICE_ACCOUNT_TOKEN": "%s"
- }`, token)
-
- if _, err = file.WriteString(content); err != nil {
- t.Fatalf("Error writing to file: %v", err)
- }
-
- return tempHome
-}
-
-// Function to overwrite the home folder
-func setTemporaryHome(tempHomePath string) {
- env := getHomeEnvVariableName()
- if err := os.Setenv(env, tempHomePath); err != nil {
- fmt.Printf("Error setting temporary home directory %v", err)
+ if diff := cmp.Diff(expectedMap, actualMap); diff != "" {
+ t.Errorf("DataSources mismatch (-expected +actual):\n%s", diff)
}
}
-// cleanup the temporary home and reset the environment variable
-func cleanupTemporaryHome(tempHomePath string, t *testing.T) {
- if err := os.RemoveAll(tempHomePath); err != nil {
- t.Fatalf("Error cleaning up temporary folder: %v", err)
+func TestUnitProviderHasChildResources_Basic(t *testing.T) {
+ expectedResources := []tfResource.Resource{
+ postgresFlexAlphaInstance.NewInstanceResource(),
+ postgresFlexAlphaUser.NewUserResource(),
+ postgresFlexAlphaDatabase.NewDatabaseResource(),
+
+ sqlserverFlexAlphaInstance.NewInstanceResource(),
+ sqlserverFlexAlphaUser.NewUserResource(),
+ sqlserverflexalphaDatabase.NewDatabaseResource(),
+
+ sqlserverFlexBetaInstance.NewInstanceResource(),
+ sqlserverFlexBetaUser.NewUserResource(),
+ sqlserverflexBetaDatabase.NewDatabaseResource(),
}
- originalHomeDir, err := os.UserHomeDir()
- if err != nil {
- t.Fatalf("Failed to restore home directory back to normal: %v", err)
+ provider, ok := stackit.New("testing")().(*stackit.Provider)
+ if !ok {
+ t.Fatal("could not assert provider type")
}
- // revert back to original home folder
- env := getHomeEnvVariableName()
- if err := os.Setenv(env, originalHomeDir); err != nil {
- fmt.Printf("Error resetting temporary home directory %v", err)
+ resources := provider.Resources(context.Background())
+
+ expectedMap := map[string]struct{}{}
+ for _, r := range expectedResources {
+ expectedMap[reflect.TypeOf(r).String()] = struct{}{}
+ }
+
+ actualMap := map[string]struct{}{}
+ for _, r := range resources {
+ actualMap[reflect.TypeOf(r()).String()] = struct{}{}
+ }
+
+ if diff := cmp.Diff(expectedMap, actualMap); diff != "" {
+ t.Errorf("Resources mismatch (-expected +actual):\n%s", diff)
}
}
-func getServiceAccountToken() (string, error) {
- token, set := os.LookupEnv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN")
- if !set || token == "" {
- return "", fmt.Errorf("Token not set, please set TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN to a valid token to perform tests")
- }
- return token, nil
-}
-
-func TestAccEnvVarTokenValid(t *testing.T) {
+func TestAccEnvVarServiceAccountPathValid(t *testing.T) {
+ t.Skip("needs refactoring")
// Check if acceptance tests should be run
if v := os.Getenv(resource.EnvTfAcc); v == "" {
t.Skipf(
"Acceptance tests skipped unless env '%s' set",
- resource.EnvTfAcc)
+ resource.EnvTfAcc,
+ )
return
}
- token, err := getServiceAccountToken()
- if err != nil {
- t.Fatalf("Can't get token: %v", err)
- }
-
- t.Setenv("STACKIT_CREDENTIALS_PATH", "")
- t.Setenv("STACKIT_SERVICE_ACCOUNT_TOKEN", token)
- tempHomeFolder := createTemporaryHome(false, t)
- defer cleanupTemporaryHome(tempHomeFolder, t)
- resource.Test(t, resource.TestCase{
- ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories,
- Steps: []resource.TestStep{
- {
- PreConfig: func() { setTemporaryHome(tempHomeFolder) },
- ConfigVariables: testConfigProviderCredentials,
- Config: providerCredentialConfig,
+ tempHomeFolder := testutils.CreateTemporaryHome(true, t)
+ defer testutils.CleanupTemporaryHome(tempHomeFolder, t)
+ resource.Test(
+ t, resource.TestCase{
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ {
+ PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) },
+ ConfigVariables: testConfigProviderCredentials,
+ Config: providerCredentialConfig,
+ },
},
},
- })
+ )
}
-func TestAccEnvVarTokenInvalid(t *testing.T) {
+func TestAccEnvVarServiceAccountPathInvalid(t *testing.T) {
+ t.Skip("needs refactoring")
t.Setenv("STACKIT_CREDENTIALS_PATH", "")
- t.Setenv("STACKIT_SERVICE_ACCOUNT_TOKEN", "foo")
- tempHomeFolder := createTemporaryHome(false, t)
- defer cleanupTemporaryHome(tempHomeFolder, t)
- resource.Test(t, resource.TestCase{
- ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories,
- Steps: []resource.TestStep{
- {
- PreConfig: func() { setTemporaryHome(tempHomeFolder) },
- ConfigVariables: testConfigProviderCredentials,
- Config: providerCredentialConfig,
- ExpectError: regexp.MustCompile(`undefined response type, status code 401`),
+ tempHomeFolder := testutils.CreateTemporaryHome(false, t)
+ defer testutils.CleanupTemporaryHome(tempHomeFolder, t)
+ resource.Test(
+ t, resource.TestCase{
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ {
+ PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) },
+ ConfigVariables: testConfigProviderCredentials,
+ Config: providerCredentialConfig,
+ ExpectError: regexp.MustCompile(`undefined response type, status code 401`),
+ },
},
},
- })
+ )
}
func TestAccCredentialsFileValid(t *testing.T) {
+ t.Skip("needs refactoring")
t.Setenv("STACKIT_CREDENTIALS_PATH", "")
- t.Setenv("STACKIT_SERVICE_ACCOUNT_TOKEN", "")
- tempHomeFolder := createTemporaryHome(true, t)
- defer cleanupTemporaryHome(tempHomeFolder, t)
- resource.Test(t, resource.TestCase{
- ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories,
- Steps: []resource.TestStep{
- {
- PreConfig: func() { setTemporaryHome(tempHomeFolder) },
- ConfigVariables: testConfigProviderCredentials,
- Config: providerCredentialConfig,
+ tempHomeFolder := testutils.CreateTemporaryHome(true, t)
+ defer testutils.CleanupTemporaryHome(tempHomeFolder, t)
+ resource.Test(
+ t, resource.TestCase{
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ {
+ PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) },
+ ConfigVariables: testConfigProviderCredentials,
+ Config: providerCredentialConfig,
+ },
},
},
- })
+ )
}
func TestAccCredentialsFileInvalid(t *testing.T) {
+ t.Skip("needs refactoring")
t.Setenv("STACKIT_CREDENTIALS_PATH", "")
- t.Setenv("STACKIT_SERVICE_ACCOUNT_TOKEN", "")
- tempHomeFolder := createTemporaryHome(false, t)
- defer cleanupTemporaryHome(tempHomeFolder, t)
- resource.Test(t, resource.TestCase{
- ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories,
- Steps: []resource.TestStep{
- {
- PreConfig: func() { setTemporaryHome(tempHomeFolder) },
- ConfigVariables: testConfigProviderCredentials,
- Config: providerCredentialConfig,
- ExpectError: regexp.MustCompile(`Jwt is not in(\r\n|\r|\n)the form of Header.Payload.Signature`),
+ tempHomeFolder := testutils.CreateTemporaryHome(false, t)
+ defer testutils.CleanupTemporaryHome(tempHomeFolder, t)
+ resource.Test(
+ t, resource.TestCase{
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ {
+ PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) },
+ ConfigVariables: testConfigProviderCredentials,
+ Config: providerCredentialConfig,
+ ExpectError: regexp.MustCompile(`Jwt is not in(\r\n|\r|\n)the form of Header.Payload.Signature`),
+ },
},
},
- })
+ )
}
func TestAccProviderConfigureValidValues(t *testing.T) {
+ t.Skip("needs refactoring")
// Check if acceptance tests should be run
if v := os.Getenv(resource.EnvTfAcc); v == "" {
t.Skipf(
"Acceptance tests skipped unless env '%s' set",
- resource.EnvTfAcc)
+ resource.EnvTfAcc,
+ )
return
}
- // use service account token for these tests
- token, err := getServiceAccountToken()
- if err != nil {
- t.Fatalf("Can't get token: %v", err)
- }
-
t.Setenv("STACKIT_CREDENTIALS_PATH", "")
- t.Setenv("STACKIT_SERVICE_ACCOUNT_TOKEN", token)
- tempHomeFolder := createTemporaryHome(true, t)
- defer cleanupTemporaryHome(tempHomeFolder, t)
- resource.Test(t, resource.TestCase{
- ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories,
- Steps: []resource.TestStep{
- { // valid provider attributes
- ConfigVariables: testConfigProviderCredentials,
- Config: providerValidAttributes,
+ tempHomeFolder := testutils.CreateTemporaryHome(true, t)
+ defer testutils.CleanupTemporaryHome(tempHomeFolder, t)
+ resource.Test(
+ t, resource.TestCase{
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ {
+ // valid provider attributes
+ ConfigVariables: testConfigProviderCredentials,
+ Config: providerValidAttributes,
+ },
},
},
- })
+ )
}
func TestAccProviderConfigureAnInvalidValue(t *testing.T) {
+ t.Skip("needs refactoring")
// Check if acceptance tests should be run
if v := os.Getenv(resource.EnvTfAcc); v == "" {
t.Skipf(
"Acceptance tests skipped unless env '%s' set",
- resource.EnvTfAcc)
+ resource.EnvTfAcc,
+ )
return
}
- // use service account token for these tests
- token, err := getServiceAccountToken()
- if err != nil {
- t.Fatalf("Can't get token: %v", err)
- }
t.Setenv("STACKIT_CREDENTIALS_PATH", "")
- t.Setenv("STACKIT_SERVICE_ACCOUNT_TOKEN", token)
- tempHomeFolder := createTemporaryHome(true, t)
- defer cleanupTemporaryHome(tempHomeFolder, t)
- resource.Test(t, resource.TestCase{
- ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories,
- Steps: []resource.TestStep{
- { // invalid test attribute should throw an error
- ConfigVariables: testConfigProviderCredentials,
- Config: providerInvalidAttribute,
- ExpectError: regexp.MustCompile(`An argument named "test" is not expected here\.`),
+ tempHomeFolder := testutils.CreateTemporaryHome(true, t)
+ defer testutils.CleanupTemporaryHome(tempHomeFolder, t)
+ resource.Test(
+ t, resource.TestCase{
+ ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
+ Steps: []resource.TestStep{
+ {
+ // invalid test attribute should throw an error
+ ConfigVariables: testConfigProviderCredentials,
+ Config: providerInvalidAttribute,
+ ExpectError: regexp.MustCompile(`An argument named "test" is not expected here\.`),
+ },
},
},
- })
+ )
}
diff --git a/stackit/testdata/provider-all-attributes.tf b/stackit/testdata/provider-all-attributes.tf
index 59452c76..9ec02936 100644
--- a/stackit/testdata/provider-all-attributes.tf
+++ b/stackit/testdata/provider-all-attributes.tf
@@ -1,9 +1,8 @@
-# Copyright (c) STACKIT
variable "project_id" {}
-variable "name" {}
+variable "region" {}
-provider "stackit" {
+provider "stackitprivatepreview" {
default_region = "eu01"
credentials_path = "~/.stackit/credentials.json"
service_account_token = ""
@@ -37,7 +36,11 @@ provider "stackit" {
enable_beta_resources = "true"
}
-resource "stackit_network" "network" {
- name = var.name
- project_id = var.project_id
+data "stackitprivatepreview_postgresflexalpha_flavor" "flavor" {
+ project_id = var.project_id
+ region = var.region
+ cpu = 2
+ ram = 4
+ node_type = "Single"
+ storage_class = "premium-perf2-stackit"
}
diff --git a/stackit/testdata/provider-credentials.tf b/stackit/testdata/provider-credentials.tf
index 45778443..d348939e 100644
--- a/stackit/testdata/provider-credentials.tf
+++ b/stackit/testdata/provider-credentials.tf
@@ -1,12 +1,18 @@
-# Copyright (c) STACKIT
variable "project_id" {}
-variable "name" {}
+variable "region" {}
-provider "stackit" {
+variable "service_account_key_path" {}
+
+provider "stackitprivatepreview" {
+ service_account_key_path = var.service_account_key_path
}
-resource "stackit_network" "network" {
- name = var.name
- project_id = var.project_id
-}
\ No newline at end of file
+data "stackitprivatepreview_postgresflexalpha_flavor" "flavor" {
+ project_id = var.project_id
+ region = var.region
+ cpu = 2
+ ram = 4
+ node_type = "Single"
+ storage_class = "premium-perf2-stackit"
+}
diff --git a/stackit/testdata/provider-invalid-attribute.tf b/stackit/testdata/provider-invalid-attribute.tf
index fff0834a..1c9d1729 100644
--- a/stackit/testdata/provider-invalid-attribute.tf
+++ b/stackit/testdata/provider-invalid-attribute.tf
@@ -1,13 +1,16 @@
-# Copyright (c) STACKIT
variable "project_id" {}
-variable "name" {}
+variable "region" {}
-provider "stackit" {
+provider "stackitprivatepreview" {
test = "test"
}
-resource "stackit_network" "network" {
- name = var.name
- project_id = var.project_id
-}
\ No newline at end of file
+data "stackitprivatepreview_postgresflexalpha_flavor" "flavor" {
+ project_id = var.project_id
+ region = var.region
+ cpu = 2
+ ram = 4
+ node_type = "Single"
+ storage_class = "premium-perf2-stackit"
+}
diff --git a/tools/tools.go b/tools/tools.go
index b142c65c..e9567c7f 100644
--- a/tools/tools.go
+++ b/tools/tools.go
@@ -1,7 +1,6 @@
-package tools
+//go:build tools
-// Generate copyright headers
-//go:generate go run github.com/hashicorp/copywrite headers -d .. --config ../.copywrite.hcl
+package tools
// Format Terraform code for use in documentation.
// If you do not have Terraform installed, you can remove the formatting command, but it is suggested
@@ -10,3 +9,11 @@ package tools
// Generate documentation.
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-dir .. -provider-name stackitprivatepreview
+
+import (
+ _ "github.com/golangci/golangci-lint/v2/cmd/golangci-lint"
+ _ "github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework"
+ _ "github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi"
+ _ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs"
+ _ "golang.org/x/tools/cmd/goimports"
+)