From 532f085296e65042a6f963e03c4041c77096cc99 Mon Sep 17 00:00:00 2001 From: Isaac Chung <69920967+ichung08@users.noreply.github.com> Date: Tue, 20 Aug 2024 18:15:42 -0700 Subject: [PATCH] Add terraform import script (#130) --- .../workflows/build-release-import-script.yml | 65 + .github/workflows/build.yml | 3 +- .github/workflows/import-script-tests.yml | 55 + .github/workflows/testacc.yml | 4 +- .gitignore | 4 + .goreleaser.import.yml | 48 + Makefile | 33 +- README.md | 47 + go.mod | 23 +- go.sum | 52 +- import/import_script.go | 921 +++++++++++++ import/import_script_mock_functions.go | 349 +++++ import/import_script_suite_test.go | 13 + import/import_script_test.go | 475 +++++++ .../mocks/iam/ClientWithResponsesInterface.go | 1141 +++++++++++++++++ .../platform/ClientWithResponsesInterface.go | 1141 +++++++++++++++++ 16 files changed, 4342 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/build-release-import-script.yml create mode 100644 .github/workflows/import-script-tests.yml create mode 100644 .goreleaser.import.yml create mode 100644 import/import_script.go create mode 100644 import/import_script_mock_functions.go create mode 100644 import/import_script_suite_test.go create mode 100644 import/import_script_test.go create mode 100644 internal/mocks/iam/ClientWithResponsesInterface.go create mode 100644 internal/mocks/platform/ClientWithResponsesInterface.go diff --git a/.github/workflows/build-release-import-script.yml b/.github/workflows/build-release-import-script.yml new file mode 100644 index 00000000..c59e9e4b --- /dev/null +++ b/.github/workflows/build-release-import-script.yml @@ -0,0 +1,65 @@ +name: Build and Release Import Script + +on: + push: + tags: + - 'import-v*' + +permissions: + contents: write + +jobs: + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + with: + go-version-file: 'go.mod' + cache: true + - run: go mod download + - run: go build -v -o import ./import/import_script.go + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + with: + go-version-file: 'go.mod' + cache: true + - run: go fmt ./import/import_script.go + - run: go vet ./import/import_script.go + - run: make validate-fmt + + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + fetch-depth: 0 + - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + with: + go-version-file: 'go.mod' + cache: true + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0 + id: import_gpg + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@5742e2a039330cbb23ebf35f046f814d4c6ff811 # v5.1.0 + with: + args: release --clean --config .goreleaser.import.yml # Use the import-specific config + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + - name: Upload Terraform import script artifact + uses: actions/upload-artifact@v3 + with: + name: import + path: dist/import* \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3275195f..8a785150 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,8 @@ jobs: cache: true - run: go mod download - run: go build -v . - - run: make test + - name: Run unit tests + run: make test lint: name: Lint diff --git a/.github/workflows/import-script-tests.yml b/.github/workflows/import-script-tests.yml new file mode 100644 index 00000000..54f82b36 --- /dev/null +++ b/.github/workflows/import-script-tests.yml @@ -0,0 +1,55 @@ +name: Import Script Tests + +on: + pull_request: + push: + branches: + - main + +# Testing only needs permissions to read the repository contents. +permissions: + contents: read + +jobs: + # Ensure project builds before running testing matrix + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + with: + go-version-file: 'go.mod' + cache: true + - run: go mod download + - name: Build import script + run: go build -o import_script ./import/import_script.go + + test-import-script: + name: Import Script Tests + needs: build + timeout-minutes: 20 + strategy: + fail-fast: true + matrix: + terraform: + - latest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + with: + go-version-file: 'go.mod' + cache: true + - uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1 + with: + terraform_version: ${{ matrix.terraform }} + terraform_wrapper: false + - run: go mod download + - name: Run import script tests + env: + SKIP_IMPORT_SCRIPT_TEST: 1 + HOSTED_ORGANIZATION_API_TOKEN: ${{ secrets.DEV_HOSTED_ORGANIZATION_API_TOKEN }} + HOSTED_ORGANIZATION_ID: clx42kkcm01fo01o06agtmshg + run: make test-import-script diff --git a/.github/workflows/testacc.yml b/.github/workflows/testacc.yml index 3076f564..de4cb2f3 100644 --- a/.github/workflows/testacc.yml +++ b/.github/workflows/testacc.yml @@ -111,7 +111,7 @@ jobs: terraform: - latest provider_version: - - v0.3.0 + - v0.3.1 - v0.2.1 - v0.1.0-alpha - main @@ -162,7 +162,7 @@ jobs: terraform: - latest provider_version: - - v0.3.0 + - v0.3.1 - v0.2.1 - v0.1.0-alpha - main diff --git a/.gitignore b/.gitignore index c9c61cc9..ef9299ab 100644 --- a/.gitignore +++ b/.gitignore @@ -25,11 +25,15 @@ website/node_modules *.test *.iml *.tfvars +import.tf +generated.tf +import/import_script website/vendor test_results vendor/ .terraformrc +.terraform.lock.hcl # Test exclusions !command/test-fixtures/**/*.tfstate diff --git a/.goreleaser.import.yml b/.goreleaser.import.yml new file mode 100644 index 00000000..48fe6733 --- /dev/null +++ b/.goreleaser.import.yml @@ -0,0 +1,48 @@ +project_name: terraform-import-script + +builds: + - main: ./import/import.go + binary: terraform-import-script + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + +archives: + - format: tar.gz + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +signs: + - cmd: gpg + args: + - "--output" + - "${signature}" + - "--detach-sign" + - "${artifact}" + artifacts: checksum + +# Customize the release name to differentiate it from your main project releases +release: + name_template: "Terraform Import Script {{.Tag}}" + header: | + # Terraform Import Script Release {{.Tag}} + + This release contains the Terraform import script, a standalone tool for importing resources into Terraform. \ No newline at end of file diff --git a/Makefile b/Makefile index d6776ec9..f8efb578 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ $(ENVTEST_ASSETS_DIR): mkdir -p $(ENVTEST_ASSETS_DIR) OAPI_CODEGEN ?= $(ENVTEST_ASSETS_DIR)/oapi-codegen +MOCKERY_VERSION := 2.42.0 + # Run acceptance tests .PHONY: testacc testacc: @@ -18,7 +20,12 @@ testacc: .PHONY: test test: go vet ./... - TF_ACC="" go test ./... -v $(TESTARGS) + TF_ACC="" SKIP_IMPORT_SCRIPT_TEST="" SKIP_IMPORT_SCRIPT_TEST_DEV="" go test ./... -v $(TESTARGS) + +# Run script tests +.PHONY: test-import-script +test-import-script: + go test ./import/... -v $(TESTARGS) .PHONY: fmt fmt: @@ -26,6 +33,30 @@ fmt: goimports -w ./ [ -z "$$CIRCLECI" ] || git diff --exit-code --color=always # In CI: exit if anything changed +.PHONY: mock +mock: ensure-mockery generate-mocks + +.PHONY: ensure-mockery +ensure-mockery: + @if ! mockery --version | grep -q $(MOCKERY_VERSION); then \ + echo "Installing Mockery $(MOCKERY_VERSION)"; \ + go install $(MOCKERY_PACKAGE); \ + fi + +.PHONY: generate-mocks +generate-mocks: + @echo "Generating mocks..." + @rm -rf mocks + @mockery --name=ClientWithResponsesInterface \ + --dir=./internal/clients/iam \ + --output=./internal/mocks/iam \ + --outpkg=mocks_iam + @mockery --name=ClientWithResponsesInterface \ + --dir=./internal/clients/platform \ + --output=./internal/mocks/platform \ + --outpkg=mocks_platform + @echo "Mocks generated successfully." + .PHONY: validate-fmt validate-fmt: @output=$$(gofmt -l ./); \ diff --git a/README.md b/README.md index 3d2f4ca2..58a898d9 100644 --- a/README.md +++ b/README.md @@ -203,5 +203,52 @@ You will also need to set all the environment variables described in `internal/p The acceptance tests will run against the Astronomer API and create/read/update/delete real resources. +## Importing Existing Resources +The Astro Terraform Import Script is a tool designed to help you import existing Astro resources into your Terraform configuration. +Currently, this script automates the process of generating Terraform import blocks and resource configurations for the following resources: workspaces, deployments, clusters, hybrid cluster workspace authorizations, API tokens, teams, team roles, and user roles. +To use the import script, download the `import_script` executable file from [releases](https://github.com/astronomer/terraform-provider-astro/releases) and run it with the following command: + +``` +./import [options] +``` + +### Options + +- `-resources`: Comma-separated list of resources to import. Accepted values are workspace, deployment, cluster, api_token, team, team_roles, user_roles. +- `-token`: API token to authenticate with the Astro platform. If not provided, the script will attempt to use the `ASTRO_API_TOKEN` environment variable. +- `-host`: API host to connect to. Default is https://api.astronomer.io. Use "dev" for https://api.astronomer-dev.io or "stage" for https://api.astronomer-stage.io. +- `-organizationId`: Organization ID to import resources from. +- `-runTerraformInit`: Run `terraform init` after generating the import configuration. +- `-help`: Display help information. + +### Examples + +1. Import workspaces and deployments: + ``` + ./import -resources workspace,deployment -token your_api_token -organizationId your_org_id + ``` + +2. Import all supported resources and run Terraform init: + ``` + ./import -resources workspace,deployment,cluster,api_token,team,team_roles,user_roles -token your_api_token -organizationId your_org_id -runTerraformInit + ``` + +3. Use a different API host (e.g., dev environment): + ``` + ./import -resources workspace -token your_api_token -organizationId your_org_id -host dev + ``` + +### Output + +The script will generate two main files: + +1. `import.tf`: Contains the Terraform import blocks for the specified resources. +2. `generated.tf`: Contains the Terraform resource configurations for the imported resources. + +### Notes + +- Ensure you have the necessary permissions in your Astro organization to access the resources you're attempting to import. +- The generated Terraform configurations may require some manual adjustment to match your specific requirements or to resolve any conflicts. +- Always review the generated files before applying them to your Terraform state. diff --git a/go.mod b/go.mod index 1eb28ef4..827164a8 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,11 @@ require ( github.com/hashicorp/terraform-plugin-testing v1.8.0 github.com/lucsky/cuid v1.2.1 github.com/oapi-codegen/runtime v1.1.1 + github.com/onsi/ginkgo/v2 v2.20.0 + github.com/onsi/gomega v1.34.1 github.com/samber/lo v1.39.0 github.com/stretchr/testify v1.9.0 + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 ) require ( @@ -33,8 +36,11 @@ require ( github.com/cloudflare/circl v1.3.7 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.16.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/cli v1.1.6 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -71,6 +77,7 @@ require ( github.com/rivo/uniseg v0.2.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect + github.com/stretchr/objx v0.5.2 // 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 @@ -78,17 +85,17 @@ require ( github.com/yuin/goldmark-meta v1.1.0 // indirect github.com/zclconf/go-cty v1.14.4 // indirect go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect - golang.org/x/crypto v0.23.0 // indirect - golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/mod v0.20.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect + golang.org/x/tools v0.24.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/grpc v1.63.2 // indirect - google.golang.org/protobuf v1.34.0 // indirect + google.golang.org/protobuf v1.34.1 // indirect gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 514bfae9..bfbfa7d7 100644 --- a/go.sum +++ b/go.sum @@ -51,6 +51,10 @@ github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+ github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +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/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= @@ -64,6 +68,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/uuid v1.1.1/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= @@ -173,6 +179,10 @@ github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmt github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/onsi/ginkgo/v2 v2.20.0 h1:PE84V2mHqoT1sglvHc8ZdQtPcwmvvt29WLEEO3xmdZw= +github.com/onsi/ginkgo/v2 v2.20.0/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= +github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= +github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -197,6 +207,8 @@ github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +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= @@ -227,25 +239,25 @@ go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U= -golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= +golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 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.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/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-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -259,26 +271,26 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 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.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= -golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= +golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= +golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.3.0/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.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.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= @@ -290,8 +302,8 @@ google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= 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.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= -google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 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-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= diff --git a/import/import_script.go b/import/import_script.go new file mode 100644 index 00000000..a47b61af --- /dev/null +++ b/import/import_script.go @@ -0,0 +1,921 @@ +package main + +import ( + "context" + "flag" + "fmt" + "log" + "net/http" + "os" + "os/exec" + "path/filepath" + "strings" + "sync" + + "golang.org/x/exp/maps" + + "github.com/astronomer/terraform-provider-astro/internal/clients/iam" + + "github.com/astronomer/terraform-provider-astro/internal/clients" + + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/samber/lo" +) + +type HandlerResult struct { + Resource string + ImportString string + Error error +} + +func main() { + log.SetFlags(0) + log.Println("Terraform Import Script Starting") + + // collect all arguments from the user, indicating all the resources that need to be imported + resourcesPtr := flag.String("resources", "", "Comma separated list of resources to import. The only accepted values are workspace, deployment, cluster, api_token, team, team_roles, user_roles") + tokenPtr := flag.String("token", "", "API token to authenticate with the platform") + hostPtr := flag.String("host", "https://api.astronomer.io", "API host to connect to") + organizationIdPtr := flag.String("organizationId", "", "Organization ID to import resources into") + runTerraformInitPtr := flag.Bool("runTerraformInit", false, "Run terraform init after generating the import configuration") + helpFlag := flag.Bool("help", false, "Display help information") + + flag.Parse() + + // display help information + if *helpFlag { + printHelp() + return + } + + // validate the resources argument + resources := strings.Split(strings.ToLower(*resourcesPtr), ",") + acceptedResources := []string{"workspace", "deployment", "cluster", "api_token", "team", "team_roles", "user_roles"} + for _, resource := range resources { + if !lo.Contains(acceptedResources, resource) { + log.Fatalf("Invalid resource: %s is not accepted. The only accepted resources are %s", resource, acceptedResources) + return + } + } + + log.Println("Resources to import: ", resources) + + // set the API token + token := *tokenPtr + if token == "" { + token = os.Getenv("ASTRO_API_TOKEN") + } + + if len(token) == 0 { + log.Fatal("API token not provided") + return + } + + // set the host + var host string + if *hostPtr == "dev" { + host = "https://api.astronomer-dev.io" + } else if *hostPtr == "stage" { + host = "https://api.astronomer-stage.io" + } else { + host = *hostPtr + } + + // set the organization ID + organizationId := *organizationIdPtr + if organizationId == "" { + log.Fatalf("Organization ID not provided") + } + + log.Printf("Using organization ID: %s", organizationId) + + // Check if Terraform is installed + _, err := exec.LookPath("terraform") + if err != nil { + log.Fatalf("Error: Terraform is not installed or not in PATH. Please install Terraform and make sure it's in your system PATH") + } + + // connect to v1beta1 client + ctx := context.Background() + platformClient, err := platform.NewPlatformClient(host, token, "import") + if err != nil { + log.Fatalf("Failed to create platform client: %v", err) + } + + iamClient, err := iam.NewIamClient(host, token, "import") + if err != nil { + log.Fatalf("Failed to create iam client: %v", err) + return + } + + // set terraform provider configuration + var importString string + importString += fmt.Sprintf(`terraform { + required_providers { + astro = { + source = "astronomer/astro" + } + } +} + +provider "astro" { + organization_id = "%s" + host = "%s" + token = "%s" +} +`, organizationId, host, token) + + // for each resource, we get the list of entities and generate the terraform import command + + resourceHandlers := map[string]func(context.Context, *platform.ClientWithResponses, *iam.ClientWithResponses, string) (string, error){ + "workspace": handleWorkspaces, + "deployment": handleDeployments, + "cluster": handleClusters, + "api_token": handleApiTokens, + "team": handleTeams, + "team_roles": handleTeamRoles, + "user_roles": handleUserRoles, + } + + results := make(chan HandlerResult, len(resources)) + var wg sync.WaitGroup + + for _, resource := range resources { + wg.Add(1) + + go func(resource string) { + defer wg.Done() + handler, exists := resourceHandlers[resource] + if !exists { + log.Printf("Resource not supported: %s", resource) + results <- HandlerResult{Resource: resource, Error: fmt.Errorf("resource not supported")} + return + } + result, err := handler(ctx, platformClient, iamClient, organizationId) + if err != nil { + log.Printf("Error handling resource %s: %v", resource, err) + results <- HandlerResult{Resource: resource, Error: err} + } else { + results <- HandlerResult{Resource: resource, ImportString: result} + } + }(resource) + } + + wg.Wait() + close(results) + + var allResults []HandlerResult + var deploymentImportString string + for result := range results { + allResults = append(allResults, result) + if result.Error != nil { + log.Printf("Error handling resource %s: %v", result.Resource, result.Error) + } else { + if result.Resource == "deployment" { + deploymentImportString += result.ImportString + } else { + importString += result.ImportString + } + log.Printf("Successfully handled resource %s", result.Resource) + } + } + + // write the terraform configuration to a file + err = os.WriteFile("import.tf", []byte(importString), 0644) + if err != nil { + log.Fatalf("Failed to write import configuration to file: %v", err) + return + } + + log.Println("Successfully wrote import configuration to import.tf") + + // Trigger terraform init if the flag is set - used to download the provider in CI integration tests + if *runTerraformInitPtr { + log.Println("Running terraform init") + rootDir, err := os.Getwd() + + // Find the import_script.go file + importScriptPath := filepath.Join(rootDir, "import_script.go") + _, err = os.Stat(importScriptPath) + if err != nil { + // If not found, try going up one directory + rootDir = filepath.Dir(rootDir) + importScriptPath = filepath.Join(rootDir, "import_script.go") + _, err = os.Stat(importScriptPath) + } + + cmd := exec.Command("terraform", "init") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + if err := cmd.Run(); err != nil { + log.Fatalf("Failed to run terraform init: %v", err) + return + } + } + + // Generate the corresponding terraform HCL configuration for each import block + err = generateTerraformConfig() + if err != nil { + log.Fatalf("Failed to run Terraform command: %v", err) + return + } + + // Add deployment import blocks and HCL to the generated file + err = addDeploymentsToGeneratedFile(deploymentImportString, organizationId, platformClient, ctx) + if err != nil { + log.Fatalf("Failed to add deployments to generated file: %v", err) + return + } + + log.Println("Import process completed successfully. The 'generated.tf' file now includes all resources, including deployments.") + + // Print summary of results + log.Println("Import process completed. Summary:") + for _, result := range allResults { + if result.Error != nil { + log.Printf("Resource %s failed: %v", result.Resource, result.Error) + } else { + log.Printf("Resource %s processed successfully", result.Resource) + } + } +} + +func printHelp() { + log.Println("Terraform Import Script") + log.Println("\nUsage: go run script.go [options]") + log.Println("\nOptions:") + log.Println(" -resources string") + log.Println(" Comma separated list of resources to import. Accepted values:") + log.Println(" workspace, deployment, cluster, api_token, team, team_roles, user_roles") + log.Println(" -token string") + log.Println(" API token to authenticate with the platform") + log.Println(" -host string") + log.Println(" API host to connect to (default: https://api.astronomer.io)") + log.Println(" Use 'dev' for https://api.astronomer-dev.io") + log.Println(" Use 'stage' for https://api.astronomer-stage.io") + log.Println(" -organizationId string") + log.Println(" Organization ID to import resources into") + log.Println(" -runTerraformInit") + log.Println(" Run terraform init after generating the import configuration") + log.Println(" -help") + log.Println(" Display this help information") + log.Println("\nExample:") + log.Println(" go run script.go -resources=workspace,deployment -token=your_api_token -organizationId=your_org_id") + log.Println("\nNote: If the -token flag is not provided, the script will attempt to use the ASTRO_API_TOKEN environment variable.") +} + +// generateTerraformConfig runs terraform plan to generate the configuration +func generateTerraformConfig() error { + // delete the generated.tf file if it exists + filenames := []string{"generated.tf", "terraform.tfstate"} + for _, filename := range filenames { + // Check if the file exists + if _, err := os.Stat(filename); err == nil { + // File exists, so delete it + err = os.Remove(filename) + if err != nil { + return err + } + log.Printf("Successfully deleted %s", filename) + } else if os.IsNotExist(err) { + // File does not exist, nothing to do + log.Printf("%s does not exist, no need to delete", filename) + } else { + // Some other error occurred + return err + } + } + + // terraform plan to generate the configuration + cmd := exec.Command("terraform", "plan", "-generate-config-out=generated.tf") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + if err := cmd.Run(); err != nil { + return err + } + + return nil +} + +func handleWorkspaces(ctx context.Context, platformClient *platform.ClientWithResponses, iamClient *iam.ClientWithResponses, organizationId string) (string, error) { + log.Printf("Importing workspaces for organization %s", organizationId) + + workspacesResp, err := platformClient.ListWorkspacesWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list workspaces: %v", err) + } + + if workspacesResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", workspacesResp.StatusCode(), string(workspacesResp.Body)) + } + + if workspacesResp.JSON200 == nil { + return "", fmt.Errorf("failed to list workspaces, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, workspacesResp.HTTPResponse, workspacesResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + workspaces := workspacesResp.JSON200.Workspaces + if workspaces == nil { + return "", fmt.Errorf("workspaces list is nil") + } + + workspaceIds := lo.Map(workspaces, func(workspace platform.Workspace, _ int) string { + return workspace.Id + }) + + log.Printf("Importing Workspaces: %v", workspaceIds) + + var importString string + for _, workspaceId := range workspaceIds { + workspaceImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_workspace.workspace_%v +}`, workspaceId, workspaceId) + + importString += workspaceImportString + "\n" + } + + return importString, nil +} + +func handleDeployments(ctx context.Context, platformClient *platform.ClientWithResponses, iamClient *iam.ClientWithResponses, organizationId string) (string, error) { + log.Printf("Importing deployments for organization %s", organizationId) + + deploymentsResp, err := platformClient.ListDeploymentsWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list deployments: %v", err) + } + + if deploymentsResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", deploymentsResp.StatusCode(), string(deploymentsResp.Body)) + } + + if deploymentsResp.JSON200 == nil { + return "", fmt.Errorf("failed to list deployments, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, deploymentsResp.HTTPResponse, deploymentsResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + deployments := deploymentsResp.JSON200.Deployments + if deployments == nil { + return "", fmt.Errorf("deployments list is nil") + } + + deploymentIds := lo.Map(deployments, func(deployment platform.Deployment, _ int) string { + return deployment.Id + }) + log.Printf("Importing Deployments: %v", deploymentIds) + + var importString string + for _, deploymentId := range deploymentIds { + deploymentImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_deployment.deployment_%v +}`, deploymentId, deploymentId) + + importString += deploymentImportString + "\n" + } + + return importString, nil +} + +func handleClusters(ctx context.Context, platformClient *platform.ClientWithResponses, iamClient *iam.ClientWithResponses, organizationId string) (string, error) { + log.Printf("Importing clusters for organization %s", organizationId) + + clustersResp, err := platformClient.ListClustersWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list clusters: %v", err) + } + + if clustersResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", clustersResp.StatusCode(), string(clustersResp.Body)) + } + + if clustersResp.JSON200 == nil { + return "", fmt.Errorf("failed to list clusters, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, clustersResp.HTTPResponse, clustersResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + clusters := clustersResp.JSON200.Clusters + if clusters == nil { + return "", fmt.Errorf("clusters list is nil") + } + + clusterMap := make(map[string]platform.ClusterType) + for _, cluster := range clusters { + if cluster.Id != "" { + clusterMap[cluster.Id] = cluster.Type + } + } + + log.Printf("Importing Clusters: %v", maps.Keys(clusterMap)) + + var importString string + var clusterImportString string + for clusterId, clusterType := range clusterMap { + if clusterType != platform.ClusterTypeHYBRID { + clusterImportString = fmt.Sprintf(` +import { + id = "%v" + to = astro_cluster.cluster_%v +}`, clusterId, clusterId) + } else { + clusterImportString += fmt.Sprintf(` +import { + id = "%v" + to = astro_hybrid_cluster_workspace_authorization.cluster_%v +}`, clusterId, clusterId) + } + + importString += clusterImportString + "\n" + } + + return importString, nil +} + +func handleApiTokens(ctx context.Context, platformClient *platform.ClientWithResponses, iamClient *iam.ClientWithResponses, organizationId string) (string, error) { + log.Printf("Importing API tokens for organization %s", organizationId) + + apiTokensResp, err := iamClient.ListApiTokensWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list API tokens: %v", err) + } + + if apiTokensResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", apiTokensResp.StatusCode(), string(apiTokensResp.Body)) + } + + if apiTokensResp.JSON200 == nil { + return "", fmt.Errorf("failed to list API tokens, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, apiTokensResp.HTTPResponse, apiTokensResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + apiTokens := apiTokensResp.JSON200.Tokens + if apiTokens == nil { + return "", fmt.Errorf("API tokens list is nil") + } + + apiTokenIds := lo.Map(apiTokens, func(apiToken iam.ApiToken, _ int) string { + return apiToken.Id + }) + + log.Printf("Importing API Tokens: %v", apiTokenIds) + + var importString string + for _, apiTokenId := range apiTokenIds { + apiTokenImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_api_token.api_token_%v +}`, apiTokenId, apiTokenId) + + importString += apiTokenImportString + "\n" + } + + return importString, nil +} + +func handleTeams(ctx context.Context, platformClient *platform.ClientWithResponses, iamClient *iam.ClientWithResponses, organizationId string) (string, error) { + log.Printf("Importing teams for organization %s", organizationId) + + // Check if SCIM is enabled for the organization, if so, exit as teams cannot be imported + organizationResp, err := platformClient.GetOrganizationWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to get organization: %v", err) + } + + if organizationResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", organizationResp.StatusCode(), string(organizationResp.Body)) + } + + if organizationResp.JSON200 == nil { + return "", fmt.Errorf("failed to get organization, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, organizationResp.HTTPResponse, organizationResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + organization := organizationResp.JSON200 + if organization.IsScimEnabled == true { + return "", fmt.Errorf("SCIM is enabled for the organization, teams cannot be imported") + } + + teamsResp, err := iamClient.ListTeamsWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list teams: %v", err) + } + + if teamsResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", teamsResp.StatusCode(), string(teamsResp.Body)) + } + + if teamsResp.JSON200 == nil { + return "", fmt.Errorf("failed to list teams, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic = clients.NormalizeAPIError(ctx, teamsResp.HTTPResponse, teamsResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + teams := teamsResp.JSON200.Teams + if teams == nil { + return "", fmt.Errorf("teams list is nil") + } + + teamIds := lo.Map(teams, func(team iam.Team, _ int) string { + return team.Id + }) + + log.Printf("Importing Teams: %v", teamIds) + + var importString string + for _, teamId := range teamIds { + teamImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_team.team_%v +}`, teamId, teamId) + + importString += teamImportString + "\n" + } + + return importString, nil +} + +func handleTeamRoles(ctx context.Context, platformClient *platform.ClientWithResponses, iamClient *iam.ClientWithResponses, organizationId string) (string, error) { + log.Printf("Importing team roles for organization %s", organizationId) + + teamsResp, err := iamClient.ListTeamsWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list teams: %v", err) + } + + if teamsResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", teamsResp.StatusCode(), string(teamsResp.Body)) + } + + if teamsResp.JSON200 == nil { + return "", fmt.Errorf("failed to list teams, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, teamsResp.HTTPResponse, teamsResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + teams := teamsResp.JSON200.Teams + if teams == nil { + return "", fmt.Errorf("teams list is nil") + } + + teamIds := lo.Map(teams, func(team iam.Team, _ int) string { + return team.Id + }) + + log.Printf("Importing Team Roles: %v", teamIds) + + var importString string + for _, teamId := range teamIds { + teamImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_team_roles.team_%v +}`, teamId, teamId) + + importString += teamImportString + "\n" + } + + return importString, nil +} + +func handleUserRoles(ctx context.Context, platformClient *platform.ClientWithResponses, iamClient *iam.ClientWithResponses, organizationId string) (string, error) { + log.Printf("Importing user roles for organization %s", organizationId) + + usersResp, err := iamClient.ListUsersWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list users: %v", err) + } + + if usersResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", usersResp.StatusCode(), string(usersResp.Body)) + } + + if usersResp.JSON200 == nil { + return "", fmt.Errorf("failed to list users, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, usersResp.HTTPResponse, usersResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + users := usersResp.JSON200.Users + if users == nil { + return "", fmt.Errorf("users list is nil") + } + + userIds := lo.Map(users, func(user iam.User, _ int) string { + return user.Id + }) + + log.Printf("Importing User Roles: %v", userIds) + + var importString string + for _, userId := range userIds { + userImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_user_roles.user_%v +}`, userId, userId) + + importString += userImportString + "\n" + } + + return importString, nil +} + +// addDeploymentsToGeneratedFile adds the deployment import blocks and HCL to the generated.tf file +func addDeploymentsToGeneratedFile(deploymentImportString string, organizationId string, platformClient *platform.ClientWithResponses, ctx context.Context) error { + var contentBytes []byte + var err error + + // Try to read the existing generated.tf file + contentBytes, err = os.ReadFile("generated.tf") + if err != nil { + if os.IsNotExist(err) { + // File doesn't exist, we'll create our own content + log.Println("generated.tf does not exist. Creating new file with deployment information.") + contentBytes = []byte{} + } else { + // Some other error occurred + return fmt.Errorf("error reading generated.tf: %v", err) + } + } + + // Generate deployment HCL + deploymentHCL, err := generateDeploymentHCL(ctx, platformClient, organizationId) + if err != nil { + return fmt.Errorf("failed to generate deployment HCL: %v", err) + } + + // Combine existing content (if any), deployment import blocks, and deployment HCL + existingContent := strings.TrimSpace(string(contentBytes)) + newContent := existingContent + if newContent != "" { + newContent += "\n\n" + } + newContent += "// generated Deployment HCL \n" + strings.TrimSpace(deploymentImportString) + "\n\n" + strings.TrimSpace(deploymentHCL) + + // Write the updated content to generated.tf + err = os.WriteFile("generated.tf", []byte(newContent), 0644) + if err != nil { + return fmt.Errorf("failed to write updated generated.tf: %v", err) + } + + log.Println("Successfully updated generated.tf with deployment information.") + return nil +} + +// generateDeploymentHCL generates the HCL for all deployments in the organization +// generateTerraformConfig has trouble with deployments, so we generate the HCL manually +func generateDeploymentHCL(ctx context.Context, platformClient *platform.ClientWithResponses, organizationId string) (string, error) { + deploymentsResp, err := platformClient.ListDeploymentsWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list deployments: %v", err) + } + + if deploymentsResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", deploymentsResp.StatusCode(), string(deploymentsResp.Body)) + } + + if deploymentsResp.JSON200 == nil { + return "", fmt.Errorf("failed to list deployments, JSON200 resp is nil, organizationId: %v", organizationId) + } + + deployments := deploymentsResp.JSON200.Deployments + if deployments == nil { + return "", fmt.Errorf("deployments list is nil") + } + + deploymentIds := lo.Map(deployments, func(deployment platform.Deployment, _ int) string { + return deployment.Id + }) + + var hclString string + for _, deploymentId := range deploymentIds { + var deploymentHCL string + + // get deployment details + deploymentResp, err := platformClient.GetDeploymentWithResponse(ctx, organizationId, deploymentId) + if err != nil { + return "", fmt.Errorf("failed to list deployments: %v", err) + } + + if deploymentsResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", deploymentsResp.StatusCode(), string(deploymentsResp.Body)) + } + + if deploymentsResp.JSON200 == nil { + return "", fmt.Errorf("failed to list deployments, JSON200 resp is nil, organizationId: %v", organizationId) + } + + deployment := deploymentResp.JSON200 + if deployment == nil { + return "", fmt.Errorf("deployment is nil") + } + + contactEmailsString := formatContactEmails(deployment.ContactEmails) + environmentVariablesString := formatEnvironmentVariables(deployment.EnvironmentVariables) + workerQueuesString := formatWorkerQueues(deployment.WorkerQueues, (*string)(deployment.Executor)) + + deploymentType := deployment.Type + + if *deploymentType == platform.DeploymentTypeDEDICATED { + deploymentHCL = fmt.Sprintf(` +resource "astro_deployment" "deployment_%s" { + cluster_id = "%s" + %s + default_task_pod_cpu = "%s" + default_task_pod_memory = "%s" + description = "%s" + %s + executor = "%s" + is_cicd_enforced = %t + is_dag_deploy_enabled = %t + is_development_mode = %t + is_high_availability = %t + name = "%s" + resource_quota_cpu = "%s" + resource_quota_memory = "%s" + scheduler_size = "%s" + type = "%s" + workspace_id = "%s" + %s +} +`, + deployment.Id, + stringValue(deployment.ClusterId), + contactEmailsString, + stringValue(deployment.DefaultTaskPodCpu), + stringValue(deployment.DefaultTaskPodMemory), + stringValue(deployment.Description), + environmentVariablesString, + stringValue((*string)(deployment.Executor)), + deployment.IsCicdEnforced, + deployment.IsDagDeployEnabled, + boolValue(deployment.IsDevelopmentMode), + boolValue(deployment.IsHighAvailability), + deployment.Name, + stringValue(deployment.ResourceQuotaCpu), + stringValue(deployment.ResourceQuotaMemory), + stringValue((*string)(deployment.SchedulerSize)), + stringValue((*string)(deploymentType)), + deployment.WorkspaceId, + workerQueuesString, + ) + } else if *deploymentType == platform.DeploymentTypeSTANDARD { + deploymentHCL = fmt.Sprintf(` +resource "astro_deployment" "deployment_%s" { + cloud_provider = "%s" + %s + default_task_pod_cpu = "%s" + default_task_pod_memory = "%s" + description = "%s" + %s + executor = "%s" + is_cicd_enforced = %t + is_dag_deploy_enabled = %t + is_development_mode = %t + is_high_availability = %t + name = "%s" + region = "%s" + resource_quota_cpu = "%s" + resource_quota_memory = "%s" + scheduler_size = "%s" + type = "%s" + workspace_id = "%s" + %s +} +`, + deployment.Id, + stringValue((*string)(deployment.CloudProvider)), + contactEmailsString, + stringValue(deployment.DefaultTaskPodCpu), + stringValue(deployment.DefaultTaskPodMemory), + stringValue(deployment.Description), + environmentVariablesString, + stringValue((*string)(deployment.Executor)), + deployment.IsCicdEnforced, + deployment.IsDagDeployEnabled, + boolValue(deployment.IsDevelopmentMode), + boolValue(deployment.IsHighAvailability), + deployment.Name, + stringValue(deployment.Region), + stringValue(deployment.ResourceQuotaCpu), + stringValue(deployment.ResourceQuotaMemory), + stringValue((*string)(deployment.SchedulerSize)), + stringValue((*string)(deploymentType)), + deployment.WorkspaceId, + workerQueuesString, + ) + } else { + log.Printf("Skipping deployment %s: unsupported deployment type %s", deployment.Id, stringValue((*string)(deploymentType))) + } + log.Printf("Generated import for astro_deployment.deployment_%s", deployment.Id) + + hclString += deploymentHCL + } + + return hclString, nil +} + +func stringValue(s *string) string { + if s == nil { + return "" + } + return *s +} + +func boolValue(b *bool) bool { + if b == nil { + return false + } + return *b +} + +func formatContactEmails(emails *[]string) string { + if emails == nil || len(*emails) == 0 { + return fmt.Sprintf(`contact_emails = []`) + } + quotedEmails := make([]string, len(*emails)) + for i, email := range *emails { + quotedEmails[i] = fmt.Sprintf(`"%s"`, email) + } + return fmt.Sprintf(`contact_emails = [%s]`, strings.Join(quotedEmails, ", ")) +} + +func formatEnvironmentVariables(envVars *[]platform.DeploymentEnvironmentVariable) string { + if envVars == nil || len(*envVars) == 0 { + return fmt.Sprintf(`environment_variables = []`) + } + variables := lo.Map(*envVars, func(envVar platform.DeploymentEnvironmentVariable, _ int) string { + return fmt.Sprintf(`{ + name = "%s" + value = "%s" + is_secret = %t + }`, envVar.Key, stringValue(envVar.Value), envVar.IsSecret) + }) + return fmt.Sprintf(`environment_variables = [%s]`, strings.Join(variables, ", ")) +} + +func formatWorkerQueues(queues *[]platform.WorkerQueue, executor *string) string { + // If queues is nil and executor is not CELERY, return an empty string + if queues == nil && (executor == nil || *executor != "CELERY") { + return "" + } + + // If queues is empty but executor is CELERY, return an empty worker_queues array + if (queues == nil || len(*queues) == 0) && executor != nil && *executor == "CELERY" { + return `worker_queues = []` + } + + // If we have queues, format them + if queues != nil && len(*queues) > 0 { + workerQueues := lo.Map(*queues, func(queue platform.WorkerQueue, _ int) string { + return fmt.Sprintf(`{ + astro_machine = "%s" + name = "%s" + is_default = %t + max_worker_count = %d + min_worker_count = %d + worker_concurrency = %d + }`, stringValue(queue.AstroMachine), queue.Name, queue.IsDefault, queue.MaxWorkerCount, queue.MinWorkerCount, queue.WorkerConcurrency) + }) + return fmt.Sprintf(`worker_queues = [%s]`, strings.Join(workerQueues, ", ")) + } + + // If we've reached here, it means queues is nil or empty, and executor is not CELERY + return "" +} diff --git a/import/import_script_mock_functions.go b/import/import_script_mock_functions.go new file mode 100644 index 00000000..4bd9e0e0 --- /dev/null +++ b/import/import_script_mock_functions.go @@ -0,0 +1,349 @@ +package main + +import ( + "context" + "fmt" + "log" + "net/http" + + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/iam" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + mocksIam "github.com/astronomer/terraform-provider-astro/internal/mocks/iam" + mocksPlatform "github.com/astronomer/terraform-provider-astro/internal/mocks/platform" + "github.com/samber/lo" + "golang.org/x/exp/maps" +) + +func HandleWorkspaces(ctx context.Context, platformClient *mocksPlatform.ClientWithResponsesInterface, iamClient *mocksIam.ClientWithResponsesInterface, organizationId string) (string, error) { + log.Printf("Importing workspaces for organization %s", organizationId) + + workspacesResp, err := platformClient.ListWorkspacesWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list workspaces: %v", err) + } + + if workspacesResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", workspacesResp.StatusCode(), string(workspacesResp.Body)) + } + + if workspacesResp.JSON200 == nil { + return "", fmt.Errorf("failed to list workspaces, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, workspacesResp.HTTPResponse, workspacesResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + workspaces := workspacesResp.JSON200.Workspaces + if workspaces == nil { + return "", fmt.Errorf("workspaces list is nil") + } + + workspaceIds := lo.Map(workspaces, func(workspace platform.Workspace, _ int) string { + return workspace.Id + }) + + log.Printf("Importing Workspaces: %v", workspaceIds) + + var importString string + for _, workspaceId := range workspaceIds { + workspaceImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_workspace.workspace_%v +}`, workspaceId, workspaceId) + + importString += workspaceImportString + "\n" + } + + return importString, nil +} + +func HandleDeployments(ctx context.Context, platformClient *mocksPlatform.ClientWithResponsesInterface, iamClient *mocksIam.ClientWithResponsesInterface, organizationId string) (string, error) { + log.Printf("Importing deployments for organization %s", organizationId) + + deploymentsResp, err := platformClient.ListDeploymentsWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list deployments: %v", err) + } + + if deploymentsResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", deploymentsResp.StatusCode(), string(deploymentsResp.Body)) + } + + if deploymentsResp.JSON200 == nil { + return "", fmt.Errorf("failed to list deployments, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, deploymentsResp.HTTPResponse, deploymentsResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + deployments := deploymentsResp.JSON200.Deployments + if deployments == nil { + return "", fmt.Errorf("deployments list is nil") + } + + deploymentIds := lo.Map(deployments, func(deployment platform.Deployment, _ int) string { + return deployment.Id + }) + log.Printf("Importing Deployments: %v", deploymentIds) + + var importString string + for _, deploymentId := range deploymentIds { + deploymentImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_deployment.deployment_%v +}`, deploymentId, deploymentId) + + importString += deploymentImportString + "\n" + } + + return importString, nil +} + +func HandleClusters(ctx context.Context, platformClient *mocksPlatform.ClientWithResponsesInterface, iamClient *mocksIam.ClientWithResponsesInterface, organizationId string) (string, error) { + log.Printf("Importing clusters for organization %s", organizationId) + + clustersResp, err := platformClient.ListClustersWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list clusters: %v", err) + } + + if clustersResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", clustersResp.StatusCode(), string(clustersResp.Body)) + } + + if clustersResp.JSON200 == nil { + return "", fmt.Errorf("failed to list clusters, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, clustersResp.HTTPResponse, clustersResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + clusters := clustersResp.JSON200.Clusters + if clusters == nil { + return "", fmt.Errorf("clusters list is nil") + } + + clusterMap := make(map[string]platform.ClusterType) + for _, cluster := range clusters { + if cluster.Id != "" { + clusterMap[cluster.Id] = cluster.Type + } + } + + log.Printf("Importing Clusters: %v", maps.Keys(clusterMap)) + + var importString string + for clusterId, clusterType := range clusterMap { + clusterImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_cluster.cluster_%v +}`, clusterId, clusterId) + + if clusterType == platform.ClusterTypeHYBRID { + log.Printf("Importing hybrid cluster workspace authorization for cluster %s", clusterId) + clusterImportString += fmt.Sprintf(` +import { + id = "%v" + to = astro_hybrid_cluster_workspace_authorization.cluster_%v +}`, clusterId, clusterId) + } + + importString += clusterImportString + "\n" + } + + return importString, nil +} + +func HandleApiTokens(ctx context.Context, platformClient *mocksPlatform.ClientWithResponsesInterface, iamClient *mocksIam.ClientWithResponsesInterface, organizationId string) (string, error) { + log.Printf("Importing API tokens for organization %s", organizationId) + + apiTokensResp, err := iamClient.ListApiTokensWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list API tokens: %v", err) + } + + if apiTokensResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", apiTokensResp.StatusCode(), string(apiTokensResp.Body)) + } + + if apiTokensResp.JSON200 == nil { + return "", fmt.Errorf("failed to list API tokens, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, apiTokensResp.HTTPResponse, apiTokensResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + apiTokens := apiTokensResp.JSON200.Tokens + if apiTokens == nil { + return "", fmt.Errorf("API tokens list is nil") + } + + apiTokenIds := lo.Map(apiTokens, func(apiToken iam.ApiToken, _ int) string { + return apiToken.Id + }) + + log.Printf("Importing API Tokens: %v", apiTokenIds) + + var importString string + for _, apiTokenId := range apiTokenIds { + apiTokenImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_api_token.api_token_%v +}`, apiTokenId, apiTokenId) + + importString += apiTokenImportString + "\n" + } + + return importString, nil +} + +func HandleTeams(ctx context.Context, platformClient *mocksPlatform.ClientWithResponsesInterface, iamClient *mocksIam.ClientWithResponsesInterface, organizationId string) (string, error) { + log.Printf("Importing teams for organization %s", organizationId) + + teamsResp, err := iamClient.ListTeamsWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list teams: %v", err) + } + + if teamsResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", teamsResp.StatusCode(), string(teamsResp.Body)) + } + + if teamsResp.JSON200 == nil { + return "", fmt.Errorf("failed to list teams, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, teamsResp.HTTPResponse, teamsResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + teams := teamsResp.JSON200.Teams + if teams == nil { + return "", fmt.Errorf("teams list is nil") + } + + teamIds := lo.Map(teams, func(team iam.Team, _ int) string { + return team.Id + }) + + log.Printf("Importing Teams: %v", teamIds) + + var importString string + for _, teamId := range teamIds { + teamImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_team.team_%v +}`, teamId, teamId) + + importString += teamImportString + "\n" + } + + return importString, nil +} + +func HandleTeamRoles(ctx context.Context, platformClient *mocksPlatform.ClientWithResponsesInterface, iamClient *mocksIam.ClientWithResponsesInterface, organizationId string) (string, error) { + log.Printf("Importing team roles for organization %s", organizationId) + + teamsResp, err := iamClient.ListTeamsWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list teams: %v", err) + } + + if teamsResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", teamsResp.StatusCode(), string(teamsResp.Body)) + } + + if teamsResp.JSON200 == nil { + return "", fmt.Errorf("failed to list teams, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, teamsResp.HTTPResponse, teamsResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + teams := teamsResp.JSON200.Teams + if teams == nil { + return "", fmt.Errorf("teams list is nil") + } + + teamIds := lo.Map(teams, func(team iam.Team, _ int) string { + return team.Id + }) + + log.Printf("Importing Team Roles: %v", teamIds) + + var importString string + for _, teamId := range teamIds { + teamImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_team_roles.team_%v +}`, teamId, teamId) + + importString += teamImportString + "\n" + } + + return importString, nil +} + +func HandleUserRoles(ctx context.Context, platformClient *mocksPlatform.ClientWithResponsesInterface, iamClient *mocksIam.ClientWithResponsesInterface, organizationId string) (string, error) { + log.Printf("Importing user roles for organization %s", organizationId) + + usersResp, err := iamClient.ListUsersWithResponse(ctx, organizationId, nil) + if err != nil { + return "", fmt.Errorf("failed to list users: %v", err) + } + + if usersResp.StatusCode() != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d, body: %s", usersResp.StatusCode(), string(usersResp.Body)) + } + + if usersResp.JSON200 == nil { + return "", fmt.Errorf("failed to list users, JSON200 resp is nil, organizationId: %v", organizationId) + } + + _, diagnostic := clients.NormalizeAPIError(ctx, usersResp.HTTPResponse, usersResp.Body) + if diagnostic != nil { + log.Printf("API Error diagnostic: %+v", diagnostic) + } + + users := usersResp.JSON200.Users + if users == nil { + return "", fmt.Errorf("users list is nil") + } + + userIds := lo.Map(users, func(user iam.User, _ int) string { + return user.Id + }) + + log.Printf("Importing User Roles: %v", userIds) + + var importString string + for _, userId := range userIds { + userImportString := fmt.Sprintf(` +import { + id = "%v" + to = astro_user_roles.user_%v +}`, userId, userId) + + importString += userImportString + "\n" + } + + return importString, nil +} diff --git a/import/import_script_suite_test.go b/import/import_script_suite_test.go new file mode 100644 index 00000000..d1cc53cd --- /dev/null +++ b/import/import_script_suite_test.go @@ -0,0 +1,13 @@ +package main_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestImportScript(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Import Script Suite") +} diff --git a/import/import_script_test.go b/import/import_script_test.go new file mode 100644 index 00000000..7cd7e7d2 --- /dev/null +++ b/import/import_script_test.go @@ -0,0 +1,475 @@ +package main_test + +import ( + "context" + "fmt" + "net/http" + "os" + "os/exec" + "path/filepath" + + import_script "github.com/astronomer/terraform-provider-astro/import" + "github.com/astronomer/terraform-provider-astro/internal/clients/iam" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + mocks_iam "github.com/astronomer/terraform-provider-astro/internal/mocks/iam" + mocks_platform "github.com/astronomer/terraform-provider-astro/internal/mocks/platform" + "github.com/lucsky/cuid" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("Import Script", func() { + var ctx context.Context + var mockPlatformClient *mocks_platform.ClientWithResponsesInterface + var mockIAMClient *mocks_iam.ClientWithResponsesInterface + var organizationId string + + BeforeEach(func() { + ctx = context.Background() + mockPlatformClient = new(mocks_platform.ClientWithResponsesInterface) + mockIAMClient = new(mocks_iam.ClientWithResponsesInterface) + organizationId = cuid.New() + }) + + Describe("HandleWorkspaces", func() { + It("should return an error if the platform client returns an error", func() { + mockPlatformClient.On("ListWorkspacesWithResponse", ctx, organizationId, (*platform.ListWorkspacesParams)(nil)).Return(nil, fmt.Errorf("error")) + + result, err := import_script.HandleWorkspaces(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return an error if the platform client returns a non-200 status code", func() { + mockResponse := &platform.ListWorkspacesResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusInternalServerError}, + } + + mockPlatformClient.On("ListWorkspacesWithResponse", ctx, organizationId, (*platform.ListWorkspacesParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleWorkspaces(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return a list of workspace resources", func() { + workspaceId1 := cuid.New() + workspaceId2 := cuid.New() + + workspaces := []platform.Workspace{ + {Id: workspaceId1}, + {Id: workspaceId2}, + } + + mockResponse := &platform.ListWorkspacesResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusOK}, + JSON200: &platform.WorkspacesPaginated{ + Workspaces: workspaces, + }, + } + + mockPlatformClient.On("ListWorkspacesWithResponse", ctx, organizationId, (*platform.ListWorkspacesParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleWorkspaces(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).To(BeNil()) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_workspace.workspace_%s", workspaceId1))) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_workspace.workspace_%s", workspaceId2))) + }) + }) + + Describe("HandleDeployments", func() { + It("should return an error if the platform client returns an error", func() { + mockPlatformClient.On("ListDeploymentsWithResponse", ctx, organizationId, (*platform.ListDeploymentsParams)(nil)).Return(nil, fmt.Errorf("error")) + + result, err := import_script.HandleDeployments(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return an error if the platform client returns a non-200 status code", func() { + mockResponse := &platform.ListDeploymentsResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusInternalServerError}, + } + + mockPlatformClient.On("ListDeploymentsWithResponse", ctx, organizationId, (*platform.ListDeploymentsParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleDeployments(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return a list of deployment resources", func() { + deploymentId1 := cuid.New() + deploymentId2 := cuid.New() + + deployments := []platform.Deployment{ + {Id: deploymentId1}, + {Id: deploymentId2}, + } + + mockResponse := &platform.ListDeploymentsResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusOK}, + JSON200: &platform.DeploymentsPaginated{ + Deployments: deployments, + }, + } + + mockPlatformClient.On("ListDeploymentsWithResponse", ctx, organizationId, (*platform.ListDeploymentsParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleDeployments(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).To(BeNil()) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_deployment.deployment_%s", deploymentId1))) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_deployment.deployment_%s", deploymentId2))) + }) + }) + + Describe("HandleClusters", func() { + It("should return an error if the platform client returns an error", func() { + mockPlatformClient.On("ListClustersWithResponse", ctx, organizationId, (*platform.ListClustersParams)(nil)).Return(nil, fmt.Errorf("error")) + + result, err := import_script.HandleClusters(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return an error if the platform client returns a non-200 status code", func() { + mockResponse := &platform.ListClustersResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusInternalServerError}, + } + + mockPlatformClient.On("ListClustersWithResponse", ctx, organizationId, (*platform.ListClustersParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleClusters(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return a list of cluster resources", func() { + clusterId1 := cuid.New() + clusterId2 := cuid.New() + workspaceId := cuid.New() + + clusters := []platform.Cluster{ + {Id: clusterId1}, + {Id: clusterId2, + Type: platform.ClusterTypeHYBRID, + WorkspaceIds: &[]string{workspaceId}}, + } + + mockResponse := &platform.ListClustersResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusOK}, + JSON200: &platform.ClustersPaginated{ + Clusters: clusters, + }, + } + + mockPlatformClient.On("ListClustersWithResponse", ctx, organizationId, (*platform.ListClustersParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleClusters(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).To(BeNil()) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_cluster.cluster_%s", clusterId1))) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_cluster.cluster_%s", clusterId2))) + + // Test for hybrid cluster workspace authorization + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_hybrid_cluster_workspace_authorization.cluster_%s", clusterId2))) + }) + }) + + Describe("HandleApiTokens", func() { + It("should return an error if the iam client returns an error", func() { + mockIAMClient.On("ListApiTokensWithResponse", ctx, organizationId, (*iam.ListApiTokensParams)(nil)).Return(nil, fmt.Errorf("error")) + + result, err := import_script.HandleApiTokens(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return an error if the iam client returns a non-200 status code", func() { + mockResponse := &iam.ListApiTokensResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusInternalServerError}, + } + + mockIAMClient.On("ListApiTokensWithResponse", ctx, organizationId, (*iam.ListApiTokensParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleApiTokens(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return a list of api token resources", func() { + apiTokenId1 := cuid.New() + apiTokenId2 := cuid.New() + + apiTokens := []iam.ApiToken{ + {Id: apiTokenId1}, + {Id: apiTokenId2}, + } + + mockResponse := &iam.ListApiTokensResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusOK}, + JSON200: &iam.ApiTokensPaginated{ + Tokens: apiTokens, + }, + } + + mockIAMClient.On("ListApiTokensWithResponse", ctx, organizationId, (*iam.ListApiTokensParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleApiTokens(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).To(BeNil()) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_api_token.api_token_%s", apiTokenId1))) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_api_token.api_token_%s", apiTokenId2))) + }) + }) + + Describe("HandleTeams", func() { + It("should return an error if the iam client returns an error", func() { + mockIAMClient.On("ListTeamsWithResponse", ctx, organizationId, (*iam.ListTeamsParams)(nil)).Return(nil, fmt.Errorf("error")) + + result, err := import_script.HandleTeams(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return an error if the iam client returns a non-200 status code", func() { + mockResponse := &iam.ListTeamsResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusInternalServerError}, + } + + mockIAMClient.On("ListTeamsWithResponse", ctx, organizationId, (*iam.ListTeamsParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleTeams(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return a list of team resources", func() { + teamId1 := cuid.New() + teamId2 := cuid.New() + + teams := []iam.Team{ + {Id: teamId1}, + {Id: teamId2}, + } + + mockResponse := &iam.ListTeamsResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusOK}, + JSON200: &iam.TeamsPaginated{ + Teams: teams, + }, + } + + mockIAMClient.On("ListTeamsWithResponse", ctx, organizationId, (*iam.ListTeamsParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleTeams(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).To(BeNil()) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_team.team_%s", teamId1))) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_team.team_%s", teamId2))) + }) + }) + + Describe("HandleTeamRoles", func() { + It("should return an error if the iam client returns an error", func() { + mockIAMClient.On("ListTeamsWithResponse", ctx, organizationId, (*iam.ListTeamsParams)(nil)).Return(nil, fmt.Errorf("error")) + + result, err := import_script.HandleTeamRoles(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return an error if the iam client returns a non-200 status code", func() { + mockResponse := &iam.ListTeamsResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusInternalServerError}, + } + + mockIAMClient.On("ListTeamsWithResponse", ctx, organizationId, (*iam.ListTeamsParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleTeamRoles(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return a list of team role resources", func() { + teamId1 := cuid.New() + teamId2 := cuid.New() + + teams := []iam.Team{ + {Id: teamId1}, + {Id: teamId2}, + } + + mockResponse := &iam.ListTeamsResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusOK}, + JSON200: &iam.TeamsPaginated{ + Teams: teams, + }, + } + + mockIAMClient.On("ListTeamsWithResponse", ctx, organizationId, (*iam.ListTeamsParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleTeamRoles(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).To(BeNil()) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_team_roles.team_%s", teamId1))) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_team_roles.team_%s", teamId2))) + }) + }) + + Describe("HandleUserRoles", func() { + It("should return an error if the iam client returns an error", func() { + mockIAMClient.On("ListUsersWithResponse", ctx, organizationId, (*iam.ListUsersParams)(nil)).Return(nil, fmt.Errorf("error")) + + result, err := import_script.HandleUserRoles(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return an error if the iam client returns a non-200 status code", func() { + mockResponse := &iam.ListUsersResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusInternalServerError}, + } + + mockIAMClient.On("ListUsersWithResponse", ctx, organizationId, (*iam.ListUsersParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleUserRoles(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).ToNot(BeNil()) + Expect(result).To(BeEmpty()) + }) + + It("should return a list of user resources", func() { + userId1 := cuid.New() + userId2 := cuid.New() + + users := []iam.User{ + {Id: userId1}, + {Id: userId2}, + } + + mockResponse := &iam.ListUsersResponse{ + HTTPResponse: &http.Response{StatusCode: http.StatusOK}, + JSON200: &iam.UsersPaginated{ + Users: users, + }, + } + + mockIAMClient.On("ListUsersWithResponse", ctx, organizationId, (*iam.ListUsersParams)(nil)).Return(mockResponse, nil) + + result, err := import_script.HandleUserRoles(ctx, mockPlatformClient, mockIAMClient, organizationId) + + Expect(err).To(BeNil()) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_user_roles.user_%s", userId1))) + Expect(result).To(ContainSubstring(fmt.Sprintf("astro_user_roles.user_%s", userId2))) + }) + }) +}) + +// will only work locally if organizationId and token are set +var _ = Describe("Integration Test", func() { + var organizationId, token, rootDir, importScriptPath string + + BeforeEach(func() { + organizationId = os.Getenv("HOSTED_ORGANIZATION_ID") + token = os.Getenv("HOSTED_ORGANIZATION_API_TOKEN") + + // Get the current working directory + var err error + rootDir, err = os.Getwd() + Expect(err).To(BeNil(), "Failed to get current working directory") + + // Find the import_script.go file + importScriptPath = filepath.Join(rootDir, "import_script.go") + _, err = os.Stat(importScriptPath) + if err != nil { + // If not found, try going up one directory + rootDir = filepath.Dir(rootDir) + importScriptPath = filepath.Join(rootDir, "import_script.go") + _, err = os.Stat(importScriptPath) + } + Expect(err).To(BeNil(), fmt.Sprintf("import_script.go not found at %s", importScriptPath)) + }) + + It("should return a list of generated resources - latest", func() { + if os.Getenv("SKIP_IMPORT_SCRIPT_TEST") == "" { + Skip("Skipping latest integration test") + return + } + + // Run the import_script.go file + cmd := exec.Command("go", "run", importScriptPath, + "-resources", "workspace,deployment,cluster,team_roles", + "-token", token, + "-organizationId", organizationId, + "-host", "dev", + "-runTerraformInit", "true") + + // Set the working directory to the directory containing import_script.go + cmd.Dir = filepath.Dir(importScriptPath) + + // Capture the output of the command + output, err := cmd.CombinedOutput() + if err != nil { + fmt.Printf("Error executing command: %v\n", err) + fmt.Printf("Command output: %s\n", string(output)) + Fail(fmt.Sprintf("Command failed with error: %v", err)) + } + + outputStr := string(output) + Expect(outputStr).To(ContainSubstring("astro_workspace")) + Expect(outputStr).To(ContainSubstring("astro_deployment")) + Expect(outputStr).To(ContainSubstring("astro_cluster")) + Expect(outputStr).To(ContainSubstring("astro_team_roles")) + }) + + It("should return a list of generated resources - dev", func() { + if os.Getenv("SKIP_IMPORT_SCRIPT_TEST_DEV") == "" { + Skip("Skipping dev integration test") + return + } + + // Run the import_script.go file + cmd := exec.Command("go", "run", importScriptPath, + "-resources", "workspace,deployment,cluster,api_token,team,team_roles,user_roles", + "-token", token, + "-organizationId", organizationId, + "-host", "dev", + "-runTerraformInit", "true") + + // Set the working directory to the directory containing import_script.go + cmd.Dir = filepath.Dir(importScriptPath) + + // Capture the output of the command + output, err := cmd.CombinedOutput() + if err != nil { + fmt.Printf("Error executing command: %v\n", err) + fmt.Printf("Command output: %s\n", string(output)) + Fail(fmt.Sprintf("Command failed with error: %v", err)) + } + + outputStr := string(output) + Expect(outputStr).To(ContainSubstring("astro_workspace")) + Expect(outputStr).To(ContainSubstring("astro_deployment")) + Expect(outputStr).To(ContainSubstring("astro_cluster")) + Expect(outputStr).To(ContainSubstring("astro_api_token")) + Expect(outputStr).To(ContainSubstring("astro_team")) + Expect(outputStr).To(ContainSubstring("astro_team_roles")) + Expect(outputStr).To(ContainSubstring("astro_user_roles")) + }) +}) diff --git a/internal/mocks/iam/ClientWithResponsesInterface.go b/internal/mocks/iam/ClientWithResponsesInterface.go new file mode 100644 index 00000000..268aa7a7 --- /dev/null +++ b/internal/mocks/iam/ClientWithResponsesInterface.go @@ -0,0 +1,1141 @@ +// Code generated by mockery v2.42.0. DO NOT EDIT. + +package mocks_iam + +import ( + context "context" + io "io" + + iam "github.com/astronomer/terraform-provider-astro/internal/clients/iam" + + mock "github.com/stretchr/testify/mock" +) + +// ClientWithResponsesInterface is an autogenerated mock type for the ClientWithResponsesInterface type +type ClientWithResponsesInterface struct { + mock.Mock +} + +// AddTeamMembersWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, teamId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) AddTeamMembersWithBodyWithResponse(ctx context.Context, organizationId string, teamId string, contentType string, body io.Reader, reqEditors ...iam.RequestEditorFn) (*iam.AddTeamMembersResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, teamId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for AddTeamMembersWithBodyWithResponse") + } + + var r0 *iam.AddTeamMembersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) (*iam.AddTeamMembersResponse, error)); ok { + return rf(ctx, organizationId, teamId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) *iam.AddTeamMembersResponse); ok { + r0 = rf(ctx, organizationId, teamId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.AddTeamMembersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, teamId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// AddTeamMembersWithResponse provides a mock function with given fields: ctx, organizationId, teamId, body, reqEditors +func (_m *ClientWithResponsesInterface) AddTeamMembersWithResponse(ctx context.Context, organizationId string, teamId string, body iam.AddTeamMembersRequest, reqEditors ...iam.RequestEditorFn) (*iam.AddTeamMembersResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, teamId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for AddTeamMembersWithResponse") + } + + var r0 *iam.AddTeamMembersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.AddTeamMembersRequest, ...iam.RequestEditorFn) (*iam.AddTeamMembersResponse, error)); ok { + return rf(ctx, organizationId, teamId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.AddTeamMembersRequest, ...iam.RequestEditorFn) *iam.AddTeamMembersResponse); ok { + r0 = rf(ctx, organizationId, teamId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.AddTeamMembersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, iam.AddTeamMembersRequest, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, teamId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateApiTokenWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateApiTokenWithBodyWithResponse(ctx context.Context, organizationId string, contentType string, body io.Reader, reqEditors ...iam.RequestEditorFn) (*iam.CreateApiTokenResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateApiTokenWithBodyWithResponse") + } + + var r0 *iam.CreateApiTokenResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...iam.RequestEditorFn) (*iam.CreateApiTokenResponse, error)); ok { + return rf(ctx, organizationId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...iam.RequestEditorFn) *iam.CreateApiTokenResponse); ok { + r0 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.CreateApiTokenResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateApiTokenWithResponse provides a mock function with given fields: ctx, organizationId, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateApiTokenWithResponse(ctx context.Context, organizationId string, body iam.CreateApiTokenRequest, reqEditors ...iam.RequestEditorFn) (*iam.CreateApiTokenResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateApiTokenWithResponse") + } + + var r0 *iam.CreateApiTokenResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, iam.CreateApiTokenRequest, ...iam.RequestEditorFn) (*iam.CreateApiTokenResponse, error)); ok { + return rf(ctx, organizationId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, iam.CreateApiTokenRequest, ...iam.RequestEditorFn) *iam.CreateApiTokenResponse); ok { + r0 = rf(ctx, organizationId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.CreateApiTokenResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, iam.CreateApiTokenRequest, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateTeamWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateTeamWithBodyWithResponse(ctx context.Context, organizationId string, contentType string, body io.Reader, reqEditors ...iam.RequestEditorFn) (*iam.CreateTeamResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateTeamWithBodyWithResponse") + } + + var r0 *iam.CreateTeamResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...iam.RequestEditorFn) (*iam.CreateTeamResponse, error)); ok { + return rf(ctx, organizationId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...iam.RequestEditorFn) *iam.CreateTeamResponse); ok { + r0 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.CreateTeamResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateTeamWithResponse provides a mock function with given fields: ctx, organizationId, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateTeamWithResponse(ctx context.Context, organizationId string, body iam.CreateTeamRequest, reqEditors ...iam.RequestEditorFn) (*iam.CreateTeamResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateTeamWithResponse") + } + + var r0 *iam.CreateTeamResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, iam.CreateTeamRequest, ...iam.RequestEditorFn) (*iam.CreateTeamResponse, error)); ok { + return rf(ctx, organizationId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, iam.CreateTeamRequest, ...iam.RequestEditorFn) *iam.CreateTeamResponse); ok { + r0 = rf(ctx, organizationId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.CreateTeamResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, iam.CreateTeamRequest, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateUserInviteWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateUserInviteWithBodyWithResponse(ctx context.Context, organizationId string, contentType string, body io.Reader, reqEditors ...iam.RequestEditorFn) (*iam.CreateUserInviteResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateUserInviteWithBodyWithResponse") + } + + var r0 *iam.CreateUserInviteResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...iam.RequestEditorFn) (*iam.CreateUserInviteResponse, error)); ok { + return rf(ctx, organizationId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...iam.RequestEditorFn) *iam.CreateUserInviteResponse); ok { + r0 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.CreateUserInviteResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateUserInviteWithResponse provides a mock function with given fields: ctx, organizationId, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateUserInviteWithResponse(ctx context.Context, organizationId string, body iam.CreateUserInviteRequest, reqEditors ...iam.RequestEditorFn) (*iam.CreateUserInviteResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateUserInviteWithResponse") + } + + var r0 *iam.CreateUserInviteResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, iam.CreateUserInviteRequest, ...iam.RequestEditorFn) (*iam.CreateUserInviteResponse, error)); ok { + return rf(ctx, organizationId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, iam.CreateUserInviteRequest, ...iam.RequestEditorFn) *iam.CreateUserInviteResponse); ok { + r0 = rf(ctx, organizationId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.CreateUserInviteResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, iam.CreateUserInviteRequest, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteApiTokenWithResponse provides a mock function with given fields: ctx, organizationId, tokenId, reqEditors +func (_m *ClientWithResponsesInterface) DeleteApiTokenWithResponse(ctx context.Context, organizationId string, tokenId string, reqEditors ...iam.RequestEditorFn) (*iam.DeleteApiTokenResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, tokenId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DeleteApiTokenWithResponse") + } + + var r0 *iam.DeleteApiTokenResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) (*iam.DeleteApiTokenResponse, error)); ok { + return rf(ctx, organizationId, tokenId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) *iam.DeleteApiTokenResponse); ok { + r0 = rf(ctx, organizationId, tokenId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.DeleteApiTokenResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, tokenId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteTeamWithResponse provides a mock function with given fields: ctx, organizationId, teamId, reqEditors +func (_m *ClientWithResponsesInterface) DeleteTeamWithResponse(ctx context.Context, organizationId string, teamId string, reqEditors ...iam.RequestEditorFn) (*iam.DeleteTeamResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, teamId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DeleteTeamWithResponse") + } + + var r0 *iam.DeleteTeamResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) (*iam.DeleteTeamResponse, error)); ok { + return rf(ctx, organizationId, teamId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) *iam.DeleteTeamResponse); ok { + r0 = rf(ctx, organizationId, teamId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.DeleteTeamResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, teamId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteUserInviteWithResponse provides a mock function with given fields: ctx, organizationId, inviteId, reqEditors +func (_m *ClientWithResponsesInterface) DeleteUserInviteWithResponse(ctx context.Context, organizationId string, inviteId string, reqEditors ...iam.RequestEditorFn) (*iam.DeleteUserInviteResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, inviteId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DeleteUserInviteWithResponse") + } + + var r0 *iam.DeleteUserInviteResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) (*iam.DeleteUserInviteResponse, error)); ok { + return rf(ctx, organizationId, inviteId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) *iam.DeleteUserInviteResponse); ok { + r0 = rf(ctx, organizationId, inviteId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.DeleteUserInviteResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, inviteId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetApiTokenWithResponse provides a mock function with given fields: ctx, organizationId, tokenId, reqEditors +func (_m *ClientWithResponsesInterface) GetApiTokenWithResponse(ctx context.Context, organizationId string, tokenId string, reqEditors ...iam.RequestEditorFn) (*iam.GetApiTokenResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, tokenId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetApiTokenWithResponse") + } + + var r0 *iam.GetApiTokenResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) (*iam.GetApiTokenResponse, error)); ok { + return rf(ctx, organizationId, tokenId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) *iam.GetApiTokenResponse); ok { + r0 = rf(ctx, organizationId, tokenId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.GetApiTokenResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, tokenId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetTeamWithResponse provides a mock function with given fields: ctx, organizationId, teamId, reqEditors +func (_m *ClientWithResponsesInterface) GetTeamWithResponse(ctx context.Context, organizationId string, teamId string, reqEditors ...iam.RequestEditorFn) (*iam.GetTeamResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, teamId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetTeamWithResponse") + } + + var r0 *iam.GetTeamResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) (*iam.GetTeamResponse, error)); ok { + return rf(ctx, organizationId, teamId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) *iam.GetTeamResponse); ok { + r0 = rf(ctx, organizationId, teamId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.GetTeamResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, teamId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetUserWithResponse provides a mock function with given fields: ctx, organizationId, userId, reqEditors +func (_m *ClientWithResponsesInterface) GetUserWithResponse(ctx context.Context, organizationId string, userId string, reqEditors ...iam.RequestEditorFn) (*iam.GetUserResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, userId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetUserWithResponse") + } + + var r0 *iam.GetUserResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) (*iam.GetUserResponse, error)); ok { + return rf(ctx, organizationId, userId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) *iam.GetUserResponse); ok { + r0 = rf(ctx, organizationId, userId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.GetUserResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, userId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListApiTokensWithResponse provides a mock function with given fields: ctx, organizationId, params, reqEditors +func (_m *ClientWithResponsesInterface) ListApiTokensWithResponse(ctx context.Context, organizationId string, params *iam.ListApiTokensParams, reqEditors ...iam.RequestEditorFn) (*iam.ListApiTokensResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListApiTokensWithResponse") + } + + var r0 *iam.ListApiTokensResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *iam.ListApiTokensParams, ...iam.RequestEditorFn) (*iam.ListApiTokensResponse, error)); ok { + return rf(ctx, organizationId, params, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *iam.ListApiTokensParams, ...iam.RequestEditorFn) *iam.ListApiTokensResponse); ok { + r0 = rf(ctx, organizationId, params, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.ListApiTokensResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *iam.ListApiTokensParams, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, params, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListTeamMembersWithResponse provides a mock function with given fields: ctx, organizationId, teamId, params, reqEditors +func (_m *ClientWithResponsesInterface) ListTeamMembersWithResponse(ctx context.Context, organizationId string, teamId string, params *iam.ListTeamMembersParams, reqEditors ...iam.RequestEditorFn) (*iam.ListTeamMembersResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, teamId, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListTeamMembersWithResponse") + } + + var r0 *iam.ListTeamMembersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, *iam.ListTeamMembersParams, ...iam.RequestEditorFn) (*iam.ListTeamMembersResponse, error)); ok { + return rf(ctx, organizationId, teamId, params, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, *iam.ListTeamMembersParams, ...iam.RequestEditorFn) *iam.ListTeamMembersResponse); ok { + r0 = rf(ctx, organizationId, teamId, params, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.ListTeamMembersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, *iam.ListTeamMembersParams, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, teamId, params, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListTeamsWithResponse provides a mock function with given fields: ctx, organizationId, params, reqEditors +func (_m *ClientWithResponsesInterface) ListTeamsWithResponse(ctx context.Context, organizationId string, params *iam.ListTeamsParams, reqEditors ...iam.RequestEditorFn) (*iam.ListTeamsResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListTeamsWithResponse") + } + + var r0 *iam.ListTeamsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *iam.ListTeamsParams, ...iam.RequestEditorFn) (*iam.ListTeamsResponse, error)); ok { + return rf(ctx, organizationId, params, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *iam.ListTeamsParams, ...iam.RequestEditorFn) *iam.ListTeamsResponse); ok { + r0 = rf(ctx, organizationId, params, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.ListTeamsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *iam.ListTeamsParams, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, params, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListUsersWithResponse provides a mock function with given fields: ctx, organizationId, params, reqEditors +func (_m *ClientWithResponsesInterface) ListUsersWithResponse(ctx context.Context, organizationId string, params *iam.ListUsersParams, reqEditors ...iam.RequestEditorFn) (*iam.ListUsersResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListUsersWithResponse") + } + + var r0 *iam.ListUsersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *iam.ListUsersParams, ...iam.RequestEditorFn) (*iam.ListUsersResponse, error)); ok { + return rf(ctx, organizationId, params, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *iam.ListUsersParams, ...iam.RequestEditorFn) *iam.ListUsersResponse); ok { + r0 = rf(ctx, organizationId, params, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.ListUsersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *iam.ListUsersParams, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, params, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RemoveTeamMemberWithResponse provides a mock function with given fields: ctx, organizationId, teamId, memberId, reqEditors +func (_m *ClientWithResponsesInterface) RemoveTeamMemberWithResponse(ctx context.Context, organizationId string, teamId string, memberId string, reqEditors ...iam.RequestEditorFn) (*iam.RemoveTeamMemberResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, teamId, memberId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for RemoveTeamMemberWithResponse") + } + + var r0 *iam.RemoveTeamMemberResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, ...iam.RequestEditorFn) (*iam.RemoveTeamMemberResponse, error)); ok { + return rf(ctx, organizationId, teamId, memberId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, ...iam.RequestEditorFn) *iam.RemoveTeamMemberResponse); ok { + r0 = rf(ctx, organizationId, teamId, memberId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.RemoveTeamMemberResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, teamId, memberId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RotateApiTokenWithResponse provides a mock function with given fields: ctx, organizationId, tokenId, reqEditors +func (_m *ClientWithResponsesInterface) RotateApiTokenWithResponse(ctx context.Context, organizationId string, tokenId string, reqEditors ...iam.RequestEditorFn) (*iam.RotateApiTokenResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, tokenId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for RotateApiTokenWithResponse") + } + + var r0 *iam.RotateApiTokenResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) (*iam.RotateApiTokenResponse, error)); ok { + return rf(ctx, organizationId, tokenId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...iam.RequestEditorFn) *iam.RotateApiTokenResponse); ok { + r0 = rf(ctx, organizationId, tokenId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.RotateApiTokenResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, tokenId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateApiTokenRolesWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, tokenId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateApiTokenRolesWithBodyWithResponse(ctx context.Context, organizationId string, tokenId string, contentType string, body io.Reader, reqEditors ...iam.RequestEditorFn) (*iam.UpdateApiTokenRolesResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, tokenId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateApiTokenRolesWithBodyWithResponse") + } + + var r0 *iam.UpdateApiTokenRolesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) (*iam.UpdateApiTokenRolesResponse, error)); ok { + return rf(ctx, organizationId, tokenId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) *iam.UpdateApiTokenRolesResponse); ok { + r0 = rf(ctx, organizationId, tokenId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.UpdateApiTokenRolesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, tokenId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateApiTokenRolesWithResponse provides a mock function with given fields: ctx, organizationId, tokenId, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateApiTokenRolesWithResponse(ctx context.Context, organizationId string, tokenId string, body iam.UpdateApiTokenRolesRequest, reqEditors ...iam.RequestEditorFn) (*iam.UpdateApiTokenRolesResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, tokenId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateApiTokenRolesWithResponse") + } + + var r0 *iam.UpdateApiTokenRolesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.UpdateApiTokenRolesRequest, ...iam.RequestEditorFn) (*iam.UpdateApiTokenRolesResponse, error)); ok { + return rf(ctx, organizationId, tokenId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.UpdateApiTokenRolesRequest, ...iam.RequestEditorFn) *iam.UpdateApiTokenRolesResponse); ok { + r0 = rf(ctx, organizationId, tokenId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.UpdateApiTokenRolesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, iam.UpdateApiTokenRolesRequest, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, tokenId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateApiTokenWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, tokenId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateApiTokenWithBodyWithResponse(ctx context.Context, organizationId string, tokenId string, contentType string, body io.Reader, reqEditors ...iam.RequestEditorFn) (*iam.UpdateApiTokenResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, tokenId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateApiTokenWithBodyWithResponse") + } + + var r0 *iam.UpdateApiTokenResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) (*iam.UpdateApiTokenResponse, error)); ok { + return rf(ctx, organizationId, tokenId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) *iam.UpdateApiTokenResponse); ok { + r0 = rf(ctx, organizationId, tokenId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.UpdateApiTokenResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, tokenId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateApiTokenWithResponse provides a mock function with given fields: ctx, organizationId, tokenId, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateApiTokenWithResponse(ctx context.Context, organizationId string, tokenId string, body iam.UpdateApiTokenRequest, reqEditors ...iam.RequestEditorFn) (*iam.UpdateApiTokenResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, tokenId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateApiTokenWithResponse") + } + + var r0 *iam.UpdateApiTokenResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.UpdateApiTokenRequest, ...iam.RequestEditorFn) (*iam.UpdateApiTokenResponse, error)); ok { + return rf(ctx, organizationId, tokenId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.UpdateApiTokenRequest, ...iam.RequestEditorFn) *iam.UpdateApiTokenResponse); ok { + r0 = rf(ctx, organizationId, tokenId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.UpdateApiTokenResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, iam.UpdateApiTokenRequest, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, tokenId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateTeamRolesWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, teamId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateTeamRolesWithBodyWithResponse(ctx context.Context, organizationId string, teamId string, contentType string, body io.Reader, reqEditors ...iam.RequestEditorFn) (*iam.UpdateTeamRolesResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, teamId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateTeamRolesWithBodyWithResponse") + } + + var r0 *iam.UpdateTeamRolesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) (*iam.UpdateTeamRolesResponse, error)); ok { + return rf(ctx, organizationId, teamId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) *iam.UpdateTeamRolesResponse); ok { + r0 = rf(ctx, organizationId, teamId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.UpdateTeamRolesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, teamId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateTeamRolesWithResponse provides a mock function with given fields: ctx, organizationId, teamId, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateTeamRolesWithResponse(ctx context.Context, organizationId string, teamId string, body iam.UpdateTeamRolesRequest, reqEditors ...iam.RequestEditorFn) (*iam.UpdateTeamRolesResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, teamId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateTeamRolesWithResponse") + } + + var r0 *iam.UpdateTeamRolesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.UpdateTeamRolesRequest, ...iam.RequestEditorFn) (*iam.UpdateTeamRolesResponse, error)); ok { + return rf(ctx, organizationId, teamId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.UpdateTeamRolesRequest, ...iam.RequestEditorFn) *iam.UpdateTeamRolesResponse); ok { + r0 = rf(ctx, organizationId, teamId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.UpdateTeamRolesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, iam.UpdateTeamRolesRequest, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, teamId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateTeamWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, teamId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateTeamWithBodyWithResponse(ctx context.Context, organizationId string, teamId string, contentType string, body io.Reader, reqEditors ...iam.RequestEditorFn) (*iam.UpdateTeamResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, teamId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateTeamWithBodyWithResponse") + } + + var r0 *iam.UpdateTeamResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) (*iam.UpdateTeamResponse, error)); ok { + return rf(ctx, organizationId, teamId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) *iam.UpdateTeamResponse); ok { + r0 = rf(ctx, organizationId, teamId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.UpdateTeamResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, teamId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateTeamWithResponse provides a mock function with given fields: ctx, organizationId, teamId, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateTeamWithResponse(ctx context.Context, organizationId string, teamId string, body iam.UpdateTeamRequest, reqEditors ...iam.RequestEditorFn) (*iam.UpdateTeamResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, teamId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateTeamWithResponse") + } + + var r0 *iam.UpdateTeamResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.UpdateTeamRequest, ...iam.RequestEditorFn) (*iam.UpdateTeamResponse, error)); ok { + return rf(ctx, organizationId, teamId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.UpdateTeamRequest, ...iam.RequestEditorFn) *iam.UpdateTeamResponse); ok { + r0 = rf(ctx, organizationId, teamId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.UpdateTeamResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, iam.UpdateTeamRequest, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, teamId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateUserRolesWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, userId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateUserRolesWithBodyWithResponse(ctx context.Context, organizationId string, userId string, contentType string, body io.Reader, reqEditors ...iam.RequestEditorFn) (*iam.UpdateUserRolesResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, userId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateUserRolesWithBodyWithResponse") + } + + var r0 *iam.UpdateUserRolesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) (*iam.UpdateUserRolesResponse, error)); ok { + return rf(ctx, organizationId, userId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) *iam.UpdateUserRolesResponse); ok { + r0 = rf(ctx, organizationId, userId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.UpdateUserRolesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, io.Reader, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, userId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateUserRolesWithResponse provides a mock function with given fields: ctx, organizationId, userId, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateUserRolesWithResponse(ctx context.Context, organizationId string, userId string, body iam.UpdateUserRolesRequest, reqEditors ...iam.RequestEditorFn) (*iam.UpdateUserRolesResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, userId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateUserRolesWithResponse") + } + + var r0 *iam.UpdateUserRolesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.UpdateUserRolesRequest, ...iam.RequestEditorFn) (*iam.UpdateUserRolesResponse, error)); ok { + return rf(ctx, organizationId, userId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, iam.UpdateUserRolesRequest, ...iam.RequestEditorFn) *iam.UpdateUserRolesResponse); ok { + r0 = rf(ctx, organizationId, userId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*iam.UpdateUserRolesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, iam.UpdateUserRolesRequest, ...iam.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, userId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewClientWithResponsesInterface creates a new instance of ClientWithResponsesInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewClientWithResponsesInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *ClientWithResponsesInterface { + mock := &ClientWithResponsesInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/mocks/platform/ClientWithResponsesInterface.go b/internal/mocks/platform/ClientWithResponsesInterface.go new file mode 100644 index 00000000..91bf39bd --- /dev/null +++ b/internal/mocks/platform/ClientWithResponsesInterface.go @@ -0,0 +1,1141 @@ +// Code generated by mockery v2.42.0. DO NOT EDIT. + +package mocks_platform + +import ( + context "context" + io "io" + + mock "github.com/stretchr/testify/mock" + + platform "github.com/astronomer/terraform-provider-astro/internal/clients/platform" +) + +// ClientWithResponsesInterface is an autogenerated mock type for the ClientWithResponsesInterface type +type ClientWithResponsesInterface struct { + mock.Mock +} + +// CreateClusterWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateClusterWithBodyWithResponse(ctx context.Context, organizationId string, contentType string, body io.Reader, reqEditors ...platform.RequestEditorFn) (*platform.CreateClusterResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateClusterWithBodyWithResponse") + } + + var r0 *platform.CreateClusterResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) (*platform.CreateClusterResponse, error)); ok { + return rf(ctx, organizationId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) *platform.CreateClusterResponse); ok { + r0 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.CreateClusterResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateClusterWithResponse provides a mock function with given fields: ctx, organizationId, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateClusterWithResponse(ctx context.Context, organizationId string, body platform.CreateClusterRequest, reqEditors ...platform.RequestEditorFn) (*platform.CreateClusterResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateClusterWithResponse") + } + + var r0 *platform.CreateClusterResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, platform.CreateClusterRequest, ...platform.RequestEditorFn) (*platform.CreateClusterResponse, error)); ok { + return rf(ctx, organizationId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, platform.CreateClusterRequest, ...platform.RequestEditorFn) *platform.CreateClusterResponse); ok { + r0 = rf(ctx, organizationId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.CreateClusterResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, platform.CreateClusterRequest, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateDeploymentWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateDeploymentWithBodyWithResponse(ctx context.Context, organizationId string, contentType string, body io.Reader, reqEditors ...platform.RequestEditorFn) (*platform.CreateDeploymentResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateDeploymentWithBodyWithResponse") + } + + var r0 *platform.CreateDeploymentResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) (*platform.CreateDeploymentResponse, error)); ok { + return rf(ctx, organizationId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) *platform.CreateDeploymentResponse); ok { + r0 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.CreateDeploymentResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateDeploymentWithResponse provides a mock function with given fields: ctx, organizationId, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateDeploymentWithResponse(ctx context.Context, organizationId string, body platform.CreateDeploymentRequest, reqEditors ...platform.RequestEditorFn) (*platform.CreateDeploymentResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateDeploymentWithResponse") + } + + var r0 *platform.CreateDeploymentResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, platform.CreateDeploymentRequest, ...platform.RequestEditorFn) (*platform.CreateDeploymentResponse, error)); ok { + return rf(ctx, organizationId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, platform.CreateDeploymentRequest, ...platform.RequestEditorFn) *platform.CreateDeploymentResponse); ok { + r0 = rf(ctx, organizationId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.CreateDeploymentResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, platform.CreateDeploymentRequest, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateWorkspaceWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateWorkspaceWithBodyWithResponse(ctx context.Context, organizationId string, contentType string, body io.Reader, reqEditors ...platform.RequestEditorFn) (*platform.CreateWorkspaceResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateWorkspaceWithBodyWithResponse") + } + + var r0 *platform.CreateWorkspaceResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) (*platform.CreateWorkspaceResponse, error)); ok { + return rf(ctx, organizationId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) *platform.CreateWorkspaceResponse); ok { + r0 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.CreateWorkspaceResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateWorkspaceWithResponse provides a mock function with given fields: ctx, organizationId, body, reqEditors +func (_m *ClientWithResponsesInterface) CreateWorkspaceWithResponse(ctx context.Context, organizationId string, body platform.CreateWorkspaceRequest, reqEditors ...platform.RequestEditorFn) (*platform.CreateWorkspaceResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateWorkspaceWithResponse") + } + + var r0 *platform.CreateWorkspaceResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, platform.CreateWorkspaceRequest, ...platform.RequestEditorFn) (*platform.CreateWorkspaceResponse, error)); ok { + return rf(ctx, organizationId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, platform.CreateWorkspaceRequest, ...platform.RequestEditorFn) *platform.CreateWorkspaceResponse); ok { + r0 = rf(ctx, organizationId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.CreateWorkspaceResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, platform.CreateWorkspaceRequest, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteClusterWithResponse provides a mock function with given fields: ctx, organizationId, clusterId, reqEditors +func (_m *ClientWithResponsesInterface) DeleteClusterWithResponse(ctx context.Context, organizationId string, clusterId string, reqEditors ...platform.RequestEditorFn) (*platform.DeleteClusterResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, clusterId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DeleteClusterWithResponse") + } + + var r0 *platform.DeleteClusterResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) (*platform.DeleteClusterResponse, error)); ok { + return rf(ctx, organizationId, clusterId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) *platform.DeleteClusterResponse); ok { + r0 = rf(ctx, organizationId, clusterId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.DeleteClusterResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, clusterId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteDeploymentHibernationOverrideWithResponse provides a mock function with given fields: ctx, organizationId, deploymentId, reqEditors +func (_m *ClientWithResponsesInterface) DeleteDeploymentHibernationOverrideWithResponse(ctx context.Context, organizationId string, deploymentId string, reqEditors ...platform.RequestEditorFn) (*platform.DeleteDeploymentHibernationOverrideResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, deploymentId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DeleteDeploymentHibernationOverrideWithResponse") + } + + var r0 *platform.DeleteDeploymentHibernationOverrideResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) (*platform.DeleteDeploymentHibernationOverrideResponse, error)); ok { + return rf(ctx, organizationId, deploymentId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) *platform.DeleteDeploymentHibernationOverrideResponse); ok { + r0 = rf(ctx, organizationId, deploymentId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.DeleteDeploymentHibernationOverrideResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, deploymentId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteDeploymentWithResponse provides a mock function with given fields: ctx, organizationId, deploymentId, reqEditors +func (_m *ClientWithResponsesInterface) DeleteDeploymentWithResponse(ctx context.Context, organizationId string, deploymentId string, reqEditors ...platform.RequestEditorFn) (*platform.DeleteDeploymentResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, deploymentId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DeleteDeploymentWithResponse") + } + + var r0 *platform.DeleteDeploymentResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) (*platform.DeleteDeploymentResponse, error)); ok { + return rf(ctx, organizationId, deploymentId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) *platform.DeleteDeploymentResponse); ok { + r0 = rf(ctx, organizationId, deploymentId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.DeleteDeploymentResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, deploymentId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteWorkspaceWithResponse provides a mock function with given fields: ctx, organizationId, workspaceId, reqEditors +func (_m *ClientWithResponsesInterface) DeleteWorkspaceWithResponse(ctx context.Context, organizationId string, workspaceId string, reqEditors ...platform.RequestEditorFn) (*platform.DeleteWorkspaceResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, workspaceId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DeleteWorkspaceWithResponse") + } + + var r0 *platform.DeleteWorkspaceResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) (*platform.DeleteWorkspaceResponse, error)); ok { + return rf(ctx, organizationId, workspaceId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) *platform.DeleteWorkspaceResponse); ok { + r0 = rf(ctx, organizationId, workspaceId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.DeleteWorkspaceResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, workspaceId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetClusterOptionsWithResponse provides a mock function with given fields: ctx, organizationId, params, reqEditors +func (_m *ClientWithResponsesInterface) GetClusterOptionsWithResponse(ctx context.Context, organizationId string, params *platform.GetClusterOptionsParams, reqEditors ...platform.RequestEditorFn) (*platform.GetClusterOptionsResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetClusterOptionsWithResponse") + } + + var r0 *platform.GetClusterOptionsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.GetClusterOptionsParams, ...platform.RequestEditorFn) (*platform.GetClusterOptionsResponse, error)); ok { + return rf(ctx, organizationId, params, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.GetClusterOptionsParams, ...platform.RequestEditorFn) *platform.GetClusterOptionsResponse); ok { + r0 = rf(ctx, organizationId, params, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.GetClusterOptionsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *platform.GetClusterOptionsParams, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, params, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetClusterWithResponse provides a mock function with given fields: ctx, organizationId, clusterId, reqEditors +func (_m *ClientWithResponsesInterface) GetClusterWithResponse(ctx context.Context, organizationId string, clusterId string, reqEditors ...platform.RequestEditorFn) (*platform.GetClusterResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, clusterId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetClusterWithResponse") + } + + var r0 *platform.GetClusterResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) (*platform.GetClusterResponse, error)); ok { + return rf(ctx, organizationId, clusterId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) *platform.GetClusterResponse); ok { + r0 = rf(ctx, organizationId, clusterId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.GetClusterResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, clusterId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetDeploymentOptionsWithResponse provides a mock function with given fields: ctx, organizationId, params, reqEditors +func (_m *ClientWithResponsesInterface) GetDeploymentOptionsWithResponse(ctx context.Context, organizationId string, params *platform.GetDeploymentOptionsParams, reqEditors ...platform.RequestEditorFn) (*platform.GetDeploymentOptionsResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetDeploymentOptionsWithResponse") + } + + var r0 *platform.GetDeploymentOptionsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.GetDeploymentOptionsParams, ...platform.RequestEditorFn) (*platform.GetDeploymentOptionsResponse, error)); ok { + return rf(ctx, organizationId, params, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.GetDeploymentOptionsParams, ...platform.RequestEditorFn) *platform.GetDeploymentOptionsResponse); ok { + r0 = rf(ctx, organizationId, params, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.GetDeploymentOptionsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *platform.GetDeploymentOptionsParams, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, params, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetDeploymentWithResponse provides a mock function with given fields: ctx, organizationId, deploymentId, reqEditors +func (_m *ClientWithResponsesInterface) GetDeploymentWithResponse(ctx context.Context, organizationId string, deploymentId string, reqEditors ...platform.RequestEditorFn) (*platform.GetDeploymentResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, deploymentId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetDeploymentWithResponse") + } + + var r0 *platform.GetDeploymentResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) (*platform.GetDeploymentResponse, error)); ok { + return rf(ctx, organizationId, deploymentId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) *platform.GetDeploymentResponse); ok { + r0 = rf(ctx, organizationId, deploymentId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.GetDeploymentResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, deploymentId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetOrganizationWithResponse provides a mock function with given fields: ctx, organizationId, params, reqEditors +func (_m *ClientWithResponsesInterface) GetOrganizationWithResponse(ctx context.Context, organizationId string, params *platform.GetOrganizationParams, reqEditors ...platform.RequestEditorFn) (*platform.GetOrganizationResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetOrganizationWithResponse") + } + + var r0 *platform.GetOrganizationResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.GetOrganizationParams, ...platform.RequestEditorFn) (*platform.GetOrganizationResponse, error)); ok { + return rf(ctx, organizationId, params, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.GetOrganizationParams, ...platform.RequestEditorFn) *platform.GetOrganizationResponse); ok { + r0 = rf(ctx, organizationId, params, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.GetOrganizationResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *platform.GetOrganizationParams, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, params, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetWorkspaceWithResponse provides a mock function with given fields: ctx, organizationId, workspaceId, reqEditors +func (_m *ClientWithResponsesInterface) GetWorkspaceWithResponse(ctx context.Context, organizationId string, workspaceId string, reqEditors ...platform.RequestEditorFn) (*platform.GetWorkspaceResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, workspaceId) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetWorkspaceWithResponse") + } + + var r0 *platform.GetWorkspaceResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) (*platform.GetWorkspaceResponse, error)); ok { + return rf(ctx, organizationId, workspaceId, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...platform.RequestEditorFn) *platform.GetWorkspaceResponse); ok { + r0 = rf(ctx, organizationId, workspaceId, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.GetWorkspaceResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, workspaceId, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListClustersWithResponse provides a mock function with given fields: ctx, organizationId, params, reqEditors +func (_m *ClientWithResponsesInterface) ListClustersWithResponse(ctx context.Context, organizationId string, params *platform.ListClustersParams, reqEditors ...platform.RequestEditorFn) (*platform.ListClustersResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListClustersWithResponse") + } + + var r0 *platform.ListClustersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.ListClustersParams, ...platform.RequestEditorFn) (*platform.ListClustersResponse, error)); ok { + return rf(ctx, organizationId, params, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.ListClustersParams, ...platform.RequestEditorFn) *platform.ListClustersResponse); ok { + r0 = rf(ctx, organizationId, params, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.ListClustersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *platform.ListClustersParams, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, params, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListDeploymentsWithResponse provides a mock function with given fields: ctx, organizationId, params, reqEditors +func (_m *ClientWithResponsesInterface) ListDeploymentsWithResponse(ctx context.Context, organizationId string, params *platform.ListDeploymentsParams, reqEditors ...platform.RequestEditorFn) (*platform.ListDeploymentsResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListDeploymentsWithResponse") + } + + var r0 *platform.ListDeploymentsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.ListDeploymentsParams, ...platform.RequestEditorFn) (*platform.ListDeploymentsResponse, error)); ok { + return rf(ctx, organizationId, params, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.ListDeploymentsParams, ...platform.RequestEditorFn) *platform.ListDeploymentsResponse); ok { + r0 = rf(ctx, organizationId, params, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.ListDeploymentsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *platform.ListDeploymentsParams, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, params, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListOrganizationsWithResponse provides a mock function with given fields: ctx, params, reqEditors +func (_m *ClientWithResponsesInterface) ListOrganizationsWithResponse(ctx context.Context, params *platform.ListOrganizationsParams, reqEditors ...platform.RequestEditorFn) (*platform.ListOrganizationsResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListOrganizationsWithResponse") + } + + var r0 *platform.ListOrganizationsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *platform.ListOrganizationsParams, ...platform.RequestEditorFn) (*platform.ListOrganizationsResponse, error)); ok { + return rf(ctx, params, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, *platform.ListOrganizationsParams, ...platform.RequestEditorFn) *platform.ListOrganizationsResponse); ok { + r0 = rf(ctx, params, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.ListOrganizationsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *platform.ListOrganizationsParams, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, params, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListWorkspacesWithResponse provides a mock function with given fields: ctx, organizationId, params, reqEditors +func (_m *ClientWithResponsesInterface) ListWorkspacesWithResponse(ctx context.Context, organizationId string, params *platform.ListWorkspacesParams, reqEditors ...platform.RequestEditorFn) (*platform.ListWorkspacesResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListWorkspacesWithResponse") + } + + var r0 *platform.ListWorkspacesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.ListWorkspacesParams, ...platform.RequestEditorFn) (*platform.ListWorkspacesResponse, error)); ok { + return rf(ctx, organizationId, params, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *platform.ListWorkspacesParams, ...platform.RequestEditorFn) *platform.ListWorkspacesResponse); ok { + r0 = rf(ctx, organizationId, params, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.ListWorkspacesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *platform.ListWorkspacesParams, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, params, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateClusterWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, clusterId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateClusterWithBodyWithResponse(ctx context.Context, organizationId string, clusterId string, contentType string, body io.Reader, reqEditors ...platform.RequestEditorFn) (*platform.UpdateClusterResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, clusterId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateClusterWithBodyWithResponse") + } + + var r0 *platform.UpdateClusterResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) (*platform.UpdateClusterResponse, error)); ok { + return rf(ctx, organizationId, clusterId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) *platform.UpdateClusterResponse); ok { + r0 = rf(ctx, organizationId, clusterId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.UpdateClusterResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, clusterId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateClusterWithResponse provides a mock function with given fields: ctx, organizationId, clusterId, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateClusterWithResponse(ctx context.Context, organizationId string, clusterId string, body platform.UpdateClusterRequest, reqEditors ...platform.RequestEditorFn) (*platform.UpdateClusterResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, clusterId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateClusterWithResponse") + } + + var r0 *platform.UpdateClusterResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, platform.UpdateClusterRequest, ...platform.RequestEditorFn) (*platform.UpdateClusterResponse, error)); ok { + return rf(ctx, organizationId, clusterId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, platform.UpdateClusterRequest, ...platform.RequestEditorFn) *platform.UpdateClusterResponse); ok { + r0 = rf(ctx, organizationId, clusterId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.UpdateClusterResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, platform.UpdateClusterRequest, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, clusterId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateDeploymentHibernationOverrideWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, deploymentId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateDeploymentHibernationOverrideWithBodyWithResponse(ctx context.Context, organizationId string, deploymentId string, contentType string, body io.Reader, reqEditors ...platform.RequestEditorFn) (*platform.UpdateDeploymentHibernationOverrideResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, deploymentId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateDeploymentHibernationOverrideWithBodyWithResponse") + } + + var r0 *platform.UpdateDeploymentHibernationOverrideResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) (*platform.UpdateDeploymentHibernationOverrideResponse, error)); ok { + return rf(ctx, organizationId, deploymentId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) *platform.UpdateDeploymentHibernationOverrideResponse); ok { + r0 = rf(ctx, organizationId, deploymentId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.UpdateDeploymentHibernationOverrideResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, deploymentId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateDeploymentHibernationOverrideWithResponse provides a mock function with given fields: ctx, organizationId, deploymentId, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateDeploymentHibernationOverrideWithResponse(ctx context.Context, organizationId string, deploymentId string, body platform.OverrideDeploymentHibernationBody, reqEditors ...platform.RequestEditorFn) (*platform.UpdateDeploymentHibernationOverrideResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, deploymentId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateDeploymentHibernationOverrideWithResponse") + } + + var r0 *platform.UpdateDeploymentHibernationOverrideResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, platform.OverrideDeploymentHibernationBody, ...platform.RequestEditorFn) (*platform.UpdateDeploymentHibernationOverrideResponse, error)); ok { + return rf(ctx, organizationId, deploymentId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, platform.OverrideDeploymentHibernationBody, ...platform.RequestEditorFn) *platform.UpdateDeploymentHibernationOverrideResponse); ok { + r0 = rf(ctx, organizationId, deploymentId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.UpdateDeploymentHibernationOverrideResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, platform.OverrideDeploymentHibernationBody, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, deploymentId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateDeploymentWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, deploymentId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateDeploymentWithBodyWithResponse(ctx context.Context, organizationId string, deploymentId string, contentType string, body io.Reader, reqEditors ...platform.RequestEditorFn) (*platform.UpdateDeploymentResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, deploymentId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateDeploymentWithBodyWithResponse") + } + + var r0 *platform.UpdateDeploymentResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) (*platform.UpdateDeploymentResponse, error)); ok { + return rf(ctx, organizationId, deploymentId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) *platform.UpdateDeploymentResponse); ok { + r0 = rf(ctx, organizationId, deploymentId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.UpdateDeploymentResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, deploymentId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateDeploymentWithResponse provides a mock function with given fields: ctx, organizationId, deploymentId, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateDeploymentWithResponse(ctx context.Context, organizationId string, deploymentId string, body platform.UpdateDeploymentRequest, reqEditors ...platform.RequestEditorFn) (*platform.UpdateDeploymentResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, deploymentId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateDeploymentWithResponse") + } + + var r0 *platform.UpdateDeploymentResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, platform.UpdateDeploymentRequest, ...platform.RequestEditorFn) (*platform.UpdateDeploymentResponse, error)); ok { + return rf(ctx, organizationId, deploymentId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, platform.UpdateDeploymentRequest, ...platform.RequestEditorFn) *platform.UpdateDeploymentResponse); ok { + r0 = rf(ctx, organizationId, deploymentId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.UpdateDeploymentResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, platform.UpdateDeploymentRequest, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, deploymentId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateOrganizationWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateOrganizationWithBodyWithResponse(ctx context.Context, organizationId string, contentType string, body io.Reader, reqEditors ...platform.RequestEditorFn) (*platform.UpdateOrganizationResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateOrganizationWithBodyWithResponse") + } + + var r0 *platform.UpdateOrganizationResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) (*platform.UpdateOrganizationResponse, error)); ok { + return rf(ctx, organizationId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) *platform.UpdateOrganizationResponse); ok { + r0 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.UpdateOrganizationResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateOrganizationWithResponse provides a mock function with given fields: ctx, organizationId, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateOrganizationWithResponse(ctx context.Context, organizationId string, body platform.UpdateOrganizationRequest, reqEditors ...platform.RequestEditorFn) (*platform.UpdateOrganizationResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateOrganizationWithResponse") + } + + var r0 *platform.UpdateOrganizationResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, platform.UpdateOrganizationRequest, ...platform.RequestEditorFn) (*platform.UpdateOrganizationResponse, error)); ok { + return rf(ctx, organizationId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, platform.UpdateOrganizationRequest, ...platform.RequestEditorFn) *platform.UpdateOrganizationResponse); ok { + r0 = rf(ctx, organizationId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.UpdateOrganizationResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, platform.UpdateOrganizationRequest, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateWorkspaceWithBodyWithResponse provides a mock function with given fields: ctx, organizationId, workspaceId, contentType, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateWorkspaceWithBodyWithResponse(ctx context.Context, organizationId string, workspaceId string, contentType string, body io.Reader, reqEditors ...platform.RequestEditorFn) (*platform.UpdateWorkspaceResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, workspaceId, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateWorkspaceWithBodyWithResponse") + } + + var r0 *platform.UpdateWorkspaceResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) (*platform.UpdateWorkspaceResponse, error)); ok { + return rf(ctx, organizationId, workspaceId, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) *platform.UpdateWorkspaceResponse); ok { + r0 = rf(ctx, organizationId, workspaceId, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.UpdateWorkspaceResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, io.Reader, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, workspaceId, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateWorkspaceWithResponse provides a mock function with given fields: ctx, organizationId, workspaceId, body, reqEditors +func (_m *ClientWithResponsesInterface) UpdateWorkspaceWithResponse(ctx context.Context, organizationId string, workspaceId string, body platform.UpdateWorkspaceRequest, reqEditors ...platform.RequestEditorFn) (*platform.UpdateWorkspaceResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, organizationId, workspaceId, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateWorkspaceWithResponse") + } + + var r0 *platform.UpdateWorkspaceResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, platform.UpdateWorkspaceRequest, ...platform.RequestEditorFn) (*platform.UpdateWorkspaceResponse, error)); ok { + return rf(ctx, organizationId, workspaceId, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, platform.UpdateWorkspaceRequest, ...platform.RequestEditorFn) *platform.UpdateWorkspaceResponse); ok { + r0 = rf(ctx, organizationId, workspaceId, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*platform.UpdateWorkspaceResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, platform.UpdateWorkspaceRequest, ...platform.RequestEditorFn) error); ok { + r1 = rf(ctx, organizationId, workspaceId, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewClientWithResponsesInterface creates a new instance of ClientWithResponsesInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewClientWithResponsesInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *ClientWithResponsesInterface { + mock := &ClientWithResponsesInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}